Registry / web-framework / peer-deps-externals-webpack-plugin

peer-deps-externals-webpack-plugin

JSON →
library1.0.4jsnpmunverified

Webpack plugin (v1.0.4) that automatically adds a library's peerDependencies to webpack's externals configuration, preventing them from being bundled. This keeps bundle size minimal and avoids duplicate dependencies when the library is consumed. Requires webpack >=2.0.0. A lightweight alternative to manually listing externals or using other dependency exclusion plugins. Stable with no active development.

npm install peer-deps-externals-webpack-plugin
INSTALL
IMPORT
SIG · PEER-DEPS-EXTERNAL
P
peer-deps-externals-webpack-plugin
web-frameworkjavascriptv1.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PeerDepsExternalsPlugin
const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin');
import PeerDepsExternalsPlugin from 'peer-deps-externals-webpack-plugin';
CommonJS require is the standard for webpack configs; ESM syntax may not work depending on Node.js version and project configuration.
PeerDepsExternalsPlugin
const { PeerDepsExternalsPlugin } = require('peer-deps-externals-webpack-plugin');
const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin').PeerDepsExternalsPlugin;
Default export is a function, not an object; destructuring the named export is incorrect.
PeerDepsExternalsPlugin (type)
import PeerDepsExternalsPlugin from 'peer-deps-externals-webpack-plugin';
import { PeerDepsExternalsPlugin } from 'peer-deps-externals-webpack-plugin';
TypeScript users: the package does not ship type definitions; use @types/peer-deps-externals-webpack-plugin if available or declare module.

Configures webpack to automatically exclude peer dependencies from the bundle using PeerDepsExternalsPlugin.

// webpack.config.js const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: __dirname + '/dist', filename: 'bundle.js', libraryTarget: 'commonjs2', // or 'umd' for libraries }, plugins: [ new PeerDepsExternalsPlugin(), ], };
Debug
Known issues
gotchaPlugin only reads peerDependencies from the nearest package.json. If a library is nested (e.g., in monorepo), externals may be incorrect.
fix
Ensure that the webpack process is run in the directory where package.json with peerDependencies resides, or set context in webpack config.
affects: *
gotchaPlugin uses all peerDependencies from package.json; it does not filter based on environment (e.g., react vs react-dom for browser).
fix
Manually edit externals or use a function for fine-grained externals control if needed.
affects: *
deprecatedPlugin is no longer actively maintained; last release in 2021. May not support webpack 5+ features like module federation.
fix
Consider alternatives like webpack-node-externals or manual externals configuration.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'react'
React is a peerDependency but not excluded from the bundle because PeerDepsExternalsPlugin is not configured.
fix
Add `new PeerDepsExternalsPlugin()` to webpack plugins array.
TypeError: PeerDepsExternalsPlugin is not a constructor
Importing the plugin incorrectly (e.g., using named import when it's a default export).
fix
Use `const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin');`
./node_modules/.bin/webpack: line 1: unexpected EOF while looking for matching ``'
Shell quoting issue when peerDependencies contain environment variable syntax (e.g., ${npm_package_peerDependencies}) in older versions.
fix
Upgrade webpack and the plugin to latest versions; or avoid using shell variables in peerDependencies.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
webpackrequiredpeer dependency; webpack >=2.0.0 required
Agent activity
2 hits · last 30 days
node
2
Resources
peer-deps-externals-webpack-plugin — npm install peer-deps-externals-webpack-plugin · libregistry