WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a9ea8ea

Browse files
author
Guy Bedford
authored
fix: default import function instantiation (#104)
1 parent 4eed0db commit a9ea8ea

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

crates/js-component-bindgen/src/esm_bindgen.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ impl EsmBindgen {
256256
}
257257
Binding::Local(local_name) => {
258258
if let Some(imports_object) = imports_object {
259-
uwriteln!(output, "{local_name} = {imports_object}.default;");
259+
uwriteln!(
260+
output,
261+
"{local_name} = {imports_object}{}.default;",
262+
maybe_quote_member(specifier)
263+
);
260264
} else {
261265
uwriteln!(output, "{local_name} from '{specifier}';");
262266
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import print from 'print';
2+
import importPoint from 'import-point';
3+
4+
export function run () {
5+
6+
}
7+
8+
export function movePoint (pnt) {
9+
const mapPoint = importPoint(pnt);
10+
print(`x: ${mapPoint.x}, y: ${mapPoint.y}`);
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example:protocol
2+
3+
world my-world {
4+
record point {
5+
x: s32,
6+
y: s32,
7+
}
8+
9+
import print: func(msg: string)
10+
import import-point: func(pnt: point) -> point
11+
12+
export run: func()
13+
export move-point: func(pnt: point) -> point
14+
}
6.77 MB
Binary file not shown.

test/runtime/import-fn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Flags: --instantiation

update-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ done
1414

1515
# copy flavorful wit case
1616
cp tests/runtime/flavorful/world.wit ../test/fixtures/wit/flavorful.wit
17+
18+
./src/jco.js componentize test/fixtures/component-gen/import-fn.js --wit test/fixtures/component-gen/import-fn.wit -o test/fixtures/components/import-fn.component.wasm

0 commit comments

Comments
 (0)