Unverified Commit 47c6cc8d authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Document next analyze export in the package bundling guide (#99735)

## Summary

Document `next analyze export` with a snapshot capture/export example
and a link to its CLI options.

## Verification

- Prettier and ESLint passed.
- Runtime tests not run (docs only).

<!-- NEXT_JS_LLM -->
parent 5b106049
...@@ -193,7 +193,7 @@ After every edit, verify the page still works at runtime using the next-dev-loop ...@@ -193,7 +193,7 @@ After every edit, verify the page still works at runtime using the next-dev-loop
### `next-bundle-optimizer` ### `next-bundle-optimizer`
The [`next-bundle-optimizer`](https://www.skills.sh/vercel/next.js/next-bundle-optimizer) uses Turbopack's bundle analyzer to identify sources of large client-side bundles that impact your site's initial load performance. The [`next-bundle-optimizer`](https://www.skills.sh/vercel/next.js/next-bundle-optimizer) skill uses Turbopack's bundle analyzer to identify sources of large client-side bundles that impact your site's initial load performance.
```bash filename="Terminal" ```bash filename="Terminal"
npx skills add vercel/next.js --skill next-bundle-optimizer npx skills add vercel/next.js --skill next-bundle-optimizer
......
...@@ -96,11 +96,37 @@ This command writes the output to `.next/diagnostics/analyze`. You can copy this ...@@ -96,11 +96,37 @@ This command writes the output to `.next/diagnostics/analyze`. You can copy this
cp -r .next/diagnostics/analyze ./analyze-before-refactor cp -r .next/diagnostics/analyze ./analyze-before-refactor
``` ```
### Export analysis data
Use `next analyze export` to stream a saved snapshot as JSON Lines for scripts or AI tools, without rebuilding or starting a server:
```bash filename="Terminal" package="npm"
npx next analyze --output --snapshot before
npx next analyze export --snapshot before > bundle-graph.jsonl
```
```bash filename="Terminal" package="yarn"
yarn next analyze --output --snapshot before
yarn next analyze export --snapshot before > bundle-graph.jsonl
```
```bash filename="Terminal" package="pnpm"
pnpm next analyze --output --snapshot before
pnpm next analyze export --snapshot before > bundle-graph.jsonl
```
```bash filename="Terminal" package="bun"
bunx next analyze --output --snapshot before
bunx next analyze export --snapshot before > bundle-graph.jsonl
```
See the [CLI reference](/docs/app/api-reference/cli/next#next-analyze-export-options) for export options.
> More options are available for the Bundle Analyzer, see Next.js CLI reference docs for the full list. > More options are available for the Bundle Analyzer, see Next.js CLI reference docs for the full list.
### Give your AI agent access to the bundle analyzer ### Give your AI agent access to the bundle analyzer
The [`next-bundle-optimizer`](https://www.skills.sh/vercel/next.js/next-bundle-optimizer) gives your AI agent access to the data powering Turbopack's bundle analyzer to automatically identify sources of large client-side bundles that impact your site's initial load performance. The [`next-bundle-optimizer`](https://www.skills.sh/vercel/next.js/next-bundle-optimizer) skill gives your AI agent access to the data powering Turbopack's bundle analyzer to automatically identify sources of large client-side bundles that impact your site's initial load performance.
First, install the skill: First, install the skill:
......
...@@ -276,7 +276,7 @@ The following options are available for the `next analyze` command: ...@@ -276,7 +276,7 @@ The following options are available for the `next analyze` command:
### `next analyze export` options ### `next analyze export` options
The `export` subcommand reads a saved snapshot without building or starting the UI server. Place replay options after `export`: `next analyze export --snapshot audit-1` selects saved data; `--snapshot` before `export` is a capture option and is rejected. The `export` subcommand streams an existing snapshot as a series of JSON Lines. It does not run analysis itself or start the web UI.
| Option | Description | | Option | Description |
| ------------------------ | ------------------------------------------------------------------------------------------- | | ------------------------ | ------------------------------------------------------------------------------------------- |
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment