# pkg.macro

> Fetch properties of your project's `package.json` at compile time.

Latest version **1.0.1** (published 2020-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install pkg.macro
pnpm add pkg.macro
yarn add pkg.macro
bun add pkg.macro
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-02-08 |
| First published | 2020-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.8.0 |
| Dependencies | 4 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | citycide |
| Keywords | babel-plugin-macros, babel-macros, macro, package, json, constants |

## Links

- npm: https://www.npmjs.com/package/pkg.macro
- npm.io page: https://npm.io/package/pkg.macro

## Dependencies (4)

- [find-up](https://npm.io/package/find-up.md) ^4.1.0
- [pick-deep](https://npm.io/package/pick-deep.md) ^1.0.0
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.8.4
- [babel-plugin-macros](https://npm.io/package/babel-plugin-macros.md) ^2.8.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-02-08
- 1.0.0 — 2020-02-08

## README

# pkg.macro &middot; [![Version](https://flat.badgen.net/npm/v/pkg.macro)](https://www.npmjs.com/package/pkg.macro) [![License](https://flat.badgen.net/npm/license/pkg.macro)](https://www.npmjs.com/package/pkg.macro) [![JavaScript Standard Style](https://flat.badgen.net/badge/code%20style/standard/green)](https://standardjs.com)

> Fetch properties of your project's `package.json` at compile time.

pkg.macro allows you to turn `pkg(["name", "version"])` into
`{ name: "your-package", version: "1.0.0" }` as a build time constant.

## installation

```sh
yarn add --dev pkg.macro
```

Make sure you also have [Babel][babel] and [babel-plugin-macros][babel-plugin-macros]
installed:

```sh
yarn add --dev @babel/cli @babel/core babel-plugin-macros
```

... and configured with Babel:

```js
module.exports = {
  presets: [],
  plugins: ["babel-plugin-macros"]
}
```

## usage

```js
import pkg from "pkg.macro"

const props = pkg([
  "name",
  "version",
  "scripts.test",
  ["dependencies", "some-package"]
])
```

The above is transformed to:

```js
const props = {
  name: "your-package",
  version: "1.0.0",
  scripts: {
    test: "test-script"
  },
  dependencies: {
    "some-package": "1.0.0"
  }
}
```

## see also

* [param.macro][param.macro] &ndash; macro for partial application, inspired by Scala's `_` & Kotlin's `it`

## development

1. Clone the repo: `git clone https://github.com/citycide/pkg.macro.git`
2. Move into the new directory: `cd pkg.macro`
3. Install dependencies: `yarn` or `npm install`
4. Build the source: `yarn build` or `npm run build`
5. Run tests: `yarn test` or `npm test`

## contributing

Pull requests and any [issues](https://github.com/citycide/pkg.macro/issues)
found are always welcome.

1. Fork the project, and preferably create a branch named something like `feat-make-better`
2. Follow the build steps [above](#development) but using your forked repo
3. Modify the source files in the `src` directory as needed
4. Make sure all tests continue to pass, and it never hurts to have more tests
5. Push & pull request! :tada:

## license

MIT © [Bo Lingen / citycide](https://github.com/citycide)

[param.macro]: https://github.com/citycide/param.macro

---
_Source: https://npm.io/package/pkg.macro · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
