{"id":20259,"library":"peer-deps-externals-webpack-plugin","title":"peer-deps-externals-webpack-plugin","description":"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.","status":"maintenance","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/Updater/peer-deps-externals-webpack-plugin","tags":["javascript","webpack","plugin","peerDependencies","externals","optimize","exclude"],"install":[{"cmd":"npm install peer-deps-externals-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add peer-deps-externals-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add peer-deps-externals-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; webpack >=2.0.0 required","package":"webpack","optional":false}],"imports":[{"note":"CommonJS require is the standard for webpack configs; ESM syntax may not work depending on Node.js version and project configuration.","wrong":"import PeerDepsExternalsPlugin from 'peer-deps-externals-webpack-plugin';","symbol":"PeerDepsExternalsPlugin","correct":"const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin');"},{"note":"Default export is a function, not an object; destructuring the named export is incorrect.","wrong":"const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin').PeerDepsExternalsPlugin;","symbol":"PeerDepsExternalsPlugin","correct":"const { PeerDepsExternalsPlugin } = require('peer-deps-externals-webpack-plugin');"},{"note":"TypeScript users: the package does not ship type definitions; use @types/peer-deps-externals-webpack-plugin if available or declare module.","wrong":"import { PeerDepsExternalsPlugin } from 'peer-deps-externals-webpack-plugin';","symbol":"PeerDepsExternalsPlugin (type)","correct":"import PeerDepsExternalsPlugin from 'peer-deps-externals-webpack-plugin';"}],"quickstart":{"code":"// webpack.config.js\nconst PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'bundle.js',\n    libraryTarget: 'commonjs2', // or 'umd' for libraries\n  },\n  plugins: [\n    new PeerDepsExternalsPlugin(),\n  ],\n};","lang":"javascript","description":"Configures webpack to automatically exclude peer dependencies from the bundle using PeerDepsExternalsPlugin."},"warnings":[{"fix":"Ensure that the webpack process is run in the directory where package.json with peerDependencies resides, or set context in webpack config.","message":"Plugin only reads peerDependencies from the nearest package.json. If a library is nested (e.g., in monorepo), externals may be incorrect.","severity":"gotcha","affected_versions":"*"},{"fix":"Manually edit externals or use a function for fine-grained externals control if needed.","message":"Plugin uses all peerDependencies from package.json; it does not filter based on environment (e.g., react vs react-dom for browser).","severity":"gotcha","affected_versions":"*"},{"fix":"Consider alternatives like webpack-node-externals or manual externals configuration.","message":"Plugin is no longer actively maintained; last release in 2021. May not support webpack 5+ features like module federation.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add `new PeerDepsExternalsPlugin()` to webpack plugins array.","cause":"React is a peerDependency but not excluded from the bundle because PeerDepsExternalsPlugin is not configured.","error":"Module not found: Error: Can't resolve 'react'"},{"fix":"Use `const PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin');`","cause":"Importing the plugin incorrectly (e.g., using named import when it's a default export).","error":"TypeError: PeerDepsExternalsPlugin is not a constructor"},{"fix":"Upgrade webpack and the plugin to latest versions; or avoid using shell variables in peerDependencies.","cause":"Shell quoting issue when peerDependencies contain environment variable syntax (e.g., ${npm_package_peerDependencies}) in older versions.","error":"./node_modules/.bin/webpack: line 1: unexpected EOF while looking for matching ``'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}