webpack-node-externals
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Webpack-node-externals is a useful tool for excluding node_modules in Webpack bundle. The node modules won't be bundled but will be kept as require('module'), thus avoiding unnecessary bloat in your library and enabling better dependency management.
To use webpack-node-externals, firstly you need to install it via npm as a dev dependency. Here is how you do it:
npm install webpack-node-externals --save-dev
Then, in your webpack.config.js
, you need to require the package and use it as a function in the externals
configuration. For Webpack 4 and earlier, it would look like this:
var nodeExternals = require('webpack-node-externals');
module.exports = {
target: 'node',
externals: [nodeExternals()],
...
};
For Webpack 5, the configuration slightly changes:
var nodeExternals = require('webpack-node-externals');
module.exports = {
externalsPresets: { node: true },
externals: [nodeExternals()],
...
};
The primary documentation for webpack-node-externals can be found in the README file on the GitHub repository at https://github.com/liady/webpack-node-externals
. It provides a detailed overview of the package, including descriptions and usage examples, and explains the different configuration options available to you.