Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
pnp-package-json-webpack-plugin
Advanced tools
A webpack plugin to generate package.json file with external modules as dependencies
A webpack plugin to generate a package.json file with external modules as dependencies
Inspired by generate-package-json-webpack-pluginyarn add --dev pnp-package-json-webpack-plugin
This plugin generates a package.json asset from modules marked in
externals
with pinned
versions using resolutions from the
PnP API. This allows for lightweight,
mostly-stable builds in Yarn workspace environments.
In your webpack configuration:
const PnpPackageJsonPlugin = require('pnp-package-json-webpack-plugin');
const basePackageValues = {
name: 'my-nodejs-module',
version: '1.0.0',
main: './index.js',
engines: {
node: '>= 14.0.0',
},
};
module.exports = {
// ...
plugins: [
new PnpPackageJsonPlugin({
basePackageValues,
}),
],
};
Please be aware that the file created should not be viewed as a replacement for
a lockfile such as yarn.lock
. The version of each external pinned by the
plugin will be stable, but it offers no control over child dependencies
installed later.
basePackageValues
Type: Object|Function
Default:
{
"name": "",
"version": "0.0.0",
"description": "",
"main": "main.js"
}
Specifies an object or function customizing the outputted package.json.
Object
webpack.config.js
module.exports = {
plugins: [
new PnpPackageJsonPlugin({
basePackageValues: {
name: 'my-app',
version: '1.0.0',
main: 'out.js',
};
}),
],
};
Function
webpack.config.js
module.exports = {
plugins: [
new PnpPackageJsonPlugin({
basePackageValues(compilation) {
const { runtimeChunk } = compilation.entrypoints.get('my-app');
return {
name: 'my-app',
version: '1.0.0',
main: runtimeChunk.files[0],
};
},
}),
],
};
outputPath
Type: String
Default: .
Specifies a filesystem path where the generated package.json will be placed.
webpack.config.js
module.exports = {
plugins: [
new PnpPackageJsonPlugin({
// plugin will generate <output.path>/package/package.json
outputPath: 'package',
}),
],
};
FAQs
A webpack plugin to generate package.json file with external modules as dependencies
The npm package pnp-package-json-webpack-plugin receives a total of 7 weekly downloads. As such, pnp-package-json-webpack-plugin popularity was classified as not popular.
We found that pnp-package-json-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.