@bytecodealliance/preview2-shim 0.20.0 → 0.20.1

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.
@@ -1,2 +1,2 @@
1
- export declare function createSyncFn(workerPath: any, debug: any, callbackHandler: any): (...args: any[]) => any;
1
+ export declare function createSyncFn(createWorker: any, debug: any, callbackHandler: any): (...args: any[]) => any;
2
2
  export declare function runAsWorker(fn: any): any;
@@ -22,8 +22,7 @@
22
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
23
  SOFTWARE.
24
24
  */
25
- import path from "node:path";
26
- import { MessageChannel, Worker, receiveMessageOnPort, workerData, parentPort, } from "node:worker_threads";
25
+ import { MessageChannel, receiveMessageOnPort, workerData, parentPort } from "node:worker_threads";
27
26
  const DEFAULT_WORKER_BUFFER_SIZE = 1024;
28
27
  function extractProperties(object) {
29
28
  if (object && typeof object === "object") {
@@ -35,12 +34,9 @@ function extractProperties(object) {
35
34
  }
36
35
  }
37
36
  const CALL_TIMEOUT = undefined;
38
- export function createSyncFn(workerPath, debug, callbackHandler) {
39
- if (!path.isAbsolute(workerPath)) {
40
- throw new Error("`workerPath` must be absolute");
41
- }
37
+ export function createSyncFn(createWorker, debug, callbackHandler) {
42
38
  const { port1: mainPort, port2: workerPort } = new MessageChannel();
43
- const worker = new Worker(workerPath, {
39
+ const worker = createWorker({
44
40
  workerData: { workerPort, debug },
45
41
  transferList: [workerPort],
46
42
  execArgv: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytecodealliance/preview2-shim",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "WASI Preview2 shim for JS environments",
5
5
  "homepage": "https://github.com/bytecodealliance/jco#readme",
6
6
  "bugs": {
@@ -62,11 +62,12 @@
62
62
  "@types/node": "^24.12.4",
63
63
  "mime": "^4.0.7",
64
64
  "puppeteer": "^25.1.0",
65
+ "rolldown": "^1.2.0",
65
66
  "typescript": "^6.0.3",
66
67
  "vitest": "^4.0.8"
67
68
  },
68
69
  "scripts": {
69
- "build": "tsc --project tsconfig.build.json",
70
+ "build": "tsc --project tsconfig.build.json && node scripts/build-worker.mjs",
70
71
  "build:watch": "tsc --watch",
71
72
  "types:check": "tsc --noEmit",
72
73
  "fmt": "oxfmt",