-
-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasm): Add target environment configuration (#1132)
Currently the Wasm rollup plugin emits code that includes calls to require builtin node modules (`fs` and `path`) as well as builtin `fetch` in browser environments. Even though there is an check before the environment specific code is executed, the mere presence of `require` for builtin node modules will cause downstream bundlers like `esbuild` and `webpack` to emit errors when they statically analyze the output. This commit adds in a `targetEnv` that configures what code is emitted to instantiate the Wasm (both inline and separate) - `"auto"` will determine the environment at runtime and invoke the correct methods accordingly - `"auto-inline"` always inlines the Wasm and will decode it according to the environment - `"browser"` omits emitting code that requires node.js builtin modules that may play havoc on downstream bundlers - `"node"` omits emitting code that requires `fetch` "auto" is the default behavior and preserves backwards compatibility.
- Loading branch information
1 parent
e5db668
commit 50b618b
Showing
5 changed files
with
181 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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