A tool for comparing webpack bundle stats
Перейти к файлу
dependabot[bot] f8a0c6fe5c
chore(deps): bump qs from 6.5.2 to 6.5.3 (#46)
Bumps [qs](https://github.com/ljharb/qs) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.5.2...v6.5.3)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-09 08:51:43 -08:00
.github/workflows fix build 2021-05-07 10:44:58 -07:00
.vscode quick webpack 5 update 2021-05-07 10:40:54 -07:00
public/samples quick webpack 5 update 2021-05-07 10:40:54 -07:00
src Add tooltip for module name (#27) 2021-10-22 10:36:37 -07:00
.gitignore quick webpack 5 update 2021-05-07 10:40:54 -07:00
.npmignore fix: don't publish samples in npm dist 2019-06-29 07:25:48 -07:00
LICENSE feat: add a github link, lazy load graph and dashboard 2019-06-07 10:58:44 -07:00
SECURITY.md Microsoft mandatory file 2022-08-17 14:50:18 +00:00
package-lock.json chore(deps): bump qs from 6.5.2 to 6.5.3 (#46) 2022-12-09 08:51:43 -08:00
package.json 0.1.1 2022-01-21 10:06:32 -08:00
readme.md quick webpack 5 update 2021-05-07 10:40:54 -07:00
screenshot.png docs: add readme, default sample data 2019-06-07 10:35:07 -07:00
tsconfig.json docs: add readme, default sample data 2019-06-07 10:35:07 -07:00
tsconfig.package.json Enable generation of TypeScript typings (#32) 2022-02-12 20:32:06 -08:00
tslint.json wip 2019-06-05 17:56:53 -07:00
webpack.config.js fix build 2021-05-07 10:44:58 -07:00
webpack.production.js feat: not so wip any more 2019-06-05 19:01:00 -07:00

readme.md

@mixer/webpack-bundle-compare

This is a tool that allows you to compare webpack bundle analysis files over time. Check it out here.

Usage

The bundle comparison tool takes URLs of webpack stat outputs and displays them. You can use the JSON output from the webpack-bundle-analyzer, but we also include a plugin here if you don't use that package.

Using the Plugin

First, install the plugin.

npm install --save-dev @mixer/webpack-bundle-compare

Then, add it to your webpack.config.js file.

+const { BundleComparisonPlugin } = require('@mixer/webpack-bundle-compare');

...

   plugins: [
+    new BundleComparisonPlugin()
   ]

By default, this'll output a file named stats.msp.gz in your build output. This is a gzipped msgpack file--for large projects webpack bundle stats can get pretty big and slow down your build, so we try to make it fast. You can configure the output format and filename by passing options to the plugin:

new BundleComparisonPlugin({
  // File to create, relative to the webpack build output path:
  file: 'myStatsFile.msp.gz',
  // Format to output, "msgpack" by default:
  format: 'msgpack' | 'json',
  // Whether to gzip the output, defaults to true:
  gzip: true | false,
})

Once you have this file, you can upload it somewhere such as Azure blob storage, and serve it in the tool. The module exposes a convenient way to get a direct preloaded link in the tool:

const { getComparisonAddress } = require('@mixer/webpack-bundle-compare');
const link = getComparisonAddress([
  'http://example.com/stats1.msp.gz',
  'http://example.com/stats1.msp.gz',
])

console.log('See your comparison at:', link);

Contributing

Architecture

It's a React/Redux app. We pull webpack analysis JSON down from URLs, process them, and output UI. State is driven via Redux, and the parsing and unzipping of the (potentially very large) webpack stat files happen in a webworker. Actions sent in the redux state are mirrored to the webworker, and in turn the webworker and send actions which get fired back to the host application. The work we do atop the stats file is not particularly interesting--an assortment of parsing, walking, and graph generation functions.

Iteration

To develop against the UI:

  1. Create a folder called "public/samples", and place JSON files in there. Or use the ones we already have preloaded.
  2. Set the WBC_FILES environment variable to a comma-delimited list of the filenames you placed in there.
  3. Running the webpack dev server via npm start will now serve the files you have placed in there.