New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

webpack-why-plugin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-why-plugin

webpack-why-plugin -----------------------------------

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
11
-42.11%
Maintainers
1
Weekly downloads
 
Created
Source

webpack-why-plugin

Print out why a particular module is included in webpack bundle. 'webpack-bundle-analyzer' allows you to look at the bundle in detail, but it doesn't tell you why a module is included in the bundle.

Example output:

    warning is bundled because:
      warning <= formik
        : src/my-page.tsx
      warning <= @material-ui/core <= @material-ui/icons
      warning <= jss-nested <= @material-ui/core <= @material-ui/icons
      warning <= jss <= @material-ui/core <= @material-ui/icons
      warning <= jss <= jss-global <= @material-ui/core <= @material-ui/icons
        : src/my-page-2.tsx

Install

First add the module:

# yarn add -D webpack-why-plugin

# npm i --dev webpack-why-plugin

In "webpack.config.js", add these lines:

    import { WebpackWhyPlugin } from "webpack-why-plugin";

    module.exports = async function main(env, arg) {
      let config = {
        entry:{
          // ...
        },
        plugins: [
        ]
        // ...
      }
      if (arg.why) {
        config.plugins.push(new WebpackWhyPlugin({names: arg.why}));
      }
      return config;
    }

Usage examples

From command line, run

# npx webpack --why m3
m3 is bundled because:
  m3 <= m1 <= m2
    : src/page1.tsx
    : src/page2.tsx

The output says the src/page1.tsx and src/page2.tsx imported module "m2", "m2" imported "m1", "m1" imported "m3", thus "m3" is in the bundle.

To explain multiple modules, delaminate by comma:

# npx webpack --why m3,m4

To match module names by regex, surround with //

# npx webpack --why /material/

FAQs

Package last updated on 20 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts