From c49f02082766e1f4f79e5ba6fd52da43bb90cdcd Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Fri, 4 Aug 2023 11:37:28 -0700 Subject: [PATCH 1/2] fix: jco componentize for latest ComponentizeJS --- crates/js-component-bindgen/src/transpile_bindgen.rs | 2 +- package.json | 2 +- src/cmd/componentize.js | 3 ++- src/jco.js | 1 + test/cli.js | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/js-component-bindgen/src/transpile_bindgen.rs b/crates/js-component-bindgen/src/transpile_bindgen.rs index 16a26c4ce..cf7501edf 100644 --- a/crates/js-component-bindgen/src/transpile_bindgen.rs +++ b/crates/js-component-bindgen/src/transpile_bindgen.rs @@ -306,7 +306,7 @@ impl Instantiator<'_, '_> { // To avoid uncaught promise rejection errors, we attach an intermediate // Promise.all with a rejection handler, if there are multiple promises. for i in 0..self.component.num_runtime_component_instances { - uwriteln!(self.src.js_init, "const instance_flags{i} = new WebAssembly.Global({{value: \"i32\", mutable: true}}, {})", wasmtime_environ::component::FLAG_MAY_LEAVE | wasmtime_environ::component::FLAG_MAY_ENTER); + uwriteln!(self.src.js_init, "const instanceFlags{i} = new WebAssembly.Global({{ value: \"i32\", mutable: true }}, {});", wasmtime_environ::component::FLAG_MAY_LEAVE | wasmtime_environ::component::FLAG_MAY_ENTER); } if self.modules.len() > 1 { self.src.js_init.push_str("Promise.all(["); diff --git a/package.json b/package.json index 544f069aa..c4d114f0f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "terser": "^5.16.1" }, "devDependencies": { - "@bytecodealliance/componentize-js": "^0.1.0", + "@bytecodealliance/componentize-js": "^0.1.1", "@types/node": "^18.11.17", "@typescript-eslint/eslint-plugin": "^5.41.0", "@typescript-eslint/parser": "^5.41.0", diff --git a/src/cmd/componentize.js b/src/cmd/componentize.js index 54f4ba250..038fd6ec1 100644 --- a/src/cmd/componentize.js +++ b/src/cmd/componentize.js @@ -14,7 +14,8 @@ export async function componentize (jsSource, opts) { const source = await readFile(jsSource, 'utf8'); const { component, imports } = await componentizeFn(source, { witPath: resolve(opts.wit), - worldName: opts.worldName + worldName: opts.worldName, + enableStdout: opts.enableStdout, }); await writeFile(opts.out, component); console.log(c`{green OK} Successfully written {bold ${opts.out}} with imports (${imports.join(', ')}).`); diff --git a/src/jco.js b/src/jco.js index 9fd1902f4..aabcaab5f 100755 --- a/src/jco.js +++ b/src/jco.js @@ -22,6 +22,7 @@ program.command('componentize') .argument('', 'JS source file to build') .requiredOption('-w, --wit ', 'WIT path to build with') .option('-n, --world-name ', 'WIT world to build') + .option('-enable-stdout', 'Allow console.log to output to stdout') .requiredOption('-o, --out ', 'output component file') .action(asyncAction(componentize)); diff --git a/test/cli.js b/test/cli.js index 1992138de..2ecfba1e4 100644 --- a/test/cli.js +++ b/test/cli.js @@ -181,7 +181,7 @@ export async function cliTest (fixtures) { } }); - test.skip('Componentize', async () => { + test('Componentize', async () => { try { const { stdout, stderr } = await exec(jcoPath, 'componentize', From b59999b72065db50db9c83d0a780a7f0f987d693 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Fri, 4 Aug 2023 11:41:18 -0700 Subject: [PATCH 2/2] fixup flag --- src/jco.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jco.js b/src/jco.js index aabcaab5f..ae6936fbc 100755 --- a/src/jco.js +++ b/src/jco.js @@ -22,7 +22,7 @@ program.command('componentize') .argument('', 'JS source file to build') .requiredOption('-w, --wit ', 'WIT path to build with') .option('-n, --world-name ', 'WIT world to build') - .option('-enable-stdout', 'Allow console.log to output to stdout') + .option('--enable-stdout', 'Allow console.log to output to stdout') .requiredOption('-o, --out ', 'output component file') .action(asyncAction(componentize));