
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
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 0 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.