MCPcopy Index your code
hub / github.com/samccone/bundle-buddy

github.com/samccone/bundle-buddy @v0.2.2 sqlite

repository ↗ · DeepWiki ↗ · release v0.2.2 ↗
84 symbols 203 edges 21 files 0 documented · 0%
README

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

Extension points exported contracts — how you extend this code

SourceFileLineInfo (Interface)
(no doc)
types.ts
InUseColumns (Interface)
(no doc)
types.ts
InUseLine (Interface)
(no doc)
types.ts
SourceTrack (Interface)
(no doc)
types.ts
Node (Interface)
(no doc)
types.ts

Core symbols most depended-on inside this repo

hashBundlesToKey
called by 5
utils.ts
stripHashes
called by 5
viz/src/util.js
error
called by 4
utils.ts
updateRoute
called by 4
viz/src/AppState.js
info
called by 3
utils.ts
deferWork
called by 3
viz/src/util.js
createAnnotations
called by 3
viz/src/BottomPanel.js
createId
called by 3
viz/src/NetworkZoom.js

Shape

Function 45
Method 18
Class 14
Interface 7

Languages

TypeScript100%

Modules by API surface

utils.ts13 symbols
viz/src/BottomPanel.js11 symbols
viz/src/NetworkZoom.js10 symbols
viz/src/AppState.js9 symbols
viz/src/NetworkAnalysis.js8 symbols
types.ts7 symbols
viz/src/util.js6 symbols
viz/src/registerServiceWorker.js4 symbols
viz/src/App.js4 symbols
process.ts4 symbols
graph_builder.ts3 symbols
viz/src/Overview.js2 symbols

Dependencies from manifests, versioned

@types/chalk0.4.31 · 1×
@types/express4.17.1 · 1×
@types/globby0.6.0 · 1×
@types/meow3.6.2 · 1×
@types/node8.0.2 · 1×
@types/opn3.0.28 · 1×
@types/source-map0.5.0 · 1×
chalk2.0.1 · 1×
d3-array1.2.0 · 1×
d3-collection1.0.4 · 1×
d3-force1.0.6 · 1×
d3-scale1.0.6 · 1×

For agents

$ claude mcp add bundle-buddy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact