Registry / devops / duplicate-package-checker-webpack-plugin

duplicate-package-checker-webpack-plugin

JSON →
library3.0.0jsnpmunverified

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.

npm install duplicate-package-checker-webpack-plugin
INSTALL
IMPORT
SIG · DUPLICATE-PACKAGE-
D
duplicate-package-checker-webpack-plugin
devopsjavascriptv3.0.0
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.

DuplicatePackageCheckerPlugin
import DuplicatePackageCheckerPlugin from 'duplicate-package-checker-webpack-plugin';
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
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.

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.

const path = require('path'); const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin'); module.exports = { mode: 'development', entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, plugins: [ new DuplicatePackageCheckerPlugin({ // Emit errors instead of warnings (default: false) emitError: false, // Show help message if duplicate packages are found (default: true) showHelp: true, // Warn also if major versions differ (default: true) strict: true, // Do not warn if same version is duplicated (default: true) // Set to `false` to also catch duplicates of the exact same version ignoreSameVersionDuplicates: true, // Exclude instances of packages from the results exclude: (instance) => instance.name === 'lodash', }) ], // Example of how to resolve duplicates using alias resolve: { alias: { // This aliases all 'lodash' imports to a single specific path // Use with caution when dealing with different major versions 'lodash': path.resolve(__dirname, 'node_modules/lodash') } } };
Debug
Known issues
breakingSetting 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.
fix
Review your `duplicate-package-checker-webpack-plugin` configuration. If you prefer warnings over build failures, set `emitError: false`.
affects: >=1.0.0
gotchaUsing `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.
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.
affects: >=1.0.0
gotchaThe `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.
fix
To detect and warn about duplicates of identical package versions, explicitly set `ignoreSameVersionDuplicates: false` in the plugin configuration.
affects: >=1.0.0
gotchaThe 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.
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.
affects: >=3.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'some-package'
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.
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.
TypeError: someFunction is not a function
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.
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.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
webpackrequiredThis is a Webpack plugin and requires Webpack as a peer dependency to function.
Agent activity
2 hits · last 30 days
node
2
Resources
duplicate-package-checker-webpack-plugin — npm install duplicate-package-checker-webpack-plugin · libregistry