Skip to content

Commit f22e230

Browse files
author
Guy Bedford
authored
gen-host-js: instance ESM output by default (#406)
* gen-host-js: instance ESM output by default Outputs a direct ES module from the JS host generator by default that can be directly imported in JS environments. For the custom instantiation API that was the previous output, a new `--instantiation` flag is provided. Instance-level customization flags are also added including: * `--compat`: Enables compatibility mode, based on the assumption that a new --tla-compat flag will be added in a future PR. * `--nodejs-compat`: Handle Node.js instantiation when no fetch global is present The above flags are only compatible with instance output and will throw otherwise. This PR also parallelizes the core Wasm instantiations, and converts the instantiation API from `instantiateCore(path, imports)` to `compileCore(path)` to enable this parallelization. In addition a new `--map` is added with support for custom import specifier mappings that can apply to both output modes.
1 parent 0234aa2 commit f22e230

24 files changed

Lines changed: 504 additions & 221 deletions

File tree

Cargo.lock

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

crates/gen-host-js/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
},
77
"extends": "eslint:recommended",
88
"parserOptions": {
9-
"ecmaVersion": 12,
9+
"ecmaVersion": 13,
1010
"sourceType": "module"
1111
},
1212
"rules": {

crates/gen-host-js/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ test = false
1010

1111
[dependencies]
1212
wit-bindgen-core = { workspace = true, features = ['component-generator'] }
13+
anyhow = { workspace = true }
1314
heck = { workspace = true }
1415
clap = { workspace = true, optional = true }
1516
wasmtime-environ = { workspace = true, features = ['component-model'] }

crates/gen-host-js/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"devDependencies": {
33
"@types/node": "^15.12.2",
4-
"@typescript-eslint/eslint-plugin": "^4.27.0",
5-
"@typescript-eslint/parser": "^4.27.0",
6-
"eslint": "^7.28.0",
4+
"@typescript-eslint/eslint-plugin": "^5.41.0",
5+
"@typescript-eslint/parser": "^5.41.0",
6+
"eslint": "^8.26.0",
77
"typescript": "^4.3.2"
88
}
99
}

0 commit comments

Comments
 (0)