{"id":19452,"library":"duplicate-dependencies-webpack-plugin","title":"Duplicate Dependencies Webpack Plugin","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/fengzilong/duplicate-dependencies-webpack-plugin","tags":["javascript","webpack","plugin"],"install":[{"cmd":"npm install duplicate-dependencies-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add duplicate-dependencies-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add duplicate-dependencies-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export; use destructured import or require. ESM and CJS both supported.","wrong":"const { DuplicateReporterPlugin } = require('duplicate-dependencies-webpack-plugin')","symbol":"DuplicateReporterPlugin","correct":"import { DuplicateReporterPlugin } from 'duplicate-dependencies-webpack-plugin'"},{"note":"Default export is the plugin constructor; in CJS, require returns the same as default export.","wrong":"const DuplicatePlugin = require('duplicate-dependencies-webpack-plugin').default","symbol":"default import","correct":"import DuplicatePlugin from 'duplicate-dependencies-webpack-plugin'"},{"note":"getHooks is a static method on the plugin class, requires compilation object from webpack.","wrong":"DuplicatePlugin.getHooks // do not call statically without compilation","symbol":"getHooks","correct":"import DuplicatePlugin from 'duplicate-dependencies-webpack-plugin'; DuplicatePlugin.getHooks(compilation)"}],"quickstart":{"code":"const { DuplicateReporterPlugin } = require('duplicate-dependencies-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: { filename: 'bundle.js' },\n  plugins: [new DuplicateReporterPlugin()]\n};","lang":"javascript","description":"Minimal webpack config adding DuplicateReporterPlugin to detect duplicate dependencies in output."},"warnings":[{"fix":"Use only in development or CI, not production builds.","message":"Plugin adds overhead for large bundles; may slow down build.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Test with webpack 5; plugin is compatible.","message":"Webpack 4 hooks: compilation.hooks.additionalAssets may be deprecated in future webpack versions.","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":"Use const { DuplicateReporterPlugin } = require('duplicate-dependencies-webpack-plugin') or const Plugin = require('duplicate-dependencies-webpack-plugin'); new Plugin()","cause":"Incorrect import or usage of DuplicateReporterPlugin as default export without destructuring.","error":"TypeError: DuplicateReporterPlugin is not a constructor"},{"fix":"Run npm install duplicate-dependencies-webpack-plugin --save-dev","cause":"Plugin not installed.","error":"Error: Cannot find module 'duplicate-dependencies-webpack-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}