Socket
Book a DemoSign in
Socket

@bytecodealliance/componentize-js

Package Overview
Dependencies
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bytecodealliance/componentize-js - npm Package Compare versions

Comparing version
0.18.5
to
0.19.0
+3
-8
package.json
{
"name": "@bytecodealliance/componentize-js",
"version": "0.18.5",
"version": "0.19.0",
"homepage": "https://github.com/bytecodealliance/componentize-js#readme",

@@ -18,3 +18,3 @@ "description": "ESM -> WebAssembly Component creator, via a SpiderMonkey JS engine embedding",

"devDependencies": {
"@bytecodealliance/preview2-shim": "^0.17.1",
"@bytecodealliance/preview2-shim": "^0.17.4",
"cross-env": "^7.0.3",

@@ -26,3 +26,2 @@ "semver": "^7.7.2",

"@bytecodealliance/jco": "^1.9.1",
"@bytecodealliance/weval": "^0.3.4",
"@bytecodealliance/wizer": "^10.0.0",

@@ -36,9 +35,7 @@ "es-module-lexer": "^1.6.0",

"clean:starlingmonkey": "rm -rf build-release",
"build": "npm run build:release && npm run build:debug && npm run build:weval",
"build": "npm run build:release && npm run build:debug",
"build:release": "make release",
"build:weval": "make release-weval",
"build:debug": "make debug",
"test": "vitest run -c test/vitest.ts",
"test:release": "vitest run -c test/vitest.ts",
"test:weval": "cross-env WEVAL_TEST=1 vitest run -c test/vitest.ts",
"test:debug": "cross-env DEBUG_TEST=1 vitest run -c test/vitest.ts",

@@ -52,4 +49,2 @@ "prepack": "node scripts/prepack.mjs"

"lib/starlingmonkey_embedding.debug.wasm",
"lib/starlingmonkey_embedding_weval.wasm",
"lib/starlingmonkey_ics.wevalcache",
"src",

@@ -56,0 +51,0 @@ "types.d.ts"

@@ -54,2 +54,3 @@ <div align="center">

Note: unfortunately Weval AOT Compilation is disabled for the time being, due to incompatibilities with newer versions of the LLVM toolchain used to compile StarlingMonkey. See [this](https://bytecodealliance.zulipchat.com/#narrow/channel/459697-StarlingMonkey/topic/Updating.20Gecko.20version/near/527089464) and the following messages for details.

@@ -62,3 +63,3 @@ ## Platform APIs

* **Streams**: `ReadableStream`, `ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`, `ReadableStreamDefaultReader`, `ReadableStreamDefaultController`, `ReadableByteStreamController`, `WritableStream` `ByteLengthQueuingStrategy` `CountQueuingStrategy`, `TransformStream`
* **URL**: `URL` `URLSearchParams`
* **URL**: `URL`, `URLSearchParams`
* **Console**: `console`

@@ -70,5 +71,6 @@ * **Performance**: `Performance`

* **Structured Clone**: `structuredClone`
* **Fetch**: `fetch` `Request` `Response` `Headers`
* **Fetch**: `fetch`, `Request`, `Response`, `Headers`
* **Forms, Files, and Blobs**: `FormData`, `MultipartFormData`, `File`, `Blob`
* **Crypto**: `SubtleCrypto` `Crypto` `crypto` `CryptoKey`
* **Crypto**: `SubtleCrypto`, `Crypto`, `crypto`, `CryptoKey`
* **Abort**: `AbortController`, `AbortSignal`

@@ -112,20 +114,4 @@ ## Usage

### AOT Compilation
### Custom `wizer` binary
To enable AOT compilation, set the `enableAot: true` option to run [Weval][weval] ahead-of-time compilation.
AOT compilation can also be configured with the following options:
| Option | Type | Example | Description |
|------------------------|-------------------------------------|-----------------|--------------------------------------------------------------------------|
| `aotMinStackSizeBytes` | `nubmer | Number | bigint | BigInt` | `2_007_846_092` | The minimum stack size (via `RUST_MIN_STACK` to set when running `weval` |
[weval]: https://github.com/bytecodealliance/weval
### Custom `weval` binary for AOT
To use a custom (pre-downloaded) [`weval`][weval] binary, set the `wevalBin` option to the path to your desired weval binary.
### Custom `wizer` binary when AOT is disabled
To use a custom (pre-downloaded) [`wizer`](https://github.com/bytecodealliance/wizer) binary, set the `wizerBin` option to the path to your desired wizer binary.

@@ -237,14 +223,2 @@

/**
* Path to custom weval cache to use
*/
aotCache?: string;
/**
* Enable AoT using weval
*/
enableAot?: boolean;
/**
* Use a pre-existing path to the `weval` binary, if present
*/
wevalBin?: string;
/**
* Use a pre-existing path to the `wizer` binary, if present

@@ -274,3 +248,3 @@ */

/**
* Pass environment variables to the spawned Wizer or Weval Process
* Pass environment variables to the spawned Wizer Process
* If set to true, all host environment variables are passed

@@ -354,10 +328,2 @@ * To pass only a subset, provide an object with the desired variables

Before being able to use `componetize-js` (ex. via `npm link`, from `jco`), you'll need to run:
```
npm run build:weval
```
This will produce a few files, most importantly `lib/starlingmonkey_embedding_weval.wasm`.
To clean up a local installation (i.e. remove the installation of StarlingMonkey):

@@ -364,0 +330,0 @@

@@ -14,3 +14,2 @@ #! /usr/bin/env node

runtimeArgs: opts.runtimeArgs,
enableAot: opts.aot,
disableFeatures: opts.disable,

@@ -26,3 +25,3 @@ preview2Adapter: opts.preview2Adapter,

program
.version('0.18.5')
.version('0.19.0')
.description('Create a component from a JavaScript module')

@@ -34,3 +33,2 @@ .usage('<js-source> --wit wit-world.wit -o <component-path>')

.option('--runtime-args <string>', 'arguments to pass to the runtime')
.option('--aot', 'enable AOT compilation')
.addOption(

@@ -37,0 +35,0 @@ new Option('-d, --disable <feature...>', 'disable WASI features').choices(

@@ -15,3 +15,2 @@ import { freemem } from 'node:os';

import wizer from '@bytecodealliance/wizer';
import getWeval from '@bytecodealliance/weval';
import {

@@ -48,7 +47,2 @@ componentNew,

/** Default path to the AOT weval cache */
const DEFAULT_AOT_CACHE = fileURLToPath(
new URL(`../lib/starlingmonkey_ics.wevalcache`, import.meta.url),
);
/** Default settings for debug options */

@@ -115,3 +109,2 @@ const DEFAULT_DEBUG_SETTINGS = {

aotCache = DEFAULT_AOT_CACHE,
} = opts;

@@ -256,15 +249,12 @@

// component to be relative to the current working directory.
// This only works in wizer, not in weval, because the latter doesn't
// support --mapdir.
if (!opts.enableAot) {
if (!useOriginalSourceFile) {
workspacePrefix = sourcesDir;
sourcePath = sourceName;
}
let currentDir = maybeWindowsPath(cwd());
if (workspacePrefix.startsWith(currentDir)) {
workspacePrefix = currentDir;
sourcePath = sourcePath.slice(workspacePrefix.length + 1);
}
// This only works in wizer.
if (!useOriginalSourceFile) {
workspacePrefix = sourcesDir;
sourcePath = sourceName;
}
let currentDir = maybeWindowsPath(cwd());
if (workspacePrefix.startsWith(currentDir)) {
workspacePrefix = currentDir;
sourcePath = sourcePath.slice(workspacePrefix.length + 1);
}

@@ -275,75 +265,29 @@ let args = `--initializer-script-path ${initializerPath} --strip-path-prefix ${workspacePrefix}/ ${sourcePath}`;

let preopens = [`--dir ${sourcesDir}`];
if (opts.enableAot) {
preopens.push(`--dir ${workspacePrefix}`);
} else {
preopens.push(`--mapdir /::${workspacePrefix}`);
}
preopens.push(`--mapdir /::${workspacePrefix}`);
let postProcess;
if (opts.enableAot) {
// Determine the weval bin path, possibly using a pre-downloaded version
let wevalBin;
if (opts.wevalBin && existsSync(opts.wevalBin)) {
wevalBin = opts.wevalBin;
} else {
wevalBin = await getWeval();
}
// Set the min stack size, if one was provided
if (opts.aotMinStackSizeBytes) {
if (!isNumeric(opts.aotMinStackSizeBytes)) {
throw new TypeError(
`aotMinStackSizeBytes must be a numeric value, received [${opts.aotMinStackSizeBytes}] (type ${typeof opts.aotMinStackSizeBytes})`,
);
}
env.RUST_MIN_STACK = opts.aotMinStackSizeBytes;
} else {
env.RUST_MIN_STACK = defaultMinStackSize();
}
const wizerBin = opts.wizerBin ?? wizer;
postProcess = spawnSync(
wizerBin,
[
'--allow-wasi',
'--init-func',
'componentize.wizer',
...preopens,
`--wasm-bulk-memory=true`,
'--inherit-env=true',
`-o=${outputWasmPath}`,
inputWasmPath,
],
{
stdio: [null, stdout, 'pipe'],
env,
input: runtimeArgs,
shell: true,
encoding: 'utf-8',
},
);
postProcess = spawnSync(
wevalBin,
[
'weval',
`--cache-ro ${aotCache}`,
...preopens,
'-w',
'--init-func',
'componentize.wizer',
`-i ${inputWasmPath}`,
`-o ${outputWasmPath}`,
],
{
stdio: [null, stdout, 'pipe'],
env,
input: runtimeArgs,
shell: true,
encoding: 'utf-8',
},
);
} else {
const wizerBin = opts.wizerBin ?? wizer;
postProcess = spawnSync(
wizerBin,
[
'--allow-wasi',
'--init-func',
'componentize.wizer',
...preopens,
`--wasm-bulk-memory=true`,
'--inherit-env=true',
`-o=${outputWasmPath}`,
inputWasmPath,
],
{
stdio: [null, stdout, 'pipe'],
env,
input: runtimeArgs,
shell: true,
encoding: 'utf-8',
},
);
}
// If the wizer (or weval) process failed, parse the output and display to the user
// If the wizer process failed, parse the output and display to the user
if (postProcess.status !== 0) {

@@ -459,3 +403,3 @@ let wizerErr = parseWizerStderr(postProcess.stderr);

/**
* Parse output of post-processing step (whether Wizer or Weval)
* Parse output of post-processing Wizer step
*

@@ -502,5 +446,3 @@ * @param {Stream} stderr

let engineBinaryRelPath = `../lib/starlingmonkey_embedding${debugSuffix}.wasm`;
if (opts.enableAot) {
engineBinaryRelPath = '../lib/starlingmonkey_embedding_weval.wasm';
}
return fileURLToPath(new URL(engineBinaryRelPath, import.meta.url));

@@ -507,0 +449,0 @@ }

@@ -21,14 +21,2 @@ interface ComponentizeOptions {

/**
* Path to custom weval cache to use
*/
aotCache?: string;
/**
* Enable AoT using weval
*/
enableAot?: boolean;
/**
* Use a pre-existing path to the `weval` binary, if present
*/
wevalBin?: string;
/**
* Use a pre-existing path to the `wizer` binary, if present

@@ -58,3 +46,3 @@ */

/**
* Pass environment variables to the spawned Wizer or Weval Process
* Pass environment variables to the spawned Wizer Process
* If set to true, all host environment variables are passed

@@ -61,0 +49,0 @@ * To pass only a subset, provide an object with the desired variables

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display