Skip to content

Commit 519256f

Browse files
committed
show imports example in readme, note Jco CLI
1 parent 5a78736 commit 519256f

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,43 @@ import { componentize } from '@bytecodealliance/componentize-js';
7878
import { writeFile } from 'node:fs/promises';
7979

8080
const { component } = await componentize(`
81-
export function hello (name) {
82-
return \`Hello \${name}\`;
81+
import { log } from 'local:hello/logger';
82+
83+
export function sayHello (name) {
84+
log(`Hello ${name}`);
8385
}
86+
8487
`, `
8588
package local:hello;
89+
interface logger {
90+
log: func(msg: string);
91+
}
8692
world hello {
87-
export hello: func(name: string) -> string;
93+
import logger;
94+
export say-hello: func(name: string);
8895
}
8996
`);
9097

9198
await writeFile('test.component.wasm', component);
9299
```
93100

94-
The component iself can be executed in any component runtime, see the [example](EXAMPLE.md) for a full workflow.
101+
The component iself can be executed in any component runtime, see the [example](EXAMPLE.md) for an end to end workflow in Wasmtime.
102+
103+
### CLI
104+
105+
ComponentizeJS can be used as a CLI from `jco`:
106+
107+
```
108+
npm install -g @bytecodealliance/jco @bytecodealliance/componentize-js
109+
```
110+
111+
For example:
112+
113+
```sh
114+
jco componentize source.js --wit wit -o component.wasm
115+
```
116+
117+
See `jco componentize --help` for more details.
95118

96119
## Features
97120

0 commit comments

Comments
 (0)