bundle-buddy

A tool to identify bundle duplication across splits.

Github星跟踪图

Bundle Buddy

Bundle Buddy is a tool to help you find source code duplication across your javascript chunks/splits. This enables you to fine tune code splitting parameters to reduce bundle invalidation rates as well as improve repeat page load performance \o/.

Example Bundle Buddy UI

Bundle Buddy operates on any source maps, but you must include the source content. It will work for any CSS/JS/TEMPLATES etc. that is mapped.

In webpack this means setting devtool to source-map
https://webpack.js.org/guides/development/#source-maps

webpack users

If you are using webpack, you can also try the bundle-buddy-webpack-plugin. This helps ensure you configure your sourcemaps correctly, and lets you run bundle-buddy directly from a webpack build. You might want to use this if you don't want to use bundle buddy standalone!


How to use?

Build your app, then run directly via npx

npx bundle-buddy my-app/public/*.map

Or you can install into your project and run with npm

npm install -g bundle-buddy

bundle-buddy my-app/public/*.map

Bundle Buddy UI interactions.

When you select a bundle on the left panel, you can then see the bundle breakdown, which shows you the most duplicated source lines across bundles that the currently selected bundle contains.

After clicking on a bundle chunk we will then show you the lines of the source file that are repeated as well as what other bundles contain said source lines.

Acting on the results.

The ideal workflow flow using Bundle Buddy is to first identify what code is most duplicated across the project's bundles, then to utilize a common code bundling techique (https://webpack.js.org/plugins/commons-chunk-plugin/), then to rebuild your site, and then finally to measure again to see your impact.

How does this work?

Bundle Buddy builds up a mapping across every source map of every file and each line in each file that is used. This enables Bundle Buddy to detect common source lines between different project chunks.


Contributing

Working on the front end is simple

cd viz
yarn install
yarn start

Working on the CLI component is also straight forward, you just need to build the front end once first.

pushd viz
yarn install
yarn build
popd
yarn install
yarn start --demo

主要指标

概览
名称与所有者samccone/bundle-buddy
主编程语言TypeScript
编程语言TypeScript (语言数: 5)
平台
许可证Other
所有者活动
创建于2017-06-25 01:15:25
推送于2024-01-09 00:14:27
最后一次提交2019-10-04 19:59:52
发布数4
最新版本名称v0.2.2 (发布于 )
第一版名称v0.1.2 (发布于 2017-07-13 20:55:47)
用户参与
星数2.9k
关注者数22
派生数84
提交数396
已启用问题?
问题数29
打开的问题数10
拉请求数19
打开的拉请求数6
关闭的拉请求数44
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?