duplicate-dependencies-webpack-plugin
webpack plugin to find duplicated dependencies from your bundle
Last updated 4 months ago by fengzilong .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install duplicate-dependencies-webpack-plugin 
SYNC missed versions from official npm registry.

duplicate-dependencies-webpack-plugin

npm version npm downloads actions status

A webpack plugin to find all duplicated dependencies in your bundle

snapshot

Installation

For yarn users

yarn add duplicate-dependencies-webpack-plugin --dev

For npm users

npm i duplicate-dependencies-webpack-plugin -D

Basic Usage

webpack.config.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

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:

{
  '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

Current Tags

  • 0.2.0                                ...           latest (4 months ago)

3 Versions

  • 0.2.0                                ...           4 months ago
  • 0.1.1                                ...           4 months ago
  • 0.1.0                                ...           5 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |