@bytecodealliance/jco 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/cmd/componentize.d.ts.map +1 -1
- package/src/cmd/componentize.js +1 -0
- package/src/cmd/opt.d.ts.map +1 -1
- package/src/cmd/opt.js +4 -9
- package/src/cmd/run.js +3 -3
- package/src/cmd/transpile.d.ts.map +1 -1
- package/src/cmd/transpile.js +3 -8
- package/src/jco.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/jco",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "JavaScript tooling for working with WebAssembly Components",
|
|
5
5
|
"author": "Guy Bedford",
|
|
6
6
|
"bin": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@bytecodealliance/componentize-js": "^0.
|
|
28
|
-
"@bytecodealliance/preview2-shim": "^0.16.
|
|
27
|
+
"@bytecodealliance/componentize-js": "^0.12.0",
|
|
28
|
+
"@bytecodealliance/preview2-shim": "^0.16.7",
|
|
29
29
|
"binaryen": "^118.0.0",
|
|
30
30
|
"chalk-template": "^1",
|
|
31
31
|
"commander": "^12",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentize.d.ts","sourceRoot":"","sources":["componentize.js"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"componentize.d.ts","sourceRoot":"","sources":["componentize.js"],"names":[],"mappings":"AAIA,sEAiBC"}
|
package/src/cmd/componentize.js
CHANGED
|
@@ -9,6 +9,7 @@ export async function componentize (jsSource, opts) {
|
|
|
9
9
|
}
|
|
10
10
|
const source = await readFile(jsSource, 'utf8');
|
|
11
11
|
const { component } = await componentizeFn(source, {
|
|
12
|
+
enableAot: opts.aot,
|
|
12
13
|
sourceName: basename(jsSource),
|
|
13
14
|
witPath: resolve(opts.wit),
|
|
14
15
|
worldName: opts.worldName,
|
package/src/cmd/opt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opt.d.ts","sourceRoot":"","sources":["opt.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opt.d.ts","sourceRoot":"","sources":["opt.js"],"names":[],"mappings":"AAQA,gFAoCC;AAED;;;;;GAKG;AACH,kDAJW,UAAU,cAER,OAAO,CAAC;IAAE,SAAS,EAAE,UAAU,CAAC;IAAC,eAAe,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAA,CAAE,CA8E7G"}
|
package/src/cmd/opt.js
CHANGED
|
@@ -6,13 +6,6 @@ import c from 'chalk-template';
|
|
|
6
6
|
import { readFile, sizeStr, fixedDigitDisplay, table, spawnIOTmp, setShowSpinner, getShowSpinner } from '../common.js';
|
|
7
7
|
import ora from '#ora';
|
|
8
8
|
|
|
9
|
-
let WASM_OPT;
|
|
10
|
-
try {
|
|
11
|
-
WASM_OPT = fileURLToPath(new URL('../../node_modules/binaryen/bin/wasm-opt', import.meta.url));
|
|
12
|
-
} catch {
|
|
13
|
-
WASM_OPT = new URL('../../node_modules/binaryen/bin/wasm-opt', import.meta.url);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
export async function opt (componentPath, opts, program) {
|
|
17
10
|
await $init;
|
|
18
11
|
const varIdx = program.parent.rawArgs.indexOf('--');
|
|
@@ -139,9 +132,11 @@ export async function optimizeComponent (componentBytes, opts) {
|
|
|
139
132
|
* @param {Uint8Array} source
|
|
140
133
|
* @returns {Promise<Uint8Array>}
|
|
141
134
|
*/
|
|
142
|
-
async function wasmOpt
|
|
135
|
+
async function wasmOpt(source, args = ['-O1', '--low-memory-unused', '--enable-bulk-memory']) {
|
|
136
|
+
const wasmOptPath = fileURLToPath(import.meta.resolve('binaryen/bin/wasm-opt'));
|
|
137
|
+
|
|
143
138
|
try {
|
|
144
|
-
return await spawnIOTmp(
|
|
139
|
+
return await spawnIOTmp(wasmOptPath, source, [
|
|
145
140
|
...args, '-o'
|
|
146
141
|
]);
|
|
147
142
|
} catch (e) {
|
package/src/cmd/run.js
CHANGED
|
@@ -85,9 +85,9 @@ async function runComponent (componentPath, args, opts, executor) {
|
|
|
85
85
|
|
|
86
86
|
await writeFile(resolve(outDir, 'package.json'), JSON.stringify({ type: 'module' }));
|
|
87
87
|
|
|
88
|
-
let preview2ShimPath
|
|
88
|
+
let preview2ShimPath;
|
|
89
89
|
try {
|
|
90
|
-
preview2ShimPath = fileURLToPath(
|
|
90
|
+
preview2ShimPath = resolve(fileURLToPath(import.meta.resolve('@bytecodealliance/preview2-shim')), '../../../');
|
|
91
91
|
} catch {
|
|
92
92
|
throw c`Unable to locate the {bold @bytecodealliance/preview2-shim} package, make sure it is installed.`;
|
|
93
93
|
}
|
|
@@ -130,4 +130,4 @@ async function runComponent (componentPath, args, opts, executor) {
|
|
|
130
130
|
// empty
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
}
|
|
133
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["transpile.js"],"names":[],"mappings":"AAgBA,8DAGC;AAED;;;;;;;;;;;GAWG;AACH,wCAXW,MAAM,QACN;IACV,IAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC,SAAa,CAAC,EAAE,IAAI,CAAC;IACrB,MAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAY,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;CAC7B,GACS,OAAO,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;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,CAAC,EAAE,IAAI,CAAC;IAClC,OAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACS,OAAO,CAAC;IAAE,KAAK,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE,CAAA;CAAE,CAAC,CAoSnI"}
|
package/src/cmd/transpile.js
CHANGED
|
@@ -102,20 +102,15 @@ export async function transpile (componentPath, opts, program) {
|
|
|
102
102
|
await writeFiles(files, opts.quiet ? false : 'Transpiled JS Component Files');
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
let WASM_2_JS;
|
|
106
|
-
try {
|
|
107
|
-
WASM_2_JS = fileURLToPath(new URL('../../node_modules/binaryen/bin/wasm2js', import.meta.url));
|
|
108
|
-
} catch {
|
|
109
|
-
WASM_2_JS = new URL('../../node_modules/binaryen/bin/wasm2js', import.meta.url);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
105
|
/**
|
|
113
106
|
* @param {Uint8Array} source
|
|
114
107
|
* @returns {Promise<Uint8Array>}
|
|
115
108
|
*/
|
|
116
109
|
async function wasm2Js (source) {
|
|
110
|
+
const wasm2jsPath = fileURLToPath(import.meta.resolve('binaryen/bin/wasm2js'));
|
|
111
|
+
|
|
117
112
|
try {
|
|
118
|
-
return await spawnIOTmp(
|
|
113
|
+
return await spawnIOTmp(wasm2jsPath, source, ['-Oz', '-o']);
|
|
119
114
|
} catch (e) {
|
|
120
115
|
if (e.toString().includes('BasicBlock requested'))
|
|
121
116
|
return wasm2Js(source);
|
package/src/jco.js
CHANGED
|
@@ -11,7 +11,7 @@ program
|
|
|
11
11
|
.name('jco')
|
|
12
12
|
.description(c`{bold jco - WebAssembly JS Component Tools}\n JS Component Transpilation Bindgen & Wasm Tools for JS`)
|
|
13
13
|
.usage('<command> [options]')
|
|
14
|
-
.version('1.
|
|
14
|
+
.version('1.6.0');
|
|
15
15
|
|
|
16
16
|
function myParseInt(value) {
|
|
17
17
|
return parseInt(value, 10);
|
|
@@ -33,6 +33,7 @@ program.command('componentize')
|
|
|
33
33
|
.argument('<js-source>', 'JS source file to build')
|
|
34
34
|
.requiredOption('-w, --wit <path>', 'WIT path to build with')
|
|
35
35
|
.option('-n, --world-name <name>', 'WIT world to build')
|
|
36
|
+
.option('--aot', 'Enable Weval AOT compilation of JS')
|
|
36
37
|
.addOption(new Option('-d, --disable <feature...>', 'disable WASI features').choices(['clocks', 'http', 'random', 'stdio', 'all']))
|
|
37
38
|
// .addOption(new Option('-e, --enable <feature...>', 'enable WASI features').choices(['http']))
|
|
38
39
|
.option('--preview2-adapter <adapter>', 'provide a custom preview2 adapter path')
|