@rspack/binding-wasm32-wasi 2.0.0-rc.1 → 2.0.0-rc.2

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": "@rspack/binding-wasm32-wasi",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.2",
4
4
  "license": "MIT",
5
5
  "description": "Node binding for rspack",
6
6
  "main": "rspack.wasi.cjs",
@@ -23,7 +23,9 @@
23
23
  "wasi-worker-browser.mjs"
24
24
  ],
25
25
  "dependencies": {
26
- "@napi-rs/wasm-runtime": "1.1.2"
26
+ "@emnapi/core": "1.9.2",
27
+ "@emnapi/runtime": "1.9.2",
28
+ "@napi-rs/wasm-runtime": "1.1.3"
27
29
  },
28
30
  "cpu": [
29
31
  "wasm32"
@@ -21,9 +21,10 @@ const __wasmUrl = new URL('./rspack.wasm32-wasi.wasm', import.meta.url).href
21
21
  const __emnapiContext = __emnapiGetDefaultContext()
22
22
  __emnapiContext.feature.Buffer = Buffer
23
23
 
24
+ // Allocate 2GB fixed shared memory (initial == maximum to disable memory.grow).
24
25
  const __sharedMemory = new WebAssembly.Memory({
25
- initial: 16384,
26
- maximum: 65536,
26
+ initial: 32768,
27
+ maximum: 32768,
27
28
  shared: true,
28
29
  })
29
30
 
@@ -57,6 +58,10 @@ const {
57
58
  ...importObject.napi,
58
59
  ...importObject.emnapi,
59
60
  memory: __sharedMemory,
61
+ // Override emnapi's napi_adjust_external_memory to a no-op.
62
+ // emnapi implements this by calling memory.grow, but we've disabled memory.grow
63
+ // (initial == maximum).
64
+ napi_adjust_external_memory() { return 0 },
60
65
  }
61
66
  return importObject
62
67
  },
package/rspack.wasi.cjs CHANGED
@@ -26,9 +26,10 @@ const __wasi = new __nodeWASI({
26
26
 
27
27
  const __emnapiContext = __emnapiGetDefaultContext()
28
28
 
29
+ // Allocate 2GB fixed shared memory (initial == maximum to disable memory.grow).
29
30
  const __sharedMemory = new WebAssembly.Memory({
30
- initial: 16384,
31
- maximum: 65536,
31
+ initial: 32768,
32
+ maximum: 32768,
32
33
  shared: true,
33
34
  })
34
35
 
@@ -97,6 +98,10 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule
97
98
  ...importObject.napi,
98
99
  ...importObject.emnapi,
99
100
  memory: __sharedMemory,
101
+ // Override emnapi's napi_adjust_external_memory to a no-op.
102
+ // emnapi implements this by calling memory.grow, but we've disabled memory.grow
103
+ // (initial == maximum).
104
+ napi_adjust_external_memory() { return 0 },
100
105
  }
101
106
  return importObject
102
107
  },
Binary file
@@ -16,10 +16,10 @@ const handler = new MessageHandler({
16
16
  // eslint-disable-next-line no-console
17
17
  console.log.apply(console, arguments)
18
18
  },
19
- printErr: function() {
19
+ printErr: function () {
20
20
  // eslint-disable-next-line no-console
21
21
  console.error.apply(console, arguments)
22
-
22
+
23
23
  errorOutputs.push([...arguments])
24
24
  },
25
25
  })
@@ -32,6 +32,10 @@ const handler = new MessageHandler({
32
32
  ...importObject.napi,
33
33
  ...importObject.emnapi,
34
34
  memory: wasmMemory,
35
+ // Override emnapi's napi_adjust_external_memory to a no-op.
36
+ // emnapi implements this by calling memory.grow, but we've disabled memory.grow
37
+ // (initial == maximum).
38
+ napi_adjust_external_memory() { return 0 },
35
39
  }
36
40
  },
37
41
  })
package/wasi-worker.mjs CHANGED
@@ -19,7 +19,7 @@ Object.assign(globalThis, {
19
19
  require,
20
20
  Worker,
21
21
  importScripts: function (f) {
22
- ;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
22
+ ; (0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
23
23
  },
24
24
  postMessage: function (msg) {
25
25
  if (parentPort) {
@@ -51,7 +51,11 @@ const handler = new MessageHandler({
51
51
  ...importObject.env,
52
52
  ...importObject.napi,
53
53
  ...importObject.emnapi,
54
- memory: wasmMemory
54
+ memory: wasmMemory,
55
+ // Override emnapi's napi_adjust_external_memory to a no-op.
56
+ // emnapi implements this by calling memory.grow, but we've disabled memory.grow
57
+ // (initial == maximum).
58
+ napi_adjust_external_memory() { return 0 },
55
59
  };
56
60
  },
57
61
  });