Detect duplicate packaged dependencies
npm install unplugin-detect-duplicated-deps  
Detect duplicate packaged dependencies
``bash`
npm i -D unplugin-detect-duplicated-deps
You can use the jsdoc to check option description and default value.
Vite
`ts
// vite.config.ts
import UnpluginDetectDuplicatedDeps from 'unplugin-detect-duplicated-deps/vite';
export default defineConfig({
plugins: [UnpluginDetectDuplicatedDeps()],
});
`
Rollup
`ts
// rollup.config.js
import UnpluginDetectDuplicatedDeps from 'unplugin-detect-duplicated-deps/rollup';
export default {
plugins: [UnpluginDetectDuplicatedDeps()],
};
`
Webpack
`ts
// webpack.config.mjs
import UnpluginDetectDuplicatedDeps from 'unplugin-detect-duplicated-deps/webpack';
const config = {
plugins: [UnpluginDetectDuplicatedDeps()],
};
`
`ts``
export default defineConfig({
plugins: [
UnpluginDetectDuplicatedDeps({
// will exit build process if duplicated deps found
throwErrorWhenDuplicated: true,
// ignore specific duplicated deps
ignore: {
axios: ['0.27.2'],
vue: ['*'],
},
}),
],
});
Because vite6 plan to deprecate commonjs node api, this plugin deprecate the commonjs support from 1.x. If you want use this plugin in commonjs environment, check 0.x
- duplicate-package-checker-webpack-plugin
- unplugin
- unplugin-starter
- bundlephobia provide the api to get package size
- vercel host documentation
- Rsdoctor | Duplicate Dependency Problem
- Pnpm | How peers are resolved
- 如何解决项目依赖重复打包问题
MIT License © 2023-PRESENT YuTengjing