Skip to content

Commit 6298fb8

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular/build): include the oxc-parser WASI binding as an optional dependency
When running inside a WebContainer environment, such as StackBlitz or the angular.dev playground, native Node.js addons cannot be loaded. The `oxc-parser` package only lists its platform-specific native bindings as optional dependencies and does not include the WebAssembly-based `@oxc-parser/binding-wasm32-wasi` binding. As a result, package managers never install the WASI binding and `oxc-parser` falls back to downloading it on demand at runtime by shelling out to `pnpm` inside a temporary directory. This fallback is executed synchronously while the module graph is being evaluated, from within a worker thread, and via a synchronous `require()` of an ES module. Any failure along that path surfaces as a misleading `ERR_REQUIRE_CYCLE_MODULE` error rather than the underlying cause, which breaks `ng serve` and `ng build` entirely. The binding loader generated by napi-rs checks whether the WASI binding is already resolvable from `node_modules` before attempting the on-demand download. Declaring `@oxc-parser/binding-wasm32-wasi` as an optional dependency of `@angular/build` ensures that package managers install it alongside the package up front. This allows `oxc-parser` to load the WASI binding directly in WebContainer environments and avoids the fragile runtime installation path. The version is pinned to match `oxc-parser` exactly, since the loader rejects bindings whose version does not match the version of the main package. The two dependencies must therefore be kept in lockstep when updating. This mirrors the existing approach used for `lmdb`, which is also declared as an optional dependency to avoid hard failures on platforms where it is unavailable. Note that at the time of this change, the currently published WASI bindings for `oxc-parser` depend on an `@napi-rs/wasm-runtime` version range that resolves to a release incompatible with the `@emnapi` alpha runtime those bindings were built against. Until a compatible `oxc-parser` release is available, the pre-installed binding will fail to initialize in the same way the on-demand download does. This change is nonetheless a prerequisite for a durable fix and will take effect once `oxc-parser` is updated to a release with compatible WASI bindings. Related to #34524
1 parent 7f3840c commit 6298fb8

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎packages/angular/build/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"xxhash-wasm": "1.1.0"
4848
},
4949
"optionalDependencies": {
50+
"@oxc-parser/binding-wasm32-wasi": "0.150.0",
5051
"lmdb": "3.5.6"
5152
},
5253
"devDependencies": {

‎pnpm-lock.yaml‎

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)