mcpField
A
analyze-bundle

analyze-bundle

github.com/vercel-labsDevelopment1.6k215 installsUpdated 2d ago
Repository

About analyze-bundle

analyze-bundle is a workflow for converting Next.js bundle analyzer `.data` files into NDJSON that can be searched with grep and jq. It provides route, source, output-file, and module dependency data for prioritizing bundle analysis.

Key features

  1. 01Convert analyzer data to NDJSON
  2. 02Inspect route-level summaries
  3. 03Find large sources and output files
  4. 04Explore module dependency edges

Use cases

  1. 01Prioritize routes for bundle optimization
  2. 02Locate large client-side JavaScript sources
  3. 03Trace dependencies between modules

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/vercel-labs/dev3000 --skill analyze-bundle

After installing, type/analyze-bundlein Claude Code to confirm it loaded.

Details

From the project README

analyze-to-ndjson

Converts Next.js bundle analyzer binary .data files into grep/jq-friendly NDJSON.

Analyze artifacts

This workflow pre-generates analyzer artifacts in:

  • .next/diagnostics/analyze/ndjson/routes.ndjson
  • .next/diagnostics/analyze/ndjson/sources.ndjson
  • .next/diagnostics/analyze/ndjson/output_files.ndjson
  • .next/diagnostics/analyze/ndjson/module_edges.ndjson
  • .next/diagnostics/analyze/ndjson/modules.ndjson

Focus on reading these files and using their evidence to prioritize changes.

Output files

FileWhat's in it
modules.ndjsonGlobal module registry (id, ident, path)
module_edges.ndjsonModule dependency graph (from, to, kind: sync/async)
sources.ndjsonPer-route source tree with sizes and environment flags
chunk_parts.ndjsonGranular size data: one line per (source, output_file) pair
output_files.ndjsonPer-route output files with aggregated sizes
routes.ndjsonRoute-level summaries

Browsing the output

Route overview
jq -s 'sort_by(-.total_compressed_size)' .next/diagnostics/analyze/ndjson/routes.ndjson
Find large sources
jq -s '
  group_by(.full_path)
  | map(max_by(.compressed_size))
  | sort_by(-.compressed_size)
  | .[0:10]
  | .[] | {full_path, compressed_size, size, route}
' .next/diagnostics/analyze/ndjson/sources.ndjson
Client-side JS
grep '"client":true' .next/diagnostics/analyze/ndjson/sources.ndjson \
  | grep '"js":true' \
  | jq -s 'sort_by(-.compressed_size) | .[0:10] | .[] | {full_path, compressed_size}'
Module dependencies
grep '"from":42,' .next/diagnostics/analyze/ndjson/module_edges.ndjson | jq .to
grep '"to":42,' .next/diagnostics/analyze/ndjson/module_edges.ndjson | jq .from
grep 'react-dom' .next/diagnostics/analyze/ndjson/modules.ndjson | jq '{id, path}'
Output files for a route
grep '"route":"/"' .next/diagnostics/analyze/ndjson/output_files.ndjson \
  | jq -s 'sort_by(-.total_compressed_size) | .[0:10] | .[] | {filename, total_compressed_size, num_parts}'
Directory tree for a route
grep '"route":"/"' .next/diagnostics/analyze/ndjson/sources.ndjson \
  | jq 'select(.parent_id == null)'

Comments

Markdown supported