Duplicate Dependencies Webpack Plugin
raw JSON → 1.0.2 verified Sat Apr 25 auth: no javascript
A webpack plugin to detect and report duplicated dependencies in the bundle. Version 1.0.2, stable, maintained sporadically. Key differentiator: provides a hook-based architecture for custom reporting, unlike simpler duplicates plugins that only warn. Allows programmatic access to duplicate package data (name, version, root path, bytes) for integration with custom reporters or CI checks. Primarily used in webpack 4 and 5 projects to audit dependency duplication.
Common errors
error TypeError: DuplicateReporterPlugin is not a constructor ↓
cause Incorrect import or usage of DuplicateReporterPlugin as default export without destructuring.
fix
Use const { DuplicateReporterPlugin } = require('duplicate-dependencies-webpack-plugin') or const Plugin = require('duplicate-dependencies-webpack-plugin'); new Plugin()
error Error: Cannot find module 'duplicate-dependencies-webpack-plugin' ↓
cause Plugin not installed.
fix
Run npm install duplicate-dependencies-webpack-plugin --save-dev
Warnings
gotcha Plugin adds overhead for large bundles; may slow down build. ↓
fix Use only in development or CI, not production builds.
deprecated Webpack 4 hooks: compilation.hooks.additionalAssets may be deprecated in future webpack versions. ↓
fix Test with webpack 5; plugin is compatible.
Install
npm install duplicate-dependencies-webpack-plugin yarn add duplicate-dependencies-webpack-plugin pnpm add duplicate-dependencies-webpack-plugin Imports
- DuplicateReporterPlugin wrong
const { DuplicateReporterPlugin } = require('duplicate-dependencies-webpack-plugin')correctimport { DuplicateReporterPlugin } from 'duplicate-dependencies-webpack-plugin' - default import wrong
const DuplicatePlugin = require('duplicate-dependencies-webpack-plugin').defaultcorrectimport DuplicatePlugin from 'duplicate-dependencies-webpack-plugin' - getHooks wrong
DuplicatePlugin.getHooks // do not call statically without compilationcorrectimport DuplicatePlugin from 'duplicate-dependencies-webpack-plugin'; DuplicatePlugin.getHooks(compilation)
Quickstart
const { DuplicateReporterPlugin } = require('duplicate-dependencies-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: { filename: 'bundle.js' },
plugins: [new DuplicateReporterPlugin()]
};