@rspack-debug/browser 2.0.0-canary.20260120 → 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.
Files changed (56) hide show
  1. package/dist/Compilation.d.ts +3 -0
  2. package/dist/Compiler.d.ts +1 -0
  3. package/dist/FileSystem.d.ts +1 -1
  4. package/dist/ModuleGraph.d.ts +3 -1
  5. package/dist/ModuleGraphConnection.d.ts +10 -0
  6. package/dist/NormalModule.d.ts +0 -1
  7. package/dist/RuntimeGlobals.d.ts +1 -1
  8. package/dist/browser/BrowserRequirePlugin.d.ts +1 -1
  9. package/dist/browser/fs.d.ts +1 -1
  10. package/dist/builtin-loader/swc/pluginImport.d.ts +1 -1
  11. package/dist/builtin-loader/swc/types.d.ts +36 -1
  12. package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +4 -2
  13. package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +9 -0
  14. package/dist/builtin-plugin/HashedModuleIdsPlugin.d.ts +10 -0
  15. package/dist/builtin-plugin/ProgressPlugin.d.ts +5 -4
  16. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +2 -2
  17. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +9 -9
  18. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -1
  19. package/dist/builtin-plugin/WorkerPlugin.d.ts +1 -0
  20. package/dist/builtin-plugin/index.d.ts +3 -0
  21. package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +3 -3
  22. package/dist/builtin-plugin/rsc/Coordinator.d.ts +8 -0
  23. package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +13 -0
  24. package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +39 -0
  25. package/dist/builtin-plugin/rsc/index.d.ts +24 -0
  26. package/dist/checkNodeVersion.d.ts +1 -0
  27. package/dist/config/adapterRuleUse.d.ts +1 -1
  28. package/dist/config/devServer.d.ts +102 -237
  29. package/dist/config/normalization.d.ts +4 -4
  30. package/dist/config/types.d.ts +184 -71
  31. package/dist/container/ContainerPlugin.d.ts +3 -2
  32. package/dist/container/ContainerReferencePlugin.d.ts +4 -3
  33. package/dist/container/ModuleFederationManifestPlugin.d.ts +10 -3
  34. package/dist/container/ModuleFederationPlugin.d.ts +20 -1
  35. package/dist/container/ModuleFederationPluginV1.d.ts +2 -2
  36. package/dist/container/ModuleFederationRuntimePlugin.d.ts +4 -0
  37. package/dist/exports.d.ts +16 -7
  38. package/dist/index.d.ts +2 -1
  39. package/dist/index.js +11541 -7053
  40. package/dist/napi-binding.d.ts +254 -94
  41. package/dist/rspack.wasi-browser.js +15 -3
  42. package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
  43. package/dist/sharing/ConsumeSharedPlugin.d.ts +16 -3
  44. package/dist/sharing/IndependentSharedPlugin.d.ts +35 -0
  45. package/dist/sharing/ProvideSharedPlugin.d.ts +22 -2
  46. package/dist/sharing/SharePlugin.d.ts +43 -5
  47. package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
  48. package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
  49. package/dist/sharing/TreeShakingSharedPlugin.d.ts +16 -0
  50. package/dist/sharing/utils.d.ts +1 -0
  51. package/dist/swc.d.ts +1 -1
  52. package/dist/util/createHash.d.ts +1 -1
  53. package/dist/util/supportsColor.d.ts +6 -0
  54. package/dist/wasi-worker-browser.mjs +10300 -6050
  55. package/package.json +6 -4
  56. package/dist/rslib-runtime.js +0 -68
@@ -17,13 +17,14 @@ const __wasi = new __WASI({
17
17
  },
18
18
  })
19
19
 
20
- const __wasmUrl = window.RSPACK_WASM_URL || new URL('./rspack.wasm32-wasi.wasm', import.meta.url).href
20
+ const __wasmUrl = globalThis.RSPACK_WASM_URL || 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
 
@@ -43,6 +44,12 @@ const {
43
44
  })
44
45
  worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
45
46
 
47
+ worker.addEventListener('error', (event) => {
48
+ if (event.data && typeof event.data === 'object' && event.data.type === 'error') {
49
+ window.dispatchEvent(new CustomEvent('napi-rs-worker-error', { detail: event.data }))
50
+ }
51
+ })
52
+
46
53
  return worker
47
54
  },
48
55
  overwriteImports(importObject) {
@@ -51,6 +58,10 @@ const {
51
58
  ...importObject.napi,
52
59
  ...importObject.emnapi,
53
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 },
54
65
  }
55
66
  return importObject
56
67
  },
@@ -85,6 +96,7 @@ export const JsCompilation = __napiModule.exports.JsCompilation
85
96
  export const JsCompiler = __napiModule.exports.JsCompiler
86
97
  export const JsContextModuleFactoryAfterResolveData = __napiModule.exports.JsContextModuleFactoryAfterResolveData
87
98
  export const JsContextModuleFactoryBeforeResolveData = __napiModule.exports.JsContextModuleFactoryBeforeResolveData
99
+ export const JsCoordinator = __napiModule.exports.JsCoordinator
88
100
  export const JsDependencies = __napiModule.exports.JsDependencies
89
101
  export const JsEntries = __napiModule.exports.JsEntries
90
102
  export const JsExportsInfo = __napiModule.exports.JsExportsInfo
@@ -0,0 +1,22 @@
1
+ import { type BuiltinPlugin, BuiltinPluginName } from '../binding';
2
+ import { RspackBuiltinPlugin } from '../builtin-plugin/base';
3
+ import type { Compiler } from '../Compiler';
4
+ import { type NormalizedSharedOptions, type ShareScope } from './SharePlugin';
5
+ export type CollectSharedEntryPluginOptions = {
6
+ sharedOptions: NormalizedSharedOptions;
7
+ shareScope?: ShareScope;
8
+ };
9
+ export type ShareRequestsMap = Record<string, {
10
+ shareScope: string;
11
+ requests: [string, string][];
12
+ }>;
13
+ export declare class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
14
+ name: BuiltinPluginName;
15
+ sharedOptions: NormalizedSharedOptions;
16
+ private _collectedEntries;
17
+ constructor(options: CollectSharedEntryPluginOptions);
18
+ getData(): ShareRequestsMap;
19
+ getFilename(): string;
20
+ apply(compiler: Compiler): void;
21
+ raw(): BuiltinPlugin;
22
+ }
@@ -3,7 +3,7 @@ import { RspackBuiltinPlugin } from '../builtin-plugin/base';
3
3
  import type { Compiler } from '../Compiler';
4
4
  export type ConsumeSharedPluginOptions = {
5
5
  consumes: Consumes;
6
- shareScope?: string;
6
+ shareScope?: string | string[];
7
7
  enhanced?: boolean;
8
8
  };
9
9
  export type Consumes = (ConsumesItem | ConsumesObject)[] | ConsumesObject;
@@ -17,22 +17,35 @@ export type ConsumesConfig = {
17
17
  packageName?: string;
18
18
  requiredVersion?: false | string;
19
19
  shareKey?: string;
20
- shareScope?: string;
20
+ shareScope?: string | string[];
21
21
  singleton?: boolean;
22
22
  strictVersion?: boolean;
23
+ treeShakingMode?: 'server-calc' | 'runtime-infer';
23
24
  };
25
+ export declare function normalizeConsumeShareOptions(consumes: Consumes, shareScope?: string | string[]): [string, {
26
+ import: string | undefined;
27
+ shareScope: string | string[];
28
+ shareKey: string;
29
+ requiredVersion: string | false | undefined;
30
+ strictVersion: boolean;
31
+ packageName: string | undefined;
32
+ singleton: boolean;
33
+ eager: boolean;
34
+ treeShakingMode: "server-calc" | "runtime-infer" | undefined;
35
+ }][];
24
36
  export declare class ConsumeSharedPlugin extends RspackBuiltinPlugin {
25
37
  name: BuiltinPluginName;
26
38
  _options: {
27
39
  consumes: [string, {
28
40
  import: string | undefined;
29
- shareScope: string;
41
+ shareScope: string | string[];
30
42
  shareKey: string;
31
43
  requiredVersion: string | false | undefined;
32
44
  strictVersion: boolean;
33
45
  packageName: string | undefined;
34
46
  singleton: boolean;
35
47
  eager: boolean;
48
+ treeShakingMode: "server-calc" | "runtime-infer" | undefined;
36
49
  }][];
37
50
  enhanced: boolean;
38
51
  };
@@ -0,0 +1,35 @@
1
+ import type { Compiler } from '../Compiler';
2
+ import type { LibraryOptions, Plugins } from '../config';
3
+ import { type ModuleFederationManifestPluginOptions } from '../container/ModuleFederationManifestPlugin';
4
+ import type { Shared, SharedConfig } from './SharePlugin';
5
+ export type MakeRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
6
+ export interface IndependentSharePluginOptions {
7
+ name: string;
8
+ shared: Shared;
9
+ library?: LibraryOptions;
10
+ outputDir?: string;
11
+ plugins?: Plugins;
12
+ treeShaking?: boolean;
13
+ manifest?: ModuleFederationManifestPluginOptions;
14
+ injectTreeShakingUsedExports?: boolean;
15
+ treeShakingSharedExcludePlugins?: string[];
16
+ }
17
+ export type ShareFallback = Record<string, [string, string, string][]>;
18
+ export declare class IndependentSharedPlugin {
19
+ mfName: string;
20
+ shared: Shared;
21
+ library?: LibraryOptions;
22
+ sharedOptions: [string, SharedConfig][];
23
+ outputDir: string;
24
+ plugins: Plugins;
25
+ treeShaking?: boolean;
26
+ manifest?: ModuleFederationManifestPluginOptions;
27
+ buildAssets: ShareFallback;
28
+ injectTreeShakingUsedExports?: boolean;
29
+ treeShakingSharedExcludePlugins?: string[];
30
+ name: string;
31
+ constructor(options: IndependentSharePluginOptions);
32
+ apply(compiler: Compiler): void;
33
+ private createIndependentCompilers;
34
+ private createIndependentCompiler;
35
+ }
@@ -1,9 +1,10 @@
1
1
  import { type BuiltinPlugin, BuiltinPluginName, type RawProvideOptions } from '../binding';
2
2
  import { RspackBuiltinPlugin } from '../builtin-plugin/base';
3
3
  import type { Compiler } from '../Compiler';
4
+ import type { ShareScope } from './SharePlugin';
4
5
  export type ProvideSharedPluginOptions<Enhanced extends boolean = false> = {
5
6
  provides: Provides<Enhanced>;
6
- shareScope?: string;
7
+ shareScope?: ShareScope;
7
8
  enhanced?: Enhanced;
8
9
  };
9
10
  export type Provides<Enhanced extends boolean> = (ProvidesItem | ProvidesObject<Enhanced>)[] | ProvidesObject<Enhanced>;
@@ -15,7 +16,7 @@ export type ProvidesConfig<Enhanced extends boolean> = Enhanced extends true ? P
15
16
  type ProvidesV1Config = {
16
17
  eager?: boolean;
17
18
  shareKey: string;
18
- shareScope?: string;
19
+ shareScope?: ShareScope;
19
20
  version?: false | string;
20
21
  };
21
22
  type ProvidesEnhancedConfig = ProvidesV1Config & ProvidesEnhancedExtraConfig;
@@ -23,7 +24,26 @@ type ProvidesEnhancedExtraConfig = {
23
24
  singleton?: boolean;
24
25
  strictVersion?: boolean;
25
26
  requiredVersion?: false | string;
27
+ /**
28
+ * Tree shaking strategy for the shared module.
29
+ */
30
+ treeShakingMode?: 'server-calc' | 'runtime-infer';
26
31
  };
32
+ export declare function normalizeProvideShareOptions<Enhanced extends boolean = false>(options: Provides<Enhanced>, shareScope?: ShareScope, enhanced?: boolean): [string, {
33
+ shareKey: string;
34
+ version: string | false | undefined;
35
+ shareScope: ShareScope;
36
+ eager: boolean;
37
+ } | {
38
+ singleton: boolean | undefined;
39
+ requiredVersion: string | false | undefined;
40
+ strictVersion: boolean | undefined;
41
+ treeShakingMode: "server-calc" | "runtime-infer" | undefined;
42
+ shareKey: string;
43
+ version: string | false | undefined;
44
+ shareScope: ShareScope;
45
+ eager: boolean;
46
+ }][];
27
47
  export declare class ProvideSharedPlugin<Enhanced extends boolean = false> extends RspackBuiltinPlugin {
28
48
  name: BuiltinPluginName;
29
49
  _provides: [string, Omit<RawProvideOptions, 'key'>][];
@@ -1,6 +1,8 @@
1
1
  import type { Compiler } from '../Compiler';
2
+ export type ShareScope = string | string[];
3
+ export declare function validateShareScope(shareScope: ShareScope, enhanced: boolean, pluginName: string): void;
2
4
  export type SharePluginOptions = {
3
- shareScope?: string;
5
+ shareScope?: ShareScope;
4
6
  shared: Shared;
5
7
  enhanced: boolean;
6
8
  };
@@ -9,43 +11,79 @@ export type SharedItem = string;
9
11
  export type SharedObject = {
10
12
  [k: string]: SharedConfig | SharedItem;
11
13
  };
14
+ export type TreeShakingConfig = {
15
+ usedExports?: string[];
16
+ mode?: 'server-calc' | 'runtime-infer';
17
+ filename?: string;
18
+ };
12
19
  export type SharedConfig = {
13
20
  eager?: boolean;
14
21
  import?: false | SharedItem;
15
22
  packageName?: string;
16
23
  requiredVersion?: false | string;
17
24
  shareKey?: string;
18
- shareScope?: string;
25
+ shareScope?: ShareScope;
19
26
  singleton?: boolean;
20
27
  strictVersion?: boolean;
21
28
  version?: false | string;
29
+ treeShaking?: TreeShakingConfig;
22
30
  };
31
+ export type NormalizedSharedOptions = [string, SharedConfig][];
32
+ export declare function normalizeSharedOptions(shared: Shared): NormalizedSharedOptions;
33
+ export declare function createProvideShareOptions(normalizedSharedOptions: NormalizedSharedOptions): {
34
+ [x: string]: {
35
+ shareKey: string;
36
+ shareScope: ShareScope | undefined;
37
+ version: string | false | undefined;
38
+ eager: boolean | undefined;
39
+ singleton: boolean | undefined;
40
+ requiredVersion: string | false | undefined;
41
+ strictVersion: boolean | undefined;
42
+ treeShakingMode: "server-calc" | "runtime-infer" | undefined;
43
+ };
44
+ }[];
45
+ export declare function createConsumeShareOptions(normalizedSharedOptions: NormalizedSharedOptions): {
46
+ [x: string]: {
47
+ import: string | false | undefined;
48
+ shareKey: string;
49
+ shareScope: ShareScope | undefined;
50
+ requiredVersion: string | false | undefined;
51
+ strictVersion: boolean | undefined;
52
+ singleton: boolean | undefined;
53
+ packageName: string | undefined;
54
+ eager: boolean | undefined;
55
+ treeShakingMode: "server-calc" | "runtime-infer" | undefined;
56
+ };
57
+ }[];
23
58
  export declare class SharePlugin {
24
- _shareScope: string | undefined;
59
+ _shareScope: ShareScope | undefined;
25
60
  _consumes: {
26
61
  [x: string]: {
27
62
  import: string | false | undefined;
28
63
  shareKey: string;
29
- shareScope: string | undefined;
64
+ shareScope: ShareScope | undefined;
30
65
  requiredVersion: string | false | undefined;
31
66
  strictVersion: boolean | undefined;
32
67
  singleton: boolean | undefined;
33
68
  packageName: string | undefined;
34
69
  eager: boolean | undefined;
70
+ treeShakingMode: "server-calc" | "runtime-infer" | undefined;
35
71
  };
36
72
  }[];
37
73
  _provides: {
38
74
  [x: string]: {
39
75
  shareKey: string;
40
- shareScope: string | undefined;
76
+ shareScope: ShareScope | undefined;
41
77
  version: string | false | undefined;
42
78
  eager: boolean | undefined;
43
79
  singleton: boolean | undefined;
44
80
  requiredVersion: string | false | undefined;
45
81
  strictVersion: boolean | undefined;
82
+ treeShakingMode: "server-calc" | "runtime-infer" | undefined;
46
83
  };
47
84
  }[];
48
85
  _enhanced: boolean;
86
+ _sharedOptions: NormalizedSharedOptions;
49
87
  constructor(options: SharePluginOptions);
50
88
  apply(compiler: Compiler): void;
51
89
  }
@@ -0,0 +1,23 @@
1
+ import { type BuiltinPlugin, BuiltinPluginName, type RawSharedContainerPluginOptions } from '../binding';
2
+ import { RspackBuiltinPlugin } from '../builtin-plugin/base';
3
+ import type { Compiler } from '../Compiler';
4
+ import type { LibraryOptions } from '../config';
5
+ export type SharedContainerPluginOptions = {
6
+ mfName: string;
7
+ shareName: string;
8
+ version: string;
9
+ request: string;
10
+ library?: LibraryOptions;
11
+ independentShareFileName?: string;
12
+ };
13
+ export declare class SharedContainerPlugin extends RspackBuiltinPlugin {
14
+ name: BuiltinPluginName;
15
+ filename: string;
16
+ _options: RawSharedContainerPluginOptions;
17
+ _shareName: string;
18
+ _globalName: string;
19
+ constructor(options: SharedContainerPluginOptions);
20
+ getData(): (string | undefined)[];
21
+ raw(compiler: Compiler): BuiltinPlugin;
22
+ apply(compiler: Compiler): void;
23
+ }
@@ -0,0 +1,14 @@
1
+ import type { BuiltinPlugin } from '../binding';
2
+ import { BuiltinPluginName } from '../binding';
3
+ import { RspackBuiltinPlugin } from '../builtin-plugin/base';
4
+ import { type ModuleFederationManifestPluginOptions } from '../container/ModuleFederationManifestPlugin';
5
+ import type { NormalizedSharedOptions } from './SharePlugin';
6
+ export declare class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
7
+ name: BuiltinPluginName;
8
+ private sharedOptions;
9
+ private injectTreeShakingUsedExports;
10
+ private manifestOptions;
11
+ constructor(sharedOptions: NormalizedSharedOptions, injectTreeShakingUsedExports?: boolean, manifestOptions?: ModuleFederationManifestPluginOptions);
12
+ private buildOptions;
13
+ raw(): BuiltinPlugin | undefined;
14
+ }
@@ -0,0 +1,16 @@
1
+ import type { Compiler } from '../Compiler';
2
+ import type { ModuleFederationPluginOptions } from '../container/ModuleFederationPlugin';
3
+ export interface TreeshakingSharedPluginOptions {
4
+ mfConfig: ModuleFederationPluginOptions;
5
+ secondary?: boolean;
6
+ }
7
+ export declare class TreeShakingSharedPlugin {
8
+ mfConfig: ModuleFederationPluginOptions;
9
+ outputDir: string;
10
+ secondary?: boolean;
11
+ private _independentSharePlugin?;
12
+ name: string;
13
+ constructor(options: TreeshakingSharedPluginOptions);
14
+ apply(compiler: Compiler): void;
15
+ get buildAssets(): import("./IndependentSharedPlugin").ShareFallback;
16
+ }
@@ -1 +1,2 @@
1
1
  export declare function isRequiredVersion(str: string): boolean;
2
+ export declare const encodeName: (name: string, prefix?: string, withExt?: boolean) => string;
package/dist/swc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { TransformOutput } from './binding';
2
2
  import type { JsMinifyOptions, Options as TransformOptions } from '@swc/types';
3
- export type { TransformOutput, TransformOptions, JsMinifyOptions };
3
+ export type { JsMinifyOptions, TransformOptions, TransformOutput };
4
4
  export declare function minify(source: string, options?: JsMinifyOptions): Promise<TransformOutput>;
5
5
  export declare function minifySync(source: string, options?: JsMinifyOptions): TransformOutput;
6
6
  export declare function transform(source: string, options?: TransformOptions): Promise<TransformOutput>;
@@ -13,4 +13,4 @@ import Hash from './hash';
13
13
  * @param algorithm the algorithm name or a constructor creating a hash
14
14
  * @returns the hash
15
15
  */
16
- export declare const createHash: (algorithm: "debug" | "xxhash64" | "md4" | "native-md4" | (string & {}) | (new () => Hash)) => Hash;
16
+ export declare const createHash: (algorithm: "xxhash64" | "md4" | "native-md4" | (string & {}) | (new () => Hash)) => Hash;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether the current environment supports color output (TTY, FORCE_COLOR, NO_COLOR, etc.).
3
+ * Used as the default for stats.colors when not explicitly set.
4
+ * @see https://github.com/web-infra-dev/rspack/issues/9353
5
+ */
6
+ export declare function isStatsColorSupported(): boolean;