[turbopack] fix feature usage telemetry#93100
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
80f135b to
905545d
Compare
15d32a7 to
4d7c6d1
Compare
Merging this PR will degrade performance by 3.4%
Performance Changes
Comparing Footnotes
|
905545d to
e550aff
Compare
4d7c6d1 to
06b101f
Compare
There was a problem hiding this comment.
Additional Suggestion:
Test file next-rs-api.test.ts references .diagnostics on TurbopackResult objects, but diagnostics was removed from TurbopackResult in commit 06b101f, causing all diagnostics assertions to fail at runtime (accessing undefined).
e550aff to
157d145
Compare
06b101f to
f6f1f87
Compare
157d145 to
f579205
Compare
f6f1f87 to
9c08867
Compare
Tests PassedCommit: edc1992 |
6d0776f to
ab525f2
Compare
19ba862 to
b45210d
Compare
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URLCommit: b3f4b1f |
ab525f2 to
709bbbe
Compare
b45210d to
f0c1ffc
Compare
709bbbe to
b3f4b1f
Compare
b3f4b1f to
edc1992
Compare
Merge activity
|

Report Turbopack feature-usage telemetry
Turbopack never reported
NEXT_BUILD_FEATURE_USAGEtelemetry for production builds. This PR wires it up and fixes a correctness bug in how the counts were computed, then cleans up the API surface that carried them across the napi boundary.Changes
turbopackBuild()now recordsEVENT_BUILD_FEATURE_USAGEevents afterwriteAllEntrypointsToDiskvia a neweventBuildFeatureUsageFromTurbopackDiagnosticshelper. Dev is out of scope — webpack'sTelemetryPluginis!dev && isClienttoo.EventBuildFeatureUsage['featureName']union — SWC triple is nowswc/target/<triple>; droppedpersistentCaching(redundant withturbopackFileSystemCache) andturbotrace: false(hardcoded).Correctness fix: count unique importers, not resolves
Previously feature-usage counts for module imports (
next/image,next/font/google, …) were computed from aBeforeResolvePluginthat emitted one event per resolve. Turbopack caches resolves, so the emission fired at most once per unique request — the count was effectively1for every feature that was imported anywhere. Webpack's equivalent counts unique importing modules viamoduleGraph.getIncomingConnections(module).size.This PR replaces the resolve-plugin emission with a single whole-app module-graph traversal on
Project. For each tracked feature, we accumulate the set of unique parent modules of each matching node (mirroring webpack's "unique origin modules" semantics). Fonts are matched against their synthesized/target.css?…virtual modules produced by the SWC font-loader transform — matching webpack'sFEATURE_MODULE_REGEXP_MAPapproach. Paths are matched viaphf_map!tables innext_telemetry.rs.Incidental simplifications
While in here, the
Diagnosticcollectibles subsystem got right-sized and then removed entirely, since feature usage was its only consumer:Project::project_feature_usage()returns a structuredVc<ProjectFeatureUsageSummary>instead of emitting diagnostics. Surfaced to JS as a dedicatedproject.featureUsage(): Promise<BuildFeatureUsage[]>napi method, called once at build's end.TurbopackResult<T>loses itsdiagnostics: BuildFeatureUsage[]field — it's now just{ result, issues }. Every napi result type and ~10 construction sites are correspondingly simpler.turbopack_core::diagnosticsentirely (Diagnostictrait,DiagnosticExt,DiagnosticContextExt,CapturedDiagnostics,PlainBuildFeatureUsage). DeletedFeatureUsageTelemetry,ModuleFeatureReportResolvePlugin,get_diagnostics()aggregation, thefeature_usage/diagnosticsfields onAllWrittenEntrypointsWithIssues/OperationResult/EntrypointsWithIssues/WrittenEndpointWithIssues/HmrUpdateWithIssues/HmrChunkNamesWithIssues/EndpointIssuesAndDiags/WriteAnalyzeResult, and the defensivedrop_collectibles::<Box<dyn Diagnostic>>()scrub inentrypoints_without_collectibles_operation.Feature-usage telemetry now flows as a plain return value end-to-end:
Project::project_feature_usage()→ napiprojectFeatureUsage()→ JSproject.featureUsage()→telemetry.record(). No collectibles, no peeking, no emission-as-side-effect.Tests
Un-skipped four previously webpack-only integration tests in
test/integration/telemetry/test/config.test.ts:image/script/dynamic,next/legacy/image,transpilePackages, and middleware options. All pass under Turbopack. The remaining three skipped tests (swcflags,@vercel/og,useCache) cover features Turbopack doesn't emit yet — left skipped with TODOs.Added unit test for the helper at
packages/next/src/telemetry/events/build.test.ts. Updated the Turbopacknext-rs-apisnapshot to reflect the new diagnostic shape.