@oxc-transform/binding-wasm32-wasi 0.77.2 → 0.77.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxc-transform/binding-wasm32-wasi",
3
- "version": "0.77.2",
3
+ "version": "0.77.3",
4
4
  "cpu": [
5
5
  "wasm32"
6
6
  ],
@@ -23,16 +23,16 @@
23
23
  "engines": {
24
24
  "node": ">=14.0.0"
25
25
  },
26
- "publishConfig": {
27
- "registry": "https://registry.npmjs.org/",
28
- "access": "public"
29
- },
30
26
  "repository": {
31
27
  "type": "git",
32
28
  "url": "https://github.com/oxc-project/oxc.git",
33
29
  "directory": "napi/transform"
34
30
  },
35
31
  "bugs": "https://github.com/oxc-project/oxc/issues",
32
+ "publishConfig": {
33
+ "registry": "https://registry.npmjs.org/",
34
+ "access": "public"
35
+ },
36
36
  "browser": "transform.wasi-browser.js",
37
37
  "dependencies": {
38
38
  "@napi-rs/wasm-runtime": "^1.0.0"
@@ -5,14 +5,16 @@ import {
5
5
  WASI as __WASI,
6
6
  } from '@napi-rs/wasm-runtime'
7
7
 
8
- import __wasmUrl from './transform.wasm32-wasi.wasm?url'
8
+
9
9
 
10
10
  const __wasi = new __WASI({
11
11
  version: 'preview1',
12
12
  })
13
13
 
14
+ const __wasmUrl = new URL('./transform.wasm32-wasi.wasm', import.meta.url).href
14
15
  const __emnapiContext = __emnapiGetDefaultContext()
15
16
 
17
+
16
18
  const __sharedMemory = new WebAssembly.Memory({
17
19
  initial: 4000,
18
20
  maximum: 65536,
@@ -65,6 +65,29 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule
65
65
  worker.onmessage = ({ data }) => {
66
66
  __wasmCreateOnMessageForFsProxy(__nodeFs)(data)
67
67
  }
68
+
69
+ // The main thread of Node.js waits for all the active handles before exiting.
70
+ // But Rust threads are never waited without `thread::join`.
71
+ // So here we hack the code of Node.js to prevent the workers from being referenced (active).
72
+ // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415,
73
+ // a worker is consist of two handles: kPublicPort and kHandle.
74
+ {
75
+ const kPublicPort = Object.getOwnPropertySymbols(worker).find(s =>
76
+ s.toString().includes("kPublicPort")
77
+ );
78
+ if (kPublicPort) {
79
+ worker[kPublicPort].ref = () => {};
80
+ }
81
+
82
+ const kHandle = Object.getOwnPropertySymbols(worker).find(s =>
83
+ s.toString().includes("kHandle")
84
+ );
85
+ if (kHandle) {
86
+ worker[kHandle].ref = () => {};
87
+ }
88
+
89
+ worker.unref();
90
+ }
68
91
  return worker
69
92
  },
70
93
  overwriteImports(importObject) {
Binary file