https://github.com/fengzilong/duplicate-dependencies-webpack-plugin
A webpack plugin to check all duplicated dependencies in your bundle
https://github.com/fengzilong/duplicate-dependencies-webpack-plugin
analyzer bundle duplicate webpack webpack-plugin
Last synced: about 1 year ago
JSON representation
A webpack plugin to check all duplicated dependencies in your bundle
- Host: GitHub
- URL: https://github.com/fengzilong/duplicate-dependencies-webpack-plugin
- Owner: fengzilong
- License: mit
- Created: 2020-01-14T15:21:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T05:43:35.000Z (over 3 years ago)
- Last Synced: 2024-09-19T13:50:04.829Z (almost 2 years ago)
- Topics: analyzer, bundle, duplicate, webpack, webpack-plugin
- Language: JavaScript
- Homepage:
- Size: 901 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# duplicate-dependencies-webpack-plugin



A webpack plugin to find all duplicated dependencies in your bundle

## Installation
For yarn users
```bash
yarn add duplicate-dependencies-webpack-plugin --dev
```
For npm users
```bash
npm i duplicate-dependencies-webpack-plugin -D
```
## Basic Usage
`webpack.config.js`
```js
const { DuplicateReporterPlugin } = require( 'duplicate-dependencies-webpack-plugin' )
module.exports = {
plugins: {
new DuplicateReporterPlugin()
}
}
```
## Advanced Usage
This plugin is designed to be more flexible
So you may want to use it together with a reporter plugin
Internally this plugin expose a hook called `result`
`webpack.config.js`
```js
const DuplicatePlugin = require( 'duplicate-dependencies-webpack-plugin' )
const ID = 'duplicates-reporter'
class DuplicatesReporterPlugin {
apply( compiler ) {
compiler.hooks.compilation.tap( ID, compilation => {
DuplicatePlugin.getHooks( compilation ).result
.tap( ID, duplicates => {
// here you get the `duplicates` data
// do whatever you want with this
useCustomPrettyReporter( duplicates )
} )
} )
}
}
module.exports = {
plugins: {
new DuplicatePlugin(),
new DuplicatesReporterPlugin()
}
}
```
duplicates looks like:
```js
{
'package_name': [
{
name: 'package_name',
version: '4.2.2',
root: 'absolute_path_to_package_root',
issuer: 'absolute_path_to_issuer', // the file issue the request
files: [Array], // files in this package which are included in your bundle
bytes: 4000 // bytes contributed by this packages
},
// ...more versions
]
}
```
## License
MIT