analyze-bundle
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseanalyze-to-ndjson
analyze-to-ndjson
Converts Next.js bundle analyzer binary files into grep/jq-friendly NDJSON.
.data将Next.js打包分析器的二进制文件转换为支持grep/jq处理的NDJSON格式。
.dataAnalyze 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.
本工作流会预生成以下路径的分析产物:
.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
建议重点读取这些文件,根据其中的信息确定优化优先级。
Output files
输出文件
| File | What's in it |
|---|---|
| Global module registry ( |
| Module dependency graph ( |
| Per-route source tree with sizes and environment flags |
| Granular size data: one line per (source, output_file) pair |
| Per-route output files with aggregated sizes |
| Route-level summaries |
| 文件 | 内容说明 |
|---|---|
| 全局模块注册表(包含 |
| 模块依赖图(包含 |
| 按路由划分的源码树,包含体积信息和环境标识 |
| 细粒度体积数据:每个(源码, 输出文件)对应一行数据 |
| 按路由划分的输出文件,包含汇总体积信息 |
| 路由维度的汇总信息 |
Browsing the output
浏览输出
Route overview
路由概览
bash
jq -s 'sort_by(-.total_compressed_size)' .next/diagnostics/analyze/ndjson/routes.ndjsonbash
jq -s 'sort_by(-.total_compressed_size)' .next/diagnostics/analyze/ndjson/routes.ndjsonFind large sources
查找大体积源码
bash
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.ndjsonbash
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.ndjsonClient-side JS
客户端JS
bash
grep '"client":true' .next/diagnostics/analyze/ndjson/sources.ndjson \
| grep '"js":true' \
| jq -s 'sort_by(-.compressed_size) | .[0:10] | .[] | {full_path, compressed_size}'bash
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
模块依赖
bash
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}'bash
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
单路由输出文件
bash
grep '"route":"/"' .next/diagnostics/analyze/ndjson/output_files.ndjson \
| jq -s 'sort_by(-.total_compressed_size) | .[0:10] | .[] | {filename, total_compressed_size, num_parts}'bash
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
单路由目录树
bash
grep '"route":"/"' .next/diagnostics/analyze/ndjson/sources.ndjson \
| jq 'select(.parent_id == null)'bash
grep '"route":"/"' .next/diagnostics/analyze/ndjson/sources.ndjson \
| jq 'select(.parent_id == null)'