next.js
3dc93da2 - Improve tree shaking through Next.js module wrappers (#98638)

Commit
41 days ago
Improve tree shaking through Next.js module wrappers (#98638) ## What? Extends the export-usage passthrough introduced by #98621 to the transparent wrappers used for dynamic entries, server components, and shared server utilities. The existing reference-tree-shaking production fixture now covers each wrapper and verifies that unused sibling exports do not remain in Turbopack's server chunks. ## Why? These wrappers forward another module's export surface, but previously marked every target export as used. That kept otherwise unreachable modules in production output and limited inner-graph tree shaking. ## How? The dynamic-entry and server-component wrappers now pass their own resolved export usage to their targets. The custom server-utility reference reports the same passthrough binding usage while preserving its shared chunking and merge behavior. A public Turbopack constructor creates passthrough export-usage values for references outside `turbopack-core`, consistent with the existing constructors for other usage modes. ## Verification - `cargo check -p next-core` - `pnpm build-all` - `pnpm test-start-turbo test/production/app-dir/reference-tree-shaking/reference-tree-shaking.test.ts` - `pnpm test-start-webpack test/production/app-dir/reference-tree-shaking/reference-tree-shaking.test.ts` <!-- NEXT_JS_LLM --> <!-- fleet df1472be-5cd1-4bd6-9fab-4efc1defa4f9 --> Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Author
Parents
Loading