@rspack/binding 1.5.0 → 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 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/napi-binding.d.ts CHANGED
@@ -495,6 +495,10 @@ export declare class VirtualFileStore {
495
495
  }
496
496
  export type JsVirtualFileStore = VirtualFileStore
497
497
 
498
+ export interface AssetInfoRelated {
499
+ sourceMap?: string | null
500
+ }
501
+
498
502
  export declare function async(path: string, request: string): Promise<ResolveResult>
499
503
 
500
504
  export interface BuiltinPlugin {
@@ -674,10 +678,6 @@ export interface JsAssetEmittedArgs {
674
678
  targetPath: string
675
679
  }
676
680
 
677
- export interface JsAssetInfoRelated {
678
- sourceMap?: string
679
- }
680
-
681
681
  export interface JsBannerContentFnCtx {
682
682
  hash: string
683
683
  chunk: Chunk
@@ -1503,7 +1503,7 @@ export interface KnownAssetInfo {
1503
1503
  /** when asset is javascript and an ESM */
1504
1504
  javascriptModule?: boolean
1505
1505
  /** related object to other assets, keyed by type of relation (only points from parent to child) */
1506
- related?: JsAssetInfoRelated
1506
+ related?: AssetInfoRelated
1507
1507
  /** unused css local ident for the css chunk */
1508
1508
  cssUnusedIdents?: Array<string>
1509
1509
  /** whether this asset is over the size limit */
@@ -2348,11 +2348,11 @@ export interface RawJsonParserOptions {
2348
2348
  }
2349
2349
 
2350
2350
  export interface RawLazyCompilationOption {
2351
- module: ((err: Error | null, arg: RawModuleArg) => RawModuleInfo)
2351
+ currentActiveModules: ((err: Error | null, ) => Set<string>)
2352
2352
  test?: RawLazyCompilationTest
2353
2353
  entries: boolean
2354
2354
  imports: boolean
2355
- cacheable: boolean
2355
+ client: string
2356
2356
  }
2357
2357
 
2358
2358
  export interface RawLibManifestPluginOptions {
@@ -2410,11 +2410,6 @@ export interface RawLimitChunkCountPluginOptions {
2410
2410
  maxChunks: number
2411
2411
  }
2412
2412
 
2413
- export interface RawModuleArg {
2414
- module: string
2415
- path: string
2416
- }
2417
-
2418
2413
  export interface RawModuleFederationRuntimePluginOptions {
2419
2414
  entryRuntime?: string | undefined
2420
2415
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/binding",
3
- "version": "1.5.0",
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.0",
54
- "@rspack/binding-win32-arm64-msvc": "1.5.0",
55
- "@rspack/binding-linux-arm64-gnu": "1.5.0",
56
- "@rspack/binding-linux-arm64-musl": "1.5.0",
57
- "@rspack/binding-wasm32-wasi": "1.5.0",
58
- "@rspack/binding-darwin-x64": "1.5.0",
59
- "@rspack/binding-win32-ia32-msvc": "1.5.0",
60
- "@rspack/binding-win32-x64-msvc": "1.5.0",
61
- "@rspack/binding-linux-x64-gnu": "1.5.0",
62
- "@rspack/binding-linux-x64-musl": "1.5.0"
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);