Skip to content

Commit 741d095

Browse files
bgwtimneutkens
andauthored
backport(15.3): document turbopack trace viewer (#78184) (#80589)
Backports #78184 (@timneutkens) User request: (https://vercel.slack.com/archives/C06CUNEC64D/p1750069211569019) > could the change from `next internal turbo-trace-server` to `next internal trace` be backported to a non-canary Next.js version? (to align with the published docs suggestion) > > currently, the docs say "You can interpret the file using `next internal trace [path-to-file]`:" ... and then further down "On versions where `trace` is not available, the command was named `turbo-trace-server`" ... which means that anyone on non-canary versions following the docs right now will receive `error: unknown command 'trace'` > > https://nextjs.org/docs/app/guides/local-development#turbopack-tracing The `mdx` change here isn't really relevant, since we don't build docs from this branch, but it merges cleanly, so it's harmless. Co-authored-by: Tim Neutkens <[email protected]>
1 parent f9e98b9 commit 741d095

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

crates/napi/src/next_api/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ pub async fn project_new(
382382
thread::spawn(move || {
383383
turbopack_trace_server::start_turbopack_trace_server(trace_file);
384384
});
385-
println!("Turbopack trace server started. View trace at https://turbo-trace-viewer.vercel.app/");
385+
println!("Turbopack trace server started. View trace at https://trace.nextjs.org");
386386
}
387387

388388
subscriber.init();

docs/01-app/03-building-your-application/06-optimizing/14-local-development.mdx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ module.exports = {
7878
}
7979
```
8080

81+
Turbopack automatically analyzes imports and optimizes them. It does not require this configuration.
82+
8183
### 4. Check your Tailwind CSS setup
8284

8385
If you're using Tailwind CSS, make sure it's set up correctly.
@@ -140,15 +142,36 @@ Use this command to see more detailed information about what's happening during
140142
next dev --verbose
141143
```
142144

143-
## Still having problems?
145+
## Turbopack tracing
144146

145-
If you've tried everything and still have issues:
147+
Turbopack tracing is a tool that helps you understand the performance of your application during local development.
148+
It provides detailed information about the time taken for each module to compile and how they are related.
146149

147-
1. Create a simple version of your app that shows the problem.
148-
2. Generate a special file that shows what's happening:
150+
1. Make sure you have the latest version of Next.js installed.
151+
1. Generate a Turbopack trace file:
149152

150153
```bash
151-
NEXT_CPU_PROF=1 npm run dev
154+
NEXT_TURBOPACK_TRACING=1 npm run dev
152155
```
153156

154-
3. Share this file (found in your project's main folder) and the `.next/trace` file on GitHub as a new issue.
157+
1. Navigate around your application or make edits to files to reproduce the problem.
158+
1. Stop the Next.js development server.
159+
1. A file called `trace-turbopack` will be available in the `.next` folder.
160+
1. You can interpret the file using `next internal trace [path-to-file]`:
161+
162+
```bash
163+
next internal trace .next/trace-turbopack
164+
```
165+
166+
On versions where `trace` is not available, the command was named `turbo-trace-server`:
167+
168+
```bash
169+
next internal turbo-trace-server .next/trace-turbopack
170+
```
171+
172+
1. Once the trace server is running you can view the trace at https://trace.nextjs.org/.
173+
1. By default the trace viewer will aggregate timings, in order to see each individual time you can switch from "Aggregated in order" to "Spans in order" at the top right of the viewer.
174+
175+
## Still having problems?
176+
177+
Share the trace file generated in the [Turbopack Tracing](#turbopack-tracing) section and share it on [GitHub Discussions](https://github.com/vercel/next.js/discussions) or [Discord](https://nextjs.org/discord).

packages/next/src/bin/next.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ const internal = program
421421
)
422422

423423
internal
424-
.command('turbo-trace-server')
424+
.command('trace')
425+
.alias('turbo-trace-server')
425426
.argument('[file]', 'Trace file to serve.')
426427
.action((file: string) => {
427428
return import('../cli/internal/turbo-trace-server.js').then((mod) =>

packages/next/src/build/swc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ function loadNative(importPath?: string) {
12551255
createProject: bindingToApi(customBindings ?? bindings, false),
12561256
startTurbopackTraceServer(traceFilePath) {
12571257
Log.warn(
1258-
'Turbopack trace server started. View trace at https://turbo-trace-viewer.vercel.app/'
1258+
'Turbopack trace server started. View trace at https://trace.nextjs.org'
12591259
)
12601260
;(customBindings ?? bindings).startTurbopackTraceServer(traceFilePath)
12611261
},

0 commit comments

Comments
 (0)