webpack-bundle-diff-add-reasons
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

webpack-bundle-diff-add-reasons

npm, github

A utility to add reasons to the bundle graph produced by webpack-bundle-diff (npm, github)

When webpack-bundle-diff adds children to the depgraph, it moves hoisted modules into their hoisted parent. This is fine for tracking the graph of modules in the bundle, but it makes tracking exaclty how a given file ends up inside the graph a little difficult.

This module adds reasons back to the bundleGraph output. This may be be preferrable to analyzing stats.json directly when it is too large to be processed by most tools that depend on stats.json. (e.g. it is multiple gigabytes)

Usage

yarn add webpack-bundle-diff-add-reasons

const getModuleGraphWithChildren = require('webpack-bundle-diff-add-reasons')
    .getModuleGraphWithChildren;
const deriveBundleData = require('webpack-bundle-diff').deriveBundleData;

// Get your bundle stats somehow
const webpackStats = require('fs').readFileSync('./stats.json', 'utf-8');

// Derive webpack-bundle-diff data
const data = deriveBundleData(webpackStats);

// Add reasons to the graph
const graphWithReasons = getModuleGraphWithReasons(
    data.bundleData.graph,
    webpackStats,
);

Development

yarn # install dependencies
yarn build # build.             Can also use `rollup -c`
yarn watch # build with watch.  Can also use `rollup -cw`
yarn jest # run tests
npm publish

Readme

Keywords

none

Package Sidebar

Install

npm i webpack-bundle-diff-add-reasons

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

15 kB

Total Files

7

Last publish

Collaborators

  • adjective