Rollup plugin that generates a lean package.json file containing only the dependencies from your bundle, optionally supplemented with additional dependencies. Version 3.2.0, released 2021-01-28 with active maintenance; supports Rollup >=1.0.0 and Node >=8.3. Key differentiator: automatically extracts dependencies used in the bundle, avoiding manual pruning of package.json for deployment. Offers options to customize base contents (via object or function) and add extra dependencies with version overrides. ESM-only plugin.
npm install rollup-plugin-generate-package-jsonVerified import paths — ran on the pinned version, not inferred.
Shows basic usage: import plugin, configure output dir, set base package.json contents and extra dependencies.
Replace 'inputPackageJson' option with 'inputFolder' set to the folder path (e.g., 'src').
Rename 'inputFile' to 'inputPackageJson'.
Upgrade Rollup to version 1.0.0 or higher.
Update Node.js to version 8.3 or higher.
Use 'output.dir' in Rollup config, not 'output.file' (or set 'outputFolder' explicitly to override).
Use the import statement: import generatePackageJson from 'rollup-plugin-generate-package-json'
Use default import: import generatePackageJson from 'rollup-plugin-generate-package-json'
Ensure the folder exists and contains a valid package.json, or set 'inputFolder' to the correct path.
Set the 'outputFolder' option in the plugin or provide 'dir' in Rollup output configuration.