# rollup-plugin-generate-package-json

> Generate package.json file with packages from your bundle using Rollup

Latest version **3.2.0** (published 2019-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-generate-package-json
pnpm add rollup-plugin-generate-package-json
yarn add rollup-plugin-generate-package-json
bun add rollup-plugin-generate-package-json
```

## Health

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

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2019-11-14 |
| First published | 2018-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/rollup-plugin-generate-package-json) |
| Module format | ESM + CommonJS |
| Node | >=8.3 |
| Dependencies | 2 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Vlad Shcherbin |
| Maintainers | shcherbin |
| Keywords | rollup, rollup-plugin, generate, package.json |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-generate-package-json
- Repository: https://github.com/vladshcherbin/rollup-plugin-generate-package-json
- Homepage: https://github.com/vladshcherbin/rollup-plugin-generate-package-json#readme
- Issues: https://github.com/vladshcherbin/rollup-plugin-generate-package-json/issues
- npm.io page: https://npm.io/package/rollup-plugin-generate-package-json

## Dependencies (2)

- [read-pkg](https://npm.io/package/read-pkg.md) ^5.2.0
- [write-pkg](https://npm.io/package/write-pkg.md) ^4.0.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

- 3.2.0 (latest) — 2019-11-14
- 3.1.4 — 2019-11-12
- 3.1.3 — 2019-06-12
- 3.1.2 — 2019-03-02
- 3.1.1 — 2019-02-27
- 3.1.0 — 2019-02-20
- 3.0.0 — 2019-02-03
- 2.1.1 — 2018-07-03
- 2.1.0 — 2018-07-03
- 2.0.1 — 2018-03-14
- 2.0.0 — 2018-03-14
- 1.0.0 — 2018-01-22

## README

# rollup-plugin-generate-package-json

[![Build Status](https://travis-ci.org/vladshcherbin/rollup-plugin-generate-package-json.svg?branch=master)](https://travis-ci.org/vladshcherbin/rollup-plugin-generate-package-json)
[![Codecov](https://codecov.io/gh/vladshcherbin/rollup-plugin-generate-package-json/branch/master/graph/badge.svg)](https://codecov.io/gh/vladshcherbin/rollup-plugin-generate-package-json)

Generate `package.json` file with packages from your bundle using Rollup.

## About

This plugin is useful when you have a lot of packages in your current `package.json` file and want to create a lean one with only packages from your generated bundle, probably for deployment.

## Installation

```bash
# yarn
yarn add rollup-plugin-generate-package-json -D

# npm
npm install rollup-plugin-generate-package-json -D
```

## Usage

```js
// rollup.config.js
import generatePackageJson from 'rollup-plugin-generate-package-json'

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/app.js',
    format: 'cjs'
  },
  plugins: [
    generatePackageJson()
  ]
}
```

### Configuration

There are some useful options, all of them are optional:

#### inputFolder

Type: `string`\
Default: `current working directory`

Set input `package.json` folder.

```js
generatePackageJson({
  inputFolder: 'nested/folder'
})
```

#### outputFolder

Type: `string`\
Default: `bundle output folder`

Set output folder for generated `package.json` file.

```js
generatePackageJson({
  outputFolder: 'dist'
})
```

#### baseContents

Type: `object | function`\
Default: `{}`

Set base contents for your generated `package.json` file.

```js
generatePackageJson({
  baseContents: {
    scripts: {
      start: 'node app.js'
    },
    dependencies: {},
    private: true
  }
})
```

It can also be a function, which receives the contents of the input `package.json` file.

```js
generatePackageJson({
  baseContents: (pkg) => ({
    name: pkg.name,
    main: pkg.main.replace('src', 'dist')
    dependencies: {},
    private: true
  })
})
```

#### additionalDependencies

Type: `Array | object`\
Default: `[]`

Set dependencies which are not directly imported in the bundle, but are used by the app.

```js
generatePackageJson({
  additionalDependencies: ['pg']
})
```

It's also possible to add new dependencies or overwrite dependency version.

```js
generatePackageJson({
  additionalDependencies: {
    pg: '7.12.1',
    'react-calendar': 'file:../react-calendar/react-calendar-v2.13.2.tgz'
  }
})
```

## License

MIT

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