Skip to content

Commit

Permalink
fix: jco componentize for latest ComponentizeJS (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Aug 4, 2023
1 parent d387500 commit d482af9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/js-component-bindgen/src/transpile_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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([");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/componentize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ')}).`);
Expand Down
1 change: 1 addition & 0 deletions src/jco.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ program.command('componentize')
.argument('<js-source>', 'JS source file to build')
.requiredOption('-w, --wit <path>', 'WIT path to build with')
.option('-n, --world-name <name>', 'WIT world to build')
.option('--enable-stdout', 'Allow console.log to output to stdout')
.requiredOption('-o, --out <out>', 'output component file')
.action(asyncAction(componentize));

Expand Down
2 changes: 1 addition & 1 deletion test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export async function cliTest (fixtures) {
}
});

test.skip('Componentize', async () => {
test('Componentize', async () => {
try {
const { stdout, stderr } = await exec(jcoPath,
'componentize',
Expand Down

0 comments on commit d482af9

Please sign in to comment.