talira

webpack-node-externals

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.

  1. esbuild An extremely fast bundler for the web
  2. webpack A bundler for javascript and friends
  3. Parcel The zero configuration build tool for the web
  4. Webpack Bundle Analyzer A webpack plugin and CLI that shows what's in your bundles as an interactive, zoomable treemap
  5. Browserify Use Node-style require() in the browser by bundling your dependencies
  6. Vite Next Generation Frontend Tooling

Compare webpack-node-externals with the top 3