@rspack/browser 1.7.8 → 1.7.10

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.
@@ -8,6 +8,7 @@ export declare class WorkerPlugin extends RspackBuiltinPlugin {
8
8
  private module;
9
9
  private workerPublicPath;
10
10
  name: BuiltinPluginName;
11
+ affectedHooks: "compilation";
11
12
  constructor(chunkLoading: ChunkLoading, wasmLoading: WasmLoading, module: OutputModule, workerPublicPath: WorkerPublicPath);
12
13
  raw(compiler: Compiler): BuiltinPlugin;
13
14
  }
@@ -2,13 +2,14 @@ import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
2
2
  import { RspackBuiltinPlugin } from '../builtin-plugin/base';
3
3
  import type { Compiler } from '../Compiler';
4
4
  import type { EntryRuntime, FilenameTemplate, LibraryOptions } from '../config';
5
+ import { type ShareScope } from '../sharing/SharePlugin';
5
6
  export type ContainerPluginOptions = {
6
7
  exposes: Exposes;
7
8
  filename?: FilenameTemplate;
8
9
  library?: LibraryOptions;
9
10
  name: string;
10
11
  runtime?: EntryRuntime;
11
- shareScope?: string;
12
+ shareScope?: ShareScope;
12
13
  enhanced?: boolean;
13
14
  };
14
15
  export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
@@ -25,7 +26,7 @@ export declare class ContainerPlugin extends RspackBuiltinPlugin {
25
26
  name: BuiltinPluginName;
26
27
  _options: {
27
28
  name: string;
28
- shareScope: string;
29
+ shareScope: ShareScope;
29
30
  library: LibraryOptions;
30
31
  runtime: EntryRuntime | undefined;
31
32
  filename: string | undefined;
@@ -2,10 +2,11 @@ import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
2
2
  import { RspackBuiltinPlugin } from '../builtin-plugin/base';
3
3
  import type { Compiler } from '../Compiler';
4
4
  import type { ExternalsType } from '../config';
5
+ import { type ShareScope } from '../sharing/SharePlugin';
5
6
  export type ContainerReferencePluginOptions = {
6
7
  remoteType: ExternalsType;
7
8
  remotes: Remotes;
8
- shareScope?: string;
9
+ shareScope?: ShareScope;
9
10
  enhanced?: boolean;
10
11
  };
11
12
  export type Remotes = (RemotesItem | RemotesObject)[] | RemotesObject;
@@ -16,7 +17,7 @@ export type RemotesObject = {
16
17
  };
17
18
  export type RemotesConfig = {
18
19
  external: RemotesItem | RemotesItems;
19
- shareScope?: string;
20
+ shareScope?: ShareScope;
20
21
  };
21
22
  export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
22
23
  name: BuiltinPluginName;
@@ -24,7 +25,7 @@ export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
24
25
  remoteType: ExternalsType;
25
26
  remotes: [string, {
26
27
  external: string[];
27
- shareScope: string;
28
+ shareScope: ShareScope;
28
29
  }][];
29
30
  enhanced: boolean;
30
31
  };
@@ -1,6 +1,6 @@
1
1
  import type { Compiler } from '../Compiler';
2
2
  import type { EntryRuntime, ExternalsType, LibraryOptions } from '../config';
3
- import { type Shared } from '../sharing/SharePlugin';
3
+ import { type Shared, type ShareScope } from '../sharing/SharePlugin';
4
4
  import { type Exposes } from './ContainerPlugin';
5
5
  import { type Remotes } from './ContainerReferencePlugin';
6
6
  export interface ModuleFederationPluginV1Options {
@@ -11,7 +11,7 @@ export interface ModuleFederationPluginV1Options {
11
11
  remoteType?: ExternalsType;
12
12
  remotes?: Remotes;
13
13
  runtime?: EntryRuntime;
14
- shareScope?: string;
14
+ shareScope?: ShareScope;
15
15
  shared?: Shared;
16
16
  enhanced?: boolean;
17
17
  }
package/dist/index.mjs CHANGED
@@ -56875,27 +56875,39 @@ function SwcJsMinimizerPlugin_isObject(value) {
56875
56875
  }
56876
56876
  function getRawExtractCommentsOptions(extractComments) {
56877
56877
  const conditionStr = (condition)=>{
56878
- if (void 0 === condition || true === condition) return '@preserve|@lic|@cc_on|^\\**!';
56878
+ if (void 0 === condition || true === condition) return {
56879
+ source: '@preserve|@lic|@cc_on|^\\**!',
56880
+ flags: ''
56881
+ };
56879
56882
  if (false === condition) throw Error('unreachable');
56880
- return condition.source;
56883
+ return {
56884
+ source: condition.source,
56885
+ flags: condition.flags
56886
+ };
56881
56887
  };
56882
56888
  if ('boolean' == typeof extractComments) {
56883
56889
  if (!extractComments) return;
56890
+ const { source, flags } = conditionStr(extractComments);
56884
56891
  const res = {
56885
- condition: conditionStr(extractComments)
56892
+ condition: source,
56893
+ conditionFlags: flags
56886
56894
  };
56887
56895
  return res;
56888
56896
  }
56889
56897
  if (extractComments instanceof RegExp) {
56898
+ const { source, flags } = conditionStr(extractComments);
56890
56899
  const res = {
56891
- condition: extractComments.source
56900
+ condition: source,
56901
+ conditionFlags: flags
56892
56902
  };
56893
56903
  return res;
56894
56904
  }
56895
56905
  if (SwcJsMinimizerPlugin_isObject(extractComments)) {
56896
56906
  if (false === extractComments.condition) return;
56907
+ const { source, flags } = conditionStr(extractComments.condition);
56897
56908
  const res = {
56898
- condition: conditionStr(extractComments.condition),
56909
+ condition: source,
56910
+ conditionFlags: flags,
56899
56911
  banner: extractComments.banner
56900
56912
  };
56901
56913
  return res;
@@ -56968,7 +56980,7 @@ class WorkerPlugin extends RspackBuiltinPlugin {
56968
56980
  return createBuiltinPlugin(this.name, void 0);
56969
56981
  }
56970
56982
  constructor(chunkLoading, wasmLoading, module, workerPublicPath){
56971
- super(), WorkerPlugin_define_property(this, "chunkLoading", void 0), WorkerPlugin_define_property(this, "wasmLoading", void 0), WorkerPlugin_define_property(this, "module", void 0), WorkerPlugin_define_property(this, "workerPublicPath", void 0), WorkerPlugin_define_property(this, "name", void 0), this.chunkLoading = chunkLoading, this.wasmLoading = wasmLoading, this.module = module, this.workerPublicPath = workerPublicPath, this.name = external_rspack_wasi_browser_js_.BuiltinPluginName.WorkerPlugin;
56983
+ super(), WorkerPlugin_define_property(this, "chunkLoading", void 0), WorkerPlugin_define_property(this, "wasmLoading", void 0), WorkerPlugin_define_property(this, "module", void 0), WorkerPlugin_define_property(this, "workerPublicPath", void 0), WorkerPlugin_define_property(this, "name", void 0), WorkerPlugin_define_property(this, "affectedHooks", void 0), this.chunkLoading = chunkLoading, this.wasmLoading = wasmLoading, this.module = module, this.workerPublicPath = workerPublicPath, this.name = external_rspack_wasi_browser_js_.BuiltinPluginName.WorkerPlugin, this.affectedHooks = 'compilation';
56972
56984
  }
56973
56985
  }
56974
56986
  function ContextModuleFactory_define_property(obj, key, value) {
@@ -58153,7 +58165,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
58153
58165
  if ('object' == typeof rspackFuture) {
58154
58166
  D(rspackFuture, 'bundlerInfo', {});
58155
58167
  if ('object' == typeof rspackFuture.bundlerInfo) {
58156
- D(rspackFuture.bundlerInfo, 'version', "1.7.8");
58168
+ D(rspackFuture.bundlerInfo, 'version', "1.7.10");
58157
58169
  D(rspackFuture.bundlerInfo, 'bundler', 'rspack');
58158
58170
  D(rspackFuture.bundlerInfo, 'force', !library);
58159
58171
  }
@@ -60423,7 +60435,7 @@ class MultiStats {
60423
60435
  return obj;
60424
60436
  });
60425
60437
  if (childOptions.version) {
60426
- obj.rspackVersion = "1.7.8";
60438
+ obj.rspackVersion = "1.7.10";
60427
60439
  obj.version = "5.75.0";
60428
60440
  }
60429
60441
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
@@ -62263,7 +62275,7 @@ const SIMPLE_EXTRACTORS = {
62263
62275
  },
62264
62276
  version: (object)=>{
62265
62277
  object.version = "5.75.0";
62266
- object.rspackVersion = "1.7.8";
62278
+ object.rspackVersion = "1.7.10";
62267
62279
  },
62268
62280
  env: (object, _compilation, _context, { _env })=>{
62269
62281
  object.env = _env;
@@ -66750,6 +66762,9 @@ function SharePlugin_define_property(obj, key, value) {
66750
66762
  else obj[key] = value;
66751
66763
  return obj;
66752
66764
  }
66765
+ function validateShareScope(shareScope, enhanced, pluginName) {
66766
+ if (Array.isArray(shareScope) && shareScope.length > 1 && !enhanced) throw new Error(`[${pluginName}] shareScope as an array with multiple entries requires enhanced=true, got: ${JSON.stringify(shareScope)}`);
66767
+ }
66753
66768
  class SharePlugin {
66754
66769
  apply(compiler) {
66755
66770
  new ConsumeSharedPlugin({
@@ -66838,9 +66853,12 @@ class ContainerPlugin extends RspackBuiltinPlugin {
66838
66853
  }
66839
66854
  constructor(options){
66840
66855
  super(), ContainerPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ContainerPlugin), ContainerPlugin_define_property(this, "_options", void 0);
66856
+ const shareScope = options.shareScope || 'default';
66857
+ const enhanced = options.enhanced ?? false;
66858
+ validateShareScope(shareScope, enhanced, 'ContainerPlugin');
66841
66859
  this._options = {
66842
66860
  name: options.name,
66843
- shareScope: options.shareScope || 'default',
66861
+ shareScope,
66844
66862
  library: options.library || {
66845
66863
  type: 'var',
66846
66864
  name: options.name
@@ -66858,7 +66876,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
66858
66876
  ],
66859
66877
  name: item.name || void 0
66860
66878
  })),
66861
- enhanced: options.enhanced ?? false
66879
+ enhanced
66862
66880
  };
66863
66881
  }
66864
66882
  }
@@ -66902,20 +66920,24 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
66902
66920
  }
66903
66921
  constructor(options){
66904
66922
  super(), ContainerReferencePlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ContainerReferencePlugin), ContainerReferencePlugin_define_property(this, "_options", void 0);
66923
+ const enhanced = options.enhanced ?? false;
66924
+ if (options.shareScope) validateShareScope(options.shareScope, enhanced, 'ContainerReferencePlugin');
66925
+ const remotes = parseOptions(options.remotes, (item)=>({
66926
+ external: Array.isArray(item) ? item : [
66927
+ item
66928
+ ],
66929
+ shareScope: options.shareScope || 'default'
66930
+ }), (item)=>({
66931
+ external: Array.isArray(item.external) ? item.external : [
66932
+ item.external
66933
+ ],
66934
+ shareScope: item.shareScope || options.shareScope || 'default'
66935
+ }));
66936
+ for (const [, config] of remotes)validateShareScope(config.shareScope, enhanced, 'ContainerReferencePlugin');
66905
66937
  this._options = {
66906
66938
  remoteType: options.remoteType,
66907
- remotes: parseOptions(options.remotes, (item)=>({
66908
- external: Array.isArray(item) ? item : [
66909
- item
66910
- ],
66911
- shareScope: options.shareScope || 'default'
66912
- }), (item)=>({
66913
- external: Array.isArray(item.external) ? item.external : [
66914
- item.external
66915
- ],
66916
- shareScope: item.shareScope || options.shareScope || 'default'
66917
- })),
66918
- enhanced: options.enhanced ?? false
66939
+ remotes,
66940
+ enhanced
66919
66941
  };
66920
66942
  }
66921
66943
  }
@@ -66984,7 +67006,7 @@ function transformSync(source, options) {
66984
67006
  const _options = JSON.stringify(options || {});
66985
67007
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
66986
67008
  }
66987
- const exports_rspackVersion = "1.7.8";
67009
+ const exports_rspackVersion = "1.7.10";
66988
67010
  const exports_version = "5.75.0";
66989
67011
  const exports_WebpackError = Error;
66990
67012
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
@@ -1871,7 +1871,7 @@ export interface RawConsumeOptions {
1871
1871
  import?: string
1872
1872
  importResolved?: string
1873
1873
  shareKey: string
1874
- shareScope: string
1874
+ shareScope: string | Array<string>
1875
1875
  requiredVersion?: string | false | undefined
1876
1876
  packageName?: string
1877
1877
  strictVersion: boolean
@@ -1886,7 +1886,7 @@ export interface RawConsumeSharedPluginOptions {
1886
1886
 
1887
1887
  export interface RawContainerPluginOptions {
1888
1888
  name: string
1889
- shareScope: string
1889
+ shareScope: string | Array<string>
1890
1890
  library: JsLibraryOptions
1891
1891
  runtime?: false | string
1892
1892
  filename?: string
@@ -1897,7 +1897,7 @@ export interface RawContainerPluginOptions {
1897
1897
  export interface RawContainerReferencePluginOptions {
1898
1898
  remoteType: string
1899
1899
  remotes: Array<RawRemoteOptions>
1900
- shareScope?: string
1900
+ shareScope?: string | Array<string> | undefined | null
1901
1901
  enhanced: boolean
1902
1902
  }
1903
1903
 
@@ -2202,6 +2202,7 @@ export interface RawExternalsPresets {
2202
2202
  export interface RawExtractComments {
2203
2203
  banner?: string | boolean
2204
2204
  condition?: string
2205
+ conditionFlags?: string
2205
2206
  }
2206
2207
 
2207
2208
  export interface RawFallbackCacheGroupOptions {
@@ -2711,7 +2712,7 @@ export interface RawProgressPluginOptions {
2711
2712
  export interface RawProvideOptions {
2712
2713
  key: string
2713
2714
  shareKey: string
2714
- shareScope: string
2715
+ shareScope: string | Array<string>
2715
2716
  version?: string | false | undefined
2716
2717
  eager: boolean
2717
2718
  singleton?: boolean
@@ -2731,7 +2732,7 @@ export interface RawRemoteAliasTarget {
2731
2732
  export interface RawRemoteOptions {
2732
2733
  key: string
2733
2734
  external: Array<string>
2734
- shareScope: string
2735
+ shareScope: string | Array<string>
2735
2736
  }
2736
2737
 
2737
2738
  export interface RawResolveOptions {
Binary file
@@ -1,9 +1,10 @@
1
1
  import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/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 ConsumeSharedPluginOptions = {
5
6
  consumes: Consumes;
6
- shareScope?: string;
7
+ shareScope?: ShareScope;
7
8
  enhanced?: boolean;
8
9
  };
9
10
  export type Consumes = (ConsumesItem | ConsumesObject)[] | ConsumesObject;
@@ -17,7 +18,7 @@ export type ConsumesConfig = {
17
18
  packageName?: string;
18
19
  requiredVersion?: false | string;
19
20
  shareKey?: string;
20
- shareScope?: string;
21
+ shareScope?: ShareScope;
21
22
  singleton?: boolean;
22
23
  strictVersion?: boolean;
23
24
  };
@@ -26,7 +27,7 @@ export declare class ConsumeSharedPlugin extends RspackBuiltinPlugin {
26
27
  _options: {
27
28
  consumes: [string, {
28
29
  import: string | undefined;
29
- shareScope: string;
30
+ shareScope: ShareScope;
30
31
  shareKey: string;
31
32
  requiredVersion: string | false | undefined;
32
33
  strictVersion: boolean;
@@ -1,9 +1,10 @@
1
1
  import { type BuiltinPlugin, BuiltinPluginName, type RawProvideOptions } from '@rspack/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;
@@ -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
  };
@@ -15,18 +17,18 @@ export type SharedConfig = {
15
17
  packageName?: string;
16
18
  requiredVersion?: false | string;
17
19
  shareKey?: string;
18
- shareScope?: string;
20
+ shareScope?: ShareScope;
19
21
  singleton?: boolean;
20
22
  strictVersion?: boolean;
21
23
  version?: false | string;
22
24
  };
23
25
  export declare class SharePlugin {
24
- _shareScope: string | undefined;
26
+ _shareScope?: ShareScope;
25
27
  _consumes: {
26
28
  [x: string]: {
27
29
  import: string | false | undefined;
28
30
  shareKey: string;
29
- shareScope: string | undefined;
31
+ shareScope: ShareScope | undefined;
30
32
  requiredVersion: string | false | undefined;
31
33
  strictVersion: boolean | undefined;
32
34
  singleton: boolean | undefined;
@@ -37,7 +39,7 @@ export declare class SharePlugin {
37
39
  _provides: {
38
40
  [x: string]: {
39
41
  shareKey: string;
40
- shareScope: string | undefined;
42
+ shareScope: ShareScope | undefined;
41
43
  version: string | false | undefined;
42
44
  eager: boolean | undefined;
43
45
  singleton: boolean | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/browser",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "Rspack for running in the browser. This is still in early stage and may not follow the semver.",