Skip to content

fix(@angular/build): include the oxc-parser WASI binding as an optional dependency - #34540

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:build-oxc-wasi-binding
Oct 27, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
clydin:build-oxc-wasi-binding

Conversation

@clydin

@clydin clydin commented Oct 27, 2026

Copy link
Copy Markdown
Member

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.

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

…al 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 angular#34524
@clydin clydin added the target: patch This PR is targeted for the next patch release label Oct 27, 2026
@clydin clydin added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Oct 27, 2026
@clydin
clydin marked this pull request as ready for review October 27, 2026 15:03

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the @oxc-parser/binding-wasm32-wasi package to the optional dependencies in packages/angular/build/package.json. There are no review comments, and I have no feedback to provide.

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 27, 2026
@alan-agius4
alan-agius4 merged commit f25cdbe into angular:main Oct 27, 2026
71 of 72 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants