Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/cmd/componentize.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { readFile, writeFile } from 'node:fs/promises';
import { resolve, basename } from 'node:path';
import c from 'chalk-template';
import { readFile, writeFile } from "node:fs/promises";
import { resolve, basename } from "node:path";

export async function componentize (jsSource, opts) {
const { componentize: componentizeFn } = await eval('import("@bytecodealliance/componentize-js")');
if (opts.disable?.includes('all')) {
opts.disable = ['stdio', 'random', 'clocks', 'http'];
import c from "chalk-template";

export async function componentize(jsSource, opts) {
const { componentize: componentizeFn } = await eval(
'import("@bytecodealliance/componentize-js")',
);
if (opts.disable?.includes("all")) {
opts.disable = ["stdio", "random", "clocks", "http"];
}
const source = await readFile(jsSource, 'utf8');
const source = await readFile(jsSource, "utf8");
const { component } = await componentizeFn(source, {
enableAot: opts.aot,
aotMinStackSizeBytes: opts.aotMinStackSizeBytes,
wevalBin: opts.wevalBin,
sourceName: basename(jsSource),
witPath: resolve(opts.wit),
Expand Down
5 changes: 4 additions & 1 deletion src/jco.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env node

import c from 'chalk-template';
import { program, Option } from 'commander';

import { opt } from './cmd/opt.js';
import { transpile, types, guestTypes } from './cmd/transpile.js';
import { run as runCmd, serve as serveCmd } from './cmd/run.js';
import { parse, print, componentNew, componentEmbed, metadataAdd, metadataShow, componentWit } from './cmd/wasm-tools.js';
import { componentize } from './cmd/componentize.js';
import c from 'chalk-template';

program
.name('jco')
Expand Down Expand Up @@ -34,6 +36,7 @@ program.command('componentize')
.requiredOption('-w, --wit <path>', 'WIT path to build with')
.option('-n, --world-name <name>', 'WIT world to build')
.option('--aot', 'Enable Weval AOT compilation of JS')
.option('--aot-min-stack-size-bytes <number>', 'Set the min stack size to be used during AOT')
.option('--weval-bin <path>', 'Specify a custom weval binary to use')
.addOption(new Option('-d, --disable <feature...>', 'disable WASI features').choices(['clocks', 'http', 'random', 'stdio', 'all']))
// .addOption(new Option('-e, --enable <feature...>', 'enable WASI features').choices(['http']))
Expand Down
Loading