{"id":13095,"library":"duplicate-package-checker-webpack-plugin","title":"Webpack Duplicate Package Checker Plugin","description":"The `duplicate-package-checker-webpack-plugin` is a Webpack plugin designed to identify and warn developers when their JavaScript bundle contains multiple, redundant versions of the same npm package. This situation often arises in complex projects due to transitive dependencies, leading to unnecessary bundle bloat and potential runtime conflicts or bugs. The plugin operates during the Webpack build process, flagging these duplicates to help maintain optimal bundle size and application stability. The current stable version is `3.0.0`. While it remains a popular tool with significant weekly downloads, its maintenance status is classified as inactive, with no new versions released to npm in the past 12 months, indicating a slow or potentially discontinued release cadence. Its key differentiator is providing clear, actionable warnings and offering explicit resolution strategies like `webpack.resolve.alias` to mitigate the issues caused by duplicate packages.","status":"maintenance","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin","tags":["javascript","webpack","plugin"],"install":[{"cmd":"npm install duplicate-package-checker-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add duplicate-package-checker-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add duplicate-package-checker-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a Webpack plugin and requires Webpack as a peer dependency to function.","package":"webpack","optional":false}],"imports":[{"note":"While the plugin's internal implementation uses CommonJS, it can be imported via both CommonJS `require` and ES Modules `import` in a modern Webpack setup. For clarity and future compatibility, ES Modules syntax is preferred.","wrong":"const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');","symbol":"DuplicatePackageCheckerPlugin","correct":"import DuplicatePackageCheckerPlugin from 'duplicate-package-checker-webpack-plugin';"}],"quickstart":{"code":"const path = require('path');\nconst DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');\n\nmodule.exports = {\n  mode: 'development',\n  entry: './src/index.js',\n  output: {\n    filename: 'bundle.js',\n    path: path.resolve(__dirname, 'dist'),\n  },\n  plugins: [\n    new DuplicatePackageCheckerPlugin({\n      // Emit errors instead of warnings (default: false)\n      emitError: false,\n      // Show help message if duplicate packages are found (default: true)\n      showHelp: true,\n      // Warn also if major versions differ (default: true)\n      strict: true,\n      // Do not warn if same version is duplicated (default: true)\n      // Set to `false` to also catch duplicates of the exact same version\n      ignoreSameVersionDuplicates: true,\n      // Exclude instances of packages from the results\n      exclude: (instance) => instance.name === 'lodash',\n    })\n  ],\n  // Example of how to resolve duplicates using alias\n  resolve: {\n    alias: {\n      // This aliases all 'lodash' imports to a single specific path\n      // Use with caution when dealing with different major versions\n      'lodash': path.resolve(__dirname, 'node_modules/lodash')\n    }\n  }\n};","lang":"javascript","description":"This quickstart demonstrates how to integrate the plugin into a basic Webpack configuration, including common options and an example of using `resolve.alias` to deduplicate a package like Lodash."},"warnings":[{"fix":"Review your `duplicate-package-checker-webpack-plugin` configuration. If you prefer warnings over build failures, set `emitError: false`.","message":"Setting the `emitError` option to `true` will cause your Webpack build to fail if any duplicate packages are detected, treating them as compilation errors rather than warnings. Ensure this behavior is desired for your CI/CD pipeline.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Only use `resolve.alias` for deduplication when you are certain that the aliased versions are fully compatible, or when aliasing different paths to the *same* intended version. Prefer upgrading dependencies or using Yarn's `install --flat` for safer resolution of compatible versions.","message":"Using `webpack.resolve.alias` to force different major versions of the same package to resolve to a single instance can lead to severe runtime bugs or unexpected application behavior if the versions are not API compatible.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"To detect and warn about duplicates of identical package versions, explicitly set `ignoreSameVersionDuplicates: false` in the plugin configuration.","message":"The `ignoreSameVersionDuplicates` option defaults to `true`, meaning the plugin will not warn about multiple instances of the *exact same package version* being present in the bundle. While less critical than major version conflicts, this can still contribute to bundle bloat.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor the plugin's GitHub repository for any updates or community-driven forks. Consider alternatives if you encounter critical bugs or compatibility problems with newer Webpack versions that are not being addressed.","message":"The project is currently in an 'inactive maintenance' state according to Snyk, with no new npm releases in over a year. This indicates potential delays in addressing new Webpack compatibility issues, bugs, or security concerns.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify that the target path in your `resolve.alias` configuration is correct and that the aliased package is properly installed at that location. Ensure all dependency versions are compatible with the aliasing strategy.","cause":"This error can occur if `webpack.resolve.alias` is incorrectly configured or if a package that was meant to be aliased is not correctly installed at the target path, leading Webpack to fail resolution.","error":"Module not found: Error: Can't resolve 'some-package'"},{"fix":"Revert the aggressive deduplication strategy for the problematic package. Identify the conflicting dependencies and either upgrade them to a compatible version range or exclude the specific package from deduplication using the plugin's `exclude` option.","cause":"Such runtime errors can surface after using `webpack.resolve.alias` or other deduplication methods that force incompatible major versions of a dependency to resolve to a single version, leading to API mismatches at runtime.","error":"TypeError: someFunction is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}