@oxc-node/core-wasm32-wasi 0.0.28 → 0.0.30

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.
@@ -5,14 +5,16 @@ import {
5
5
  WASI as __WASI,
6
6
  } from '@napi-rs/wasm-runtime'
7
7
 
8
- import __wasmUrl from './oxc-node.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('./oxc-node.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: 16384,
18
20
  maximum: 65536,
@@ -59,3 +61,5 @@ export const OxcTransformer = __napiModule.exports.OxcTransformer
59
61
  export const createResolve = __napiModule.exports.createResolve
60
62
  export const initTracing = __napiModule.exports.initTracing
61
63
  export const load = __napiModule.exports.load
64
+ export const transform = __napiModule.exports.transform
65
+ export const transformAsync = __napiModule.exports.transformAsync
package/oxc-node.wasi.cjs CHANGED
@@ -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) {
@@ -90,3 +113,5 @@ module.exports.OxcTransformer = __napiModule.exports.OxcTransformer
90
113
  module.exports.createResolve = __napiModule.exports.createResolve
91
114
  module.exports.initTracing = __napiModule.exports.initTracing
92
115
  module.exports.load = __napiModule.exports.load
116
+ module.exports.transform = __napiModule.exports.transform
117
+ module.exports.transformAsync = __napiModule.exports.transformAsync
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxc-node/core-wasm32-wasi",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "cpu": [
5
5
  "wasm32"
6
6
  ],
@@ -16,16 +16,16 @@
16
16
  "engines": {
17
17
  "node": ">=14.0.0"
18
18
  },
19
- "publishConfig": {
20
- "registry": "https://registry.npmjs.org/",
21
- "access": "public"
22
- },
23
19
  "repository": {
24
20
  "type": "git",
25
21
  "url": "git+https://github.com/oxc-project/oxc-node.git"
26
22
  },
23
+ "publishConfig": {
24
+ "registry": "https://registry.npmjs.org/",
25
+ "access": "public"
26
+ },
27
27
  "browser": "oxc-node.wasi-browser.js",
28
28
  "dependencies": {
29
- "@napi-rs/wasm-runtime": "^0.2.11"
29
+ "@napi-rs/wasm-runtime": "^1.0.1"
30
30
  }
31
31
  }