feat(next-napi-bindings): build Turbopack for wasm (#97586)
### What? Builds Turbopack for wasm, so the wasm fallback can support Turbopack and not just SWC. ### Why? `next-napi-bindings` gated every Turbopack dependency behind `cfg(not(target_arch = "wasm32"))`, so the wasm fallback shipped SWC only. That is the reason issues like #96960 have no answer today: when the native binding cannot load there is no Turbopack at all. ### How? Moves the Turbopack dependencies into the shared dependency block, leaving genuinely native-only crates gated: - `lightningcss` / `turbopack-lightningcss-napi` and `swc_ecma_react_compiler` back the `css` and `react_compiler` modules; - `swc_plugin_backend_wasmtime` cannot run inside wasm; - SWC's plugin-host features, gated in the previous layer; - `tokio`'s `full` feature pulls in `process` and `signal`, which do not exist on wasi, so the wasi build gets its own `tokio`. This is the layer at which `swc` first gets compiled for wasm, which is why the plugin-host gating has to land **before** it: with that in place, `cargo check -p next-napi-bindings --target wasm32-wasip1-threads` passes here with no `[patch.crates-io]` override. ### What this does *not* do It makes Turbopack **compile** for wasm. It does not make it run: still outstanding are the `env.read_custom_section` loader hook, a wasm `module_init` for the tokio runtime and panic hook, a host-provided fetch, the persistent cache (WASI preview1 has no file-backed mmap or flock), and file watching. Shipping is separately blocked on the unreleased emnapi v2. `turbo-tasks-malloc`'s `custom_allocator` feature also stays off, so there is no per-thread allocation accounting on wasm and memory figures are absent from traces — an observability gap, not a correctness one. <!-- fleet b6d0486f-97c7-42a7-bdaf-3490774cdec3 --> 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>
Showing
Please
register
or
sign in
to comment