@rspack/binding 1.5.1 → 1.5.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/binding.js +10 -0
- package/package.json +13 -12
- package/webcontainer-fallback.cjs +27 -0
package/binding.js
CHANGED
|
@@ -380,6 +380,16 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
|
384
|
+
try {
|
|
385
|
+
nativeBinding = require("./webcontainer-fallback.cjs")
|
|
386
|
+
} catch (err) {
|
|
387
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
388
|
+
loadErrors.push(err)
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
383
393
|
if (!nativeBinding) {
|
|
384
394
|
if (loadErrors.length > 0) {
|
|
385
395
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/binding",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Node binding for rspack",
|
|
6
6
|
"main": "binding.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"binding.js",
|
|
14
14
|
"binding.d.ts",
|
|
15
|
-
"napi-binding.d.ts"
|
|
15
|
+
"napi-binding.d.ts",
|
|
16
|
+
"webcontainer-fallback.cjs"
|
|
16
17
|
],
|
|
17
18
|
"homepage": "https://rspack.rs",
|
|
18
19
|
"bugs": "https://github.com/web-infra-dev/rspack/issues",
|
|
@@ -50,16 +51,16 @@
|
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
53
|
"optionalDependencies": {
|
|
53
|
-
"@rspack/binding-darwin-arm64": "1.5.
|
|
54
|
-
"@rspack/binding-linux-arm64-gnu": "1.5.
|
|
55
|
-
"@rspack/binding-win32-
|
|
56
|
-
"@rspack/binding-
|
|
57
|
-
"@rspack/binding-
|
|
58
|
-
"@rspack/binding-
|
|
59
|
-
"@rspack/binding-
|
|
60
|
-
"@rspack/binding-win32-x64-msvc": "1.5.
|
|
61
|
-
"@rspack/binding-linux-x64-
|
|
62
|
-
"@rspack/binding-linux-x64-
|
|
54
|
+
"@rspack/binding-darwin-arm64": "1.5.2",
|
|
55
|
+
"@rspack/binding-linux-arm64-gnu": "1.5.2",
|
|
56
|
+
"@rspack/binding-win32-arm64-msvc": "1.5.2",
|
|
57
|
+
"@rspack/binding-win32-ia32-msvc": "1.5.2",
|
|
58
|
+
"@rspack/binding-linux-arm64-musl": "1.5.2",
|
|
59
|
+
"@rspack/binding-wasm32-wasi": "1.5.2",
|
|
60
|
+
"@rspack/binding-darwin-x64": "1.5.2",
|
|
61
|
+
"@rspack/binding-win32-x64-msvc": "1.5.2",
|
|
62
|
+
"@rspack/binding-linux-x64-musl": "1.5.2",
|
|
63
|
+
"@rspack/binding-linux-x64-gnu": "1.5.2"
|
|
63
64
|
},
|
|
64
65
|
"scripts": {
|
|
65
66
|
"build:dev": "node scripts/build.js",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on https://github.com/oxc-project/oxc/blob/main/napi/parser/webcontainer-fallback.js
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const childProcess = require('node:child_process');
|
|
8
|
+
|
|
9
|
+
const pkg = JSON.parse(
|
|
10
|
+
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8'),
|
|
11
|
+
);
|
|
12
|
+
const version = pkg.version;
|
|
13
|
+
const baseDir = `/tmp/rspack-${version}`;
|
|
14
|
+
const bindingEntry = `${baseDir}/node_modules/${pkg.name}-wasm32-wasi/rspack.wasi.cjs`;
|
|
15
|
+
|
|
16
|
+
if (!fs.existsSync(bindingEntry)) {
|
|
17
|
+
fs.rmSync(baseDir, { recursive: true, force: true });
|
|
18
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
19
|
+
const bindingPkg = `${pkg.name}-wasm32-wasi@${version}`;
|
|
20
|
+
console.log(`[rspack] Downloading ${bindingPkg} on WebContainer...`);
|
|
21
|
+
childProcess.execFileSync('pnpm', ['i', bindingPkg], {
|
|
22
|
+
cwd: baseDir,
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = require(bindingEntry);
|