Use graph-backed codegen for client proxies and WASM loaders (#99115)
### What? Generate **both RSC client-reference proxies and WebAssembly loaders** under their graph-backed wrapper module identities, using one shared, higher-level content helper. Remove both generated-path exceptions from `BindingUsageInfo::used_exports` and the earlier proxy-specific export filter. ### Why? The wrapper is the module in Turbopack's graph, but its chunk item previously delegated code generation to a separately processed virtual JS module. Export-usage lookup for that proxy/loader missed the graph and fell back to “all exports used.” In a `sideEffects: false` barrel this could register a pruned client export and request a missing `<locals>` module ID. The WebAssembly loader had the same graph-identity mismatch, hidden by a separate filename-based fallback. Canary's #99102 now guards against the client-reference missing-ID symptom by checking pruned references. This PR fixes the upstream identity mismatch instead so `expand_exports()` sees real usage; #99102's independent safety checks remain in place. ### How? `chunk_item_content_with_code_from(graph_module, code_source, ...)` takes the generated source's analyzed program, references, exports, source map and async behavior while using the wrapper for the *whole code-generation module context*. Both client-reference and WASM wrappers call it. This replaces the public low-level `with_module_context` setter; it does not change module IDs, WASM output assets, React Flight registration, or the existing single-chunk WASM rejection. sokra's `ResolvedVc` suggestions are also applied. #99090's pruned-reexport-source guard remains necessary: removing it independently still fails its execution fixture. #99082 proposed reverting all of #98617 and closed unmerged; it was not a separate fix to delete. The neutral production proxy regression and two supplemental pruned-source execution fixtures remain in the PR. ### Verification - **WASM can-fail/can-pass:** all 3 existing WASM execution fixtures pass before removing the fallback; with the fallback removed but old loader delegation retained, all 3 fail `export usage not found ...wasm_.loader.mjs`; with the shared helper, all 3 pass (instantiation, imported functions/memory, and `?module` compilation). - **Proxy can-fail/can-pass:** without the wrapper-context path and proxy fallback, the production fixture fails `export usage not found .../__nextjs-internal-proxy.mjs`; with the fix it passes. - **Rust/build:** 1,282 tests pass across affected crates; clippy (`-D warnings`), rustfmt and `pnpm build-all` (18/18 tasks) pass. - **Next.js integration:** Turbopack production 6 suites/12 tests (proxy, used client references, #99102 regression, edge WASM and WASM output tracing); development 3 suites/8 tests (proxy, used client references and edge WASM). Client-reference chunking 1/1. After rebasing onto current canary, `pnpm build-all` and focused proxy/edge WASM production tests (3 suites/7 tests) pass again. <!-- NEXT_JS_LLM --> <!-- fleet ecdfa248-cd54-41ac-b4a2-c9d49e2a67ee --> --------- 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> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment