Skip to content

Commit 41ba31f

Browse files
test(jco): add basic test for async imports
1 parent 6796b8c commit 41ba31f

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

crates/js-component-bindgen/src/intrinsics/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl StringIntrinsic {
9090
let utf8EncodedLen = 0;
9191
function utf8Encode(s, realloc, memory) {
9292
if (typeof s !== 'string') \
93-
throw new TypeError('expected a string');
93+
throw new TypeError('expected a string, received [' + typeof s + ']');
9494
if (s.length === 0) {
9595
utf8EncodedLen = 0;
9696
return 1;

packages/jco/test/helpers.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ export async function setupAsyncTest(args) {
284284
const esModuleSourcePathURL = pathToFileURL(esModuleOutputPath);
285285
const esModule = await import(esModuleSourcePathURL);
286286

287-
console.log('MODULE PATH?', esModuleOutputPath);
288-
289287
// Optionally instantiate the ES module
290288
//
291289
// It's useful to be able to skip instantiation of the instantiation should happen

packages/jco/test/p3/async.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,19 @@ suite('Async (WASI P3)', () => {
6262
),
6363
imports: {
6464
...new WASIShim().getImportObject(),
65-
loadString: async () => "loaded",
66-
loadU32: async () => 43,
65+
'[async]load-string': { default: async () => "loaded" },
66+
'[async]load-u32': { default: async () => 43 },
6767
},
6868
},
6969
jco: {
7070
transpile: {
7171
extraArgs: {
7272
minify: false,
73+
asyncMode: 'jspi',
74+
asyncImports: [
75+
'[async]load-string',
76+
'[async]load-u32',
77+
]
7378
}
7479
}
7580
}

0 commit comments

Comments
 (0)