Repository navigation
fix(@angular/build): enable oxc WASI fallback in WebContainer environments - #34628
Merged
alan-agius4 merged 4 commits intoNov 2, 2026
Merged
Conversation
…ments In WebContainer environments (such as StackBlitz and angular.dev playground), native Node.js addons cannot run, requiring oxc-parser to fall back to WebAssembly (WASI). However, @oxc-parser/binding-wasm32-wasi@0.156.0 specifies @emnapi/core@2.0.0-alpha.6 while depending on @napi-rs/wasm-runtime@~1.2.6 (which was updated for @emnapi/core@>=2.0.0-beta.2). In wasm-runtime 1.2.6, initWorker is assigned to emnapi_shared.addonModule, which is undefined in alpha.6 (where it was named napiModule), throwing TypeError: Cannot set properties of undefined (setting 'initWorker'). Introducing oxc-wasi-shim aliases addonModule to napiModule on Object.prototype when in WebContainer or when NAPI_RS_FORCE_WASI is enabled, allowing the WASI runtime to initialize successfully. Additionally, remove @oxc-parser/binding-wasm32-wasi from optionalDependencies as oxc-parser's built-in WebContainer fallback downloads and loads it on demand. Fixes angular#34524
There was a problem hiding this comment.
Code Review
This pull request introduces a workaround shim (oxc-wasi-shim.ts) to resolve an upstream compatibility issue with @oxc-parser/binding-wasm32-wasi in WebAssembly environments like WebContainers. The shim is imported in several OXC tools, and a new E2E test is added to verify WASI functionality. Feedback on the changes highlights a potential issue with modifying Object.prototype using a getter-only property, which can cause TypeErrors in strict mode when other code attempts to assign to addonModule. It is recommended to add a setter to allow the property to be safely shadowed.
clydin
approved these changes
Nov 2, 2026
Collaborator
Author
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In WebContainer environments (such as StackBlitz and angular.dev playground), native Node.js addons cannot run, requiring oxc-parser to fall back to WebAssembly (WASI).
However,
@oxc-parser/binding-wasm32-wasi@0.156.0specifies@emnapi/core@2.0.0-alpha.6while depending on@napi-rs/wasm-runtime@~1.2.6(which was updated for@emnapi/core@>=2.0.0-beta.2). In wasm-runtime 1.2.6,initWorkeris assigned toemnapi_shared.addonModule, which is undefined in alpha.6 (where it was namednapiModule), throwingTypeError: Cannot set properties of undefined (setting 'initWorker').This PR introduces
oxc-wasi-shim, which aliasesaddonModuletothis.napiModuleonObject.prototypewhen running in WebContainer or whenNAPI_RS_FORCE_WASIis enabled, allowing the WASI runtime to initialize successfully. In addition,@oxc-parser/binding-wasm32-wasiis removed fromoptionalDependenciessince oxc-parser's built-in WebContainer fallback downloads and loads it on demand.An end-to-end test verifying
ng servewithNAPI_RS_FORCE_WASI=trueis also included.Closes #34623
Fixes #34524