Turbopack: Add Next.js version to "initialize project" trace span#90545
Turbopack: Add Next.js version to "initialize project" trace span#90545
Conversation
Failing test suitesCommit: ca36b00 | About building and testing Next.js
Expand output● Error Overlay version staleness › should show version staleness in runtime error ● Error Overlay version staleness › should show version staleness in render error ● Error Overlay version staleness › should show version staleness in build error
Expand output● app dir client cache with parallel routes › prefetch={true} › should re-use the cache for the full page, only for 5 mins |
Merging this PR will not alter performance
Comparing Footnotes
|
Pass the Next.js version from the TypeScript side through NAPI bindings into the Rust ProjectOptions, and record it as a `version` field on the "initialize project" tracing span.
d1b70ef to
dcfd6e5
Compare
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URL |
Replace all require('next/package.json').version and import { version }
from 'next/package.json' usages with process.env.__NEXT_VERSION, which
is inlined at build time by taskfile-swc.js.
Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Adds the Next.js version as a
versionfield on the Turbopack "initialize project" tracing span. The version is passed from the TypeScript side (process.env.__NEXT_VERSION) through the NAPI bindings into RustProjectOptions, where it is recorded on the span.This makes it easy to correlate trace data with the specific Next.js version that produced it.
Also standardizes all version reads in
packages/next/src/to useprocess.env.__NEXT_VERSION(which is inlined at build time bytaskfile-swc.js) instead ofrequire('next/package.json').versionorimport { version } from 'next/package.json'.Changes
Trace span (commit 1):
crates/next-api/src/project.rs— Addednext_versionfield toProjectOptions; recorded asversionon the"initialize project"spancrates/next-napi-bindings/src/next_api/project.rs— Addednext_versiontoNapiProjectOptionsand wired it through theFromimplcrates/next-build-test/src/main.rs— Addednext_versionto testProjectOptionsinitpackages/next/src/build/swc/generated-native.d.ts— AddednextVersionto the TypeScriptNapiProjectOptionsinterfacepackages/next/src/server/dev/hot-reloader-turbopack.ts,packages/next/src/build/turbopack-build/impl.ts,packages/next/src/build/turbopack-analyze/index.ts— PassnextVersion: process.env.__NEXT_VERSIONwhen creating the Turbopack projecttest/development/basic/next-rs-api.test.ts— AddednextVersionto bothcreateProjectcall sitesConsistent
__NEXT_VERSIONusage (commit 2):packages/next/src/server/dev/hot-reloader-shared-utils.ts—require('next/package.json').version→process.env.__NEXT_VERSIONpackages/next/src/lib/patch-incorrect-lockfile.ts—nextPkgJson.version→process.env.__NEXT_VERSION; narrowed import to onlyoptionalDependenciespackages/next/src/telemetry/events/swc-load-failure.ts—import { version as nextVersion }→process.env.__NEXT_VERSION; narrowed import to onlyoptionalDependenciesTest Plan
cargo check -p next-api,cargo check -p next-build-testpnpm --filter=next types