Skip to content

Commit

Permalink
Fix definedResourceTables ReferenceError with instantiation mode (#456)
Browse files Browse the repository at this point in the history
The `js_instrinsics` should be defined under the `instantiate` function.
Otherwise we get the following error:

```
dist/component/ruby.component.js:73
  if (definedResourceTables[toTid]) return rep;
  ^

ReferenceError: definedResourceTables is not defined
```
  • Loading branch information
kateinoigakukun authored Jun 28, 2024
1 parent 2f1e4d8 commit 47073c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/js-component-bindgen/src/transpile_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ impl<'a> JsBindgen<'a> {
uwrite!(
output,
"\
{}
export function instantiate(getCoreModule, imports, instantiateCore = {}) {{
{}
{}
{}
",
&js_intrinsics as &str,
match instantiation {
InstantiationMode::Async => "WebAssembly.instantiate",
InstantiationMode::Sync =>
"(module, importObject) => new WebAssembly.Instance(module, importObject)",
},
&js_intrinsics as &str,
&intrinsic_definitions as &str,
&compilation_promises as &str,
);
Expand Down

0 comments on commit 47073c8

Please sign in to comment.