@rspack/core 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.js CHANGED
@@ -4894,23 +4894,37 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4894
4894
  extractComments: function(extractComments) {
4895
4895
  var value;
4896
4896
  let type, conditionStr = (condition)=>{
4897
- if (void 0 === condition || !0 === condition) return '@preserve|@lic|@cc_on|^\\**!';
4897
+ if (void 0 === condition || !0 === condition) return {
4898
+ source: '@preserve|@lic|@cc_on|^\\**!',
4899
+ flags: ''
4900
+ };
4898
4901
  if (!1 === condition) throw Error('unreachable');
4899
- return condition.source;
4902
+ return {
4903
+ source: condition.source,
4904
+ flags: condition.flags
4905
+ };
4900
4906
  };
4901
4907
  if ('boolean' == typeof extractComments) {
4902
4908
  if (!extractComments) return;
4909
+ let { source, flags } = conditionStr(extractComments);
4903
4910
  return {
4904
- condition: conditionStr(extractComments)
4911
+ condition: source,
4912
+ conditionFlags: flags
4913
+ };
4914
+ }
4915
+ if (extractComments instanceof RegExp) {
4916
+ let { source, flags } = conditionStr(extractComments);
4917
+ return {
4918
+ condition: source,
4919
+ conditionFlags: flags
4905
4920
  };
4906
4921
  }
4907
- if (extractComments instanceof RegExp) return {
4908
- condition: extractComments.source
4909
- };
4910
4922
  if (type = typeof (value = extractComments), null != value && ('object' === type || 'function' === type)) {
4911
4923
  if (!1 === extractComments.condition) return;
4924
+ let { source, flags } = conditionStr(extractComments.condition);
4912
4925
  return {
4913
- condition: conditionStr(extractComments.condition),
4926
+ condition: source,
4927
+ conditionFlags: flags,
4914
4928
  banner: extractComments.banner
4915
4929
  };
4916
4930
  }
@@ -4937,6 +4951,7 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4937
4951
  module;
4938
4952
  workerPublicPath;
4939
4953
  name = binding_.BuiltinPluginName.WorkerPlugin;
4954
+ affectedHooks = 'compilation';
4940
4955
  constructor(chunkLoading, wasmLoading, module1, workerPublicPath){
4941
4956
  super(), this.chunkLoading = chunkLoading, this.wasmLoading = wasmLoading, this.module = module1, this.workerPublicPath = workerPublicPath;
4942
4957
  }
@@ -5907,7 +5922,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5907
5922
  }, applyExperimentsDefaults = (experiments, { development })=>{
5908
5923
  F(experiments, 'cache', ()=>development), D(experiments, 'futureDefaults', !1), D(experiments, 'lazyCompilation', !1), D(experiments, 'asyncWebAssembly', experiments.futureDefaults), D(experiments, 'css', !!experiments.futureDefaults || void 0), D(experiments, 'topLevelAwait', !0), D(experiments, 'deferImport', !1), D(experiments, 'buildHttp', void 0), experiments.buildHttp && 'object' == typeof experiments.buildHttp && D(experiments.buildHttp, 'upgrade', !1), D(experiments, 'incremental', {}), 'object' == typeof experiments.incremental && (D(experiments.incremental, 'silent', !0), D(experiments.incremental, 'make', !0), D(experiments.incremental, 'inferAsyncModules', !0), D(experiments.incremental, 'providedExports', !0), D(experiments.incremental, 'dependenciesDiagnostics', !0), D(experiments.incremental, 'sideEffects', !0), D(experiments.incremental, 'buildChunkGraph', !1), D(experiments.incremental, 'moduleIds', !0), D(experiments.incremental, 'chunkIds', !0), D(experiments.incremental, 'modulesHashes', !0), D(experiments.incremental, 'modulesCodegen', !0), D(experiments.incremental, 'modulesRuntimeRequirements', !0), D(experiments.incremental, 'chunksRuntimeRequirements', !0), D(experiments.incremental, 'chunksHashes', !0), D(experiments.incremental, 'chunksRender', !0), D(experiments.incremental, 'emitAssets', !0)), D(experiments, 'rspackFuture', {}), D(experiments, 'parallelLoader', !1), D(experiments, 'useInputFileSystem', !1), D(experiments, 'inlineConst', !0), D(experiments, 'inlineEnum', !1), D(experiments, 'typeReexportsPresence', !1), D(experiments, 'lazyBarrel', !0);
5909
5924
  }, applybundlerInfoDefaults = (rspackFuture, library)=>{
5910
- 'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.8"), D(rspackFuture.bundlerInfo, 'bundler', 'rspack'), D(rspackFuture.bundlerInfo, 'force', !library)));
5925
+ 'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.10"), D(rspackFuture.bundlerInfo, 'bundler', 'rspack'), D(rspackFuture.bundlerInfo, 'force', !library)));
5911
5926
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
5912
5927
  D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
5913
5928
  }, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, deferImport })=>{
@@ -7475,7 +7490,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7475
7490
  obj.children = this.stats.map((stat, idx)=>{
7476
7491
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
7477
7492
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
7478
- }), childOptions.version && (obj.rspackVersion = "1.7.8", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7493
+ }), childOptions.version && (obj.rspackVersion = "1.7.10", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7479
7494
  let mapError = (j, obj)=>({
7480
7495
  ...obj,
7481
7496
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8737,7 +8752,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
8737
8752
  object.hash = context.getStatsCompilation(compilation).hash;
8738
8753
  },
8739
8754
  version: (object)=>{
8740
- object.version = "5.75.0", object.rspackVersion = "1.7.8";
8755
+ object.version = "5.75.0", object.rspackVersion = "1.7.10";
8741
8756
  },
8742
8757
  env: (object, _compilation, _context, { _env })=>{
8743
8758
  object.env = _env;
@@ -10462,7 +10477,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
10462
10477
  });
10463
10478
  }
10464
10479
  }
10465
- let CORE_VERSION = "1.7.8", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
10480
+ let CORE_VERSION = "1.7.10", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
10466
10481
 
10467
10482
  Help:
10468
10483
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -12135,6 +12150,9 @@ Help:
12135
12150
  return createBuiltinPlugin(this.name, rawOptions);
12136
12151
  }
12137
12152
  }
12153
+ function validateShareScope(shareScope, enhanced, pluginName) {
12154
+ if (Array.isArray(shareScope) && shareScope.length > 1 && !enhanced) throw Error(`[${pluginName}] shareScope as an array with multiple entries requires enhanced=true, got: ${JSON.stringify(shareScope)}`);
12155
+ }
12138
12156
  class SharePlugin {
12139
12157
  _shareScope;
12140
12158
  _consumes;
@@ -12189,9 +12207,11 @@ Help:
12189
12207
  name = binding_.BuiltinPluginName.ContainerPlugin;
12190
12208
  _options;
12191
12209
  constructor(options){
12192
- super(), this._options = {
12210
+ super();
12211
+ const shareScope = options.shareScope || 'default', enhanced = options.enhanced ?? !1;
12212
+ validateShareScope(shareScope, enhanced, 'ContainerPlugin'), this._options = {
12193
12213
  name: options.name,
12194
- shareScope: options.shareScope || 'default',
12214
+ shareScope,
12195
12215
  library: options.library || {
12196
12216
  type: 'var',
12197
12217
  name: options.name
@@ -12209,7 +12229,7 @@ Help:
12209
12229
  ],
12210
12230
  name: item.name || void 0
12211
12231
  })),
12212
- enhanced: options.enhanced ?? !1
12232
+ enhanced
12213
12233
  };
12214
12234
  }
12215
12235
  raw(compiler) {
@@ -12234,20 +12254,25 @@ Help:
12234
12254
  name = binding_.BuiltinPluginName.ContainerReferencePlugin;
12235
12255
  _options;
12236
12256
  constructor(options){
12237
- super(), this._options = {
12257
+ super();
12258
+ const enhanced = options.enhanced ?? !1;
12259
+ options.shareScope && validateShareScope(options.shareScope, enhanced, 'ContainerReferencePlugin');
12260
+ const remotes = parseOptions(options.remotes, (item)=>({
12261
+ external: Array.isArray(item) ? item : [
12262
+ item
12263
+ ],
12264
+ shareScope: options.shareScope || 'default'
12265
+ }), (item)=>({
12266
+ external: Array.isArray(item.external) ? item.external : [
12267
+ item.external
12268
+ ],
12269
+ shareScope: item.shareScope || options.shareScope || 'default'
12270
+ }));
12271
+ for (const [, config] of remotes)validateShareScope(config.shareScope, enhanced, 'ContainerReferencePlugin');
12272
+ this._options = {
12238
12273
  remoteType: options.remoteType,
12239
- remotes: parseOptions(options.remotes, (item)=>({
12240
- external: Array.isArray(item) ? item : [
12241
- item
12242
- ],
12243
- shareScope: options.shareScope || 'default'
12244
- }), (item)=>({
12245
- external: Array.isArray(item.external) ? item.external : [
12246
- item.external
12247
- ],
12248
- shareScope: item.shareScope || options.shareScope || 'default'
12249
- })),
12250
- enhanced: options.enhanced ?? !1
12274
+ remotes,
12275
+ enhanced
12251
12276
  };
12252
12277
  }
12253
12278
  raw(compiler) {
@@ -12280,7 +12305,7 @@ Help:
12280
12305
  let _options = JSON.stringify(options || {});
12281
12306
  return binding_default().transform(source, _options);
12282
12307
  }
12283
- let exports_rspackVersion = "1.7.8", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12308
+ let exports_rspackVersion = "1.7.10", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12284
12309
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12285
12310
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12286
12311
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -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/core",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -58,7 +58,7 @@
58
58
  "dependencies": {
59
59
  "@module-federation/runtime-tools": "0.22.0",
60
60
  "@rspack/lite-tapable": "1.1.0",
61
- "@rspack/binding": "1.7.8"
61
+ "@rspack/binding": "1.7.10"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@swc/helpers": ">=0.5.1"