Exclude node_modules from webpack bundles for the backend
open sourceMITfree
webpack-node-externals creates a webpack externals function that leaves node_modules dependencies out of the bundle, which is what you usually want when bundling a Node.js backend with webpack. It reads the dependencies from the node_modules folder (or package.json), with an allowlist for modules you do want bundled and options for module path and import type.
Problems it solves
- bundle a Node.js server with webpack without including node_modules
- keep dependencies external in a webpack backend build
- shrink a webpack server bundle
Features
- excludes node_modules from webpack bundles
- allowlist for modules to bundle
- configurable module directory and import type
Alternatives
The same job
These do what webpack-node-externals does.
- esbuild An extremely fast bundler for the web
- webpack A bundler for javascript and friends
- Parcel The zero configuration build tool for the web
- Webpack Bundle Analyzer A webpack plugin and CLI that shows what's in your bundles as an interactive, zoomable treemap
- Browserify Use Node-style require() in the browser by bundling your dependencies
- Vite Next Generation Frontend Tooling
