Skip to content

Commit

Permalink
fix: resource map being populated after trampoline (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Nov 1, 2024
1 parent d70b4d4 commit 08d7fb8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/js-component-bindgen/src/transpile_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,17 +597,18 @@ impl<'a> Instantiator<'a, '_> {
self.instantiation_global_initializer(init);
}

// Trampolines after initializers so we have static module indices
for (i, trampoline) in self.translation.trampolines.iter() {
self.trampoline(i, trampoline);
}

if self.gen.opts.instantiation.is_some() {
let js_init = mem::take(&mut self.src.js_init);
self.src.js.push_str(&js_init);
}

self.exports(&self.component.exports);

// Trampolines here so we have static module indices, and resource maps populated
// (both imports and exports may still be populting resource map)
for (i, trampoline) in self.translation.trampolines.iter() {
self.trampoline(i, trampoline);
}
}

fn ensure_local_resource_class(&mut self, local_name: String) {
Expand Down Expand Up @@ -1348,8 +1349,8 @@ impl<'a> Instantiator<'a, '_> {
.is_none();

let resource_id = crate::dealias(self.resolve, t);

let resource = self.types[tid].ty;

if let Some(resource_idx) = self.component.defined_resource_index(resource) {
let resource_def = self
.component
Expand Down

0 comments on commit 08d7fb8

Please sign in to comment.