@rspack/core 1.7.7 → 1.7.9

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.
@@ -162,6 +162,7 @@ export declare class Compilation {
162
162
  Iterable<Chunk>,
163
163
  Iterable<Module>
164
164
  ], void>;
165
+ beforeModuleIds: liteTapable.SyncHook<[Iterable<Module>]>;
165
166
  finishModules: liteTapable.AsyncSeriesHook<[Iterable<Module>], void>;
166
167
  chunkHash: liteTapable.SyncHook<[Chunk, Hash]>;
167
168
  chunkAsset: liteTapable.SyncHook<[Chunk, string]>;
@@ -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
@@ -1550,6 +1550,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1550
1550
  'chunks',
1551
1551
  'modules'
1552
1552
  ]),
1553
+ beforeModuleIds: new lite_tapable_namespaceObject.SyncHook([
1554
+ 'modules'
1555
+ ]),
1553
1556
  finishModules: new lite_tapable_namespaceObject.AsyncSeriesHook([
1554
1557
  'modules'
1555
1558
  ]),
@@ -4934,6 +4937,7 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4934
4937
  module;
4935
4938
  workerPublicPath;
4936
4939
  name = binding_.BuiltinPluginName.WorkerPlugin;
4940
+ affectedHooks = 'compilation';
4937
4941
  constructor(chunkLoading, wasmLoading, module1, workerPublicPath){
4938
4942
  super(), this.chunkLoading = chunkLoading, this.wasmLoading = wasmLoading, this.module = module1, this.workerPublicPath = workerPublicPath;
4939
4943
  }
@@ -5904,7 +5908,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5904
5908
  }, applyExperimentsDefaults = (experiments, { development })=>{
5905
5909
  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);
5906
5910
  }, applybundlerInfoDefaults = (rspackFuture, library)=>{
5907
- 'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.7"), D(rspackFuture.bundlerInfo, 'bundler', 'rspack'), D(rspackFuture.bundlerInfo, 'force', !library)));
5911
+ 'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.9"), D(rspackFuture.bundlerInfo, 'bundler', 'rspack'), D(rspackFuture.bundlerInfo, 'force', !library)));
5908
5912
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
5909
5913
  D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
5910
5914
  }, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, deferImport })=>{
@@ -7472,7 +7476,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7472
7476
  obj.children = this.stats.map((stat, idx)=>{
7473
7477
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
7474
7478
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
7475
- }), childOptions.version && (obj.rspackVersion = "1.7.7", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7479
+ }), childOptions.version && (obj.rspackVersion = "1.7.9", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7476
7480
  let mapError = (j, obj)=>({
7477
7481
  ...obj,
7478
7482
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8734,7 +8738,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
8734
8738
  object.hash = context.getStatsCompilation(compilation).hash;
8735
8739
  },
8736
8740
  version: (object)=>{
8737
- object.version = "5.75.0", object.rspackVersion = "1.7.7";
8741
+ object.version = "5.75.0", object.rspackVersion = "1.7.9";
8738
8742
  },
8739
8743
  env: (object, _compilation, _context, { _env })=>{
8740
8744
  object.env = _env;
@@ -10459,7 +10463,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
10459
10463
  });
10460
10464
  }
10461
10465
  }
10462
- let CORE_VERSION = "1.7.7", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
10466
+ let CORE_VERSION = "1.7.9", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
10463
10467
 
10464
10468
  Help:
10465
10469
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -11333,6 +11337,26 @@ Help:
11333
11337
  return queried.promise(getCompiler2().__internal__get_compilation().chunks, getCompiler2().__internal__get_compilation().modules);
11334
11338
  };
11335
11339
  }),
11340
+ registerCompilationBeforeModuleIdsTaps: createTap2(binding_default().RegisterJsTapKind.CompilationBeforeModuleIds, function() {
11341
+ return getCompiler2().__internal__get_compilation().hooks.beforeModuleIds;
11342
+ }, function(queried) {
11343
+ return function(arg) {
11344
+ let compilation = getCompiler2().__internal__get_compilation(), assignments = new Map(), modulesByIdentifier = new Map();
11345
+ for (let module1 of compilation.modules)modulesByIdentifier.set(module1.identifier(), module1);
11346
+ let proxiedModules = arg.modules.map((m)=>new Proxy(modulesByIdentifier.get(m.identifier), {
11347
+ get (target, prop) {
11348
+ if ('id' === prop) return assignments.get(m.identifier) ?? null;
11349
+ if ('identifier' === prop) return m.identifier;
11350
+ let value = Reflect.get(target, prop);
11351
+ return 'function' == typeof value ? value.bind(target) : value;
11352
+ },
11353
+ set: (_target, prop, value)=>'id' === prop && ('string' == typeof value || 'number' == typeof value) && (assignments.set(m.identifier, value), !0)
11354
+ }));
11355
+ return queried.call(proxiedModules), {
11356
+ assignments: Object.fromEntries(assignments.entries())
11357
+ };
11358
+ };
11359
+ }),
11336
11360
  registerCompilationChunkHashTaps: createTap2(binding_default().RegisterJsTapKind.CompilationChunkHash, function() {
11337
11361
  return getCompiler2().__internal__get_compilation().hooks.chunkHash;
11338
11362
  }, function(queried) {
@@ -12112,6 +12136,9 @@ Help:
12112
12136
  return createBuiltinPlugin(this.name, rawOptions);
12113
12137
  }
12114
12138
  }
12139
+ function validateShareScope(shareScope, enhanced, pluginName) {
12140
+ 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)}`);
12141
+ }
12115
12142
  class SharePlugin {
12116
12143
  _shareScope;
12117
12144
  _consumes;
@@ -12166,9 +12193,11 @@ Help:
12166
12193
  name = binding_.BuiltinPluginName.ContainerPlugin;
12167
12194
  _options;
12168
12195
  constructor(options){
12169
- super(), this._options = {
12196
+ super();
12197
+ const shareScope = options.shareScope || 'default', enhanced = options.enhanced ?? !1;
12198
+ validateShareScope(shareScope, enhanced, 'ContainerPlugin'), this._options = {
12170
12199
  name: options.name,
12171
- shareScope: options.shareScope || 'default',
12200
+ shareScope,
12172
12201
  library: options.library || {
12173
12202
  type: 'var',
12174
12203
  name: options.name
@@ -12186,7 +12215,7 @@ Help:
12186
12215
  ],
12187
12216
  name: item.name || void 0
12188
12217
  })),
12189
- enhanced: options.enhanced ?? !1
12218
+ enhanced
12190
12219
  };
12191
12220
  }
12192
12221
  raw(compiler) {
@@ -12211,20 +12240,25 @@ Help:
12211
12240
  name = binding_.BuiltinPluginName.ContainerReferencePlugin;
12212
12241
  _options;
12213
12242
  constructor(options){
12214
- super(), this._options = {
12243
+ super();
12244
+ const enhanced = options.enhanced ?? !1;
12245
+ options.shareScope && validateShareScope(options.shareScope, enhanced, 'ContainerReferencePlugin');
12246
+ const remotes = parseOptions(options.remotes, (item)=>({
12247
+ external: Array.isArray(item) ? item : [
12248
+ item
12249
+ ],
12250
+ shareScope: options.shareScope || 'default'
12251
+ }), (item)=>({
12252
+ external: Array.isArray(item.external) ? item.external : [
12253
+ item.external
12254
+ ],
12255
+ shareScope: item.shareScope || options.shareScope || 'default'
12256
+ }));
12257
+ for (const [, config] of remotes)validateShareScope(config.shareScope, enhanced, 'ContainerReferencePlugin');
12258
+ this._options = {
12215
12259
  remoteType: options.remoteType,
12216
- remotes: parseOptions(options.remotes, (item)=>({
12217
- external: Array.isArray(item) ? item : [
12218
- item
12219
- ],
12220
- shareScope: options.shareScope || 'default'
12221
- }), (item)=>({
12222
- external: Array.isArray(item.external) ? item.external : [
12223
- item.external
12224
- ],
12225
- shareScope: item.shareScope || options.shareScope || 'default'
12226
- })),
12227
- enhanced: options.enhanced ?? !1
12260
+ remotes,
12261
+ enhanced
12228
12262
  };
12229
12263
  }
12230
12264
  raw(compiler) {
@@ -12257,7 +12291,7 @@ Help:
12257
12291
  let _options = JSON.stringify(options || {});
12258
12292
  return binding_default().transform(source, _options);
12259
12293
  }
12260
- let exports_rspackVersion = "1.7.7", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12294
+ let exports_rspackVersion = "1.7.9", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12261
12295
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12262
12296
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12263
12297
  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.7",
3
+ "version": "1.7.9",
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.7"
61
+ "@rspack/binding": "1.7.9"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@swc/helpers": ">=0.5.1"