mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
## Summary - Adds `--metafile-md` CLI option to `bun build` that generates a markdown visualization of the module graph - Designed to help Claude and other LLMs analyze bundle composition, identify bloat, and understand dependency chains - Reuses existing metafile JSON generation code as a post-processing step ## Features The generated markdown includes: 1. **Quick Summary** - Module counts, sizes, ESM/CJS breakdown, output/input ratio 2. **Largest Input Files** - Sorted by size to identify potential bloat 3. **Entry Point Analysis** - Shows bundle size, exports, CSS bundles, and bundled modules 4. **Dependency Chains** - Most commonly imported modules and reverse dependencies 5. **Full Module Graph** - Complete import/export info for each module 6. **Raw Data for Searching** - Grep-friendly markers in code blocks: - `[MODULE:]`, `[SIZE:]`, `[IMPORT:]`, `[IMPORTED_BY:]` - `[ENTRY:]`, `[EXTERNAL:]`, `[NODE_MODULES:]` ## Usage ```bash # Default filename (meta.md) bun build entry.js --metafile-md --outdir=dist # Custom filename bun build entry.js --metafile-md=analysis.md --outdir=dist # Both JSON and markdown bun build entry.js --metafile=meta.json --metafile-md=meta.md --outdir=dist ``` ## Example Output See sample output: https://gist.github.com/example (will add) ## Test plan - [x] Test default filename (`meta.md`) - [x] Test custom filename - [x] Test both `--metafile` and `--metafile-md` together - [x] Test summary metrics - [x] Test module format info (ESM/CJS) - [x] Test external imports - [x] Test exports list - [x] Test bundled modules table - [x] Test CSS bundle reference - [x] Test import kinds (static, dynamic, require) - [x] Test commonly imported modules - [x] Test largest files sorting (bloat analysis) - [x] Test output/input ratio - [x] Test grep-friendly raw data section - [x] Test entry point markers - [x] Test external import markers - [x] Test node_modules markers All 17 new tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
25 lines
399 B
JSON
25 lines
399 B
JSON
{
|
|
"inputs": {
|
|
"../../tmp/test-entry.js": {
|
|
"bytes": 21,
|
|
"imports": [
|
|
],
|
|
"format": "esm"
|
|
}
|
|
},
|
|
"outputs": {
|
|
"./test-entry.js": {
|
|
"bytes": 49,
|
|
"inputs": {
|
|
"../../tmp/test-entry.js": {
|
|
"bytesInOutput": 22
|
|
}
|
|
},
|
|
"imports": [
|
|
],
|
|
"exports": [],
|
|
"entryPoint": "../../tmp/test-entry.js"
|
|
}
|
|
}
|
|
}
|