@rspack-debug/browser 2.0.0-beta.0 → 2.0.0-beta.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/dist/Compilation.d.ts +1 -0
- package/dist/NormalModule.d.ts +0 -1
- package/dist/RuntimeGlobals.d.ts +1 -1
- package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +1 -1
- package/dist/config/types.d.ts +31 -5
- package/dist/container/ModuleFederationManifestPlugin.d.ts +10 -3
- package/dist/container/ModuleFederationPlugin.d.ts +17 -1
- package/dist/exports.d.ts +4 -1
- package/dist/index.js +886 -399
- package/dist/napi-binding.d.ts +98 -34
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
- package/dist/sharing/ConsumeSharedPlugin.d.ts +13 -0
- package/dist/sharing/IndependentSharedPlugin.d.ts +35 -0
- package/dist/sharing/ProvideSharedPlugin.d.ts +19 -0
- package/dist/sharing/SharePlugin.d.ts +36 -0
- package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
- package/dist/sharing/TreeShakingSharedPlugin.d.ts +16 -0
- package/dist/sharing/utils.d.ts +1 -0
- package/dist/util/createHash.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2697,14 +2697,6 @@ __webpack_require__.add({
|
|
|
2697
2697
|
isDeepStrictEqual: isDeepStrictEqual
|
|
2698
2698
|
};
|
|
2699
2699
|
},
|
|
2700
|
-
"../../node_modules/.pnpm/async-function@1.0.0/node_modules/async-function/index.js" (module) {
|
|
2701
|
-
const cached = (async function() {}).constructor;
|
|
2702
|
-
module.exports = ()=>cached;
|
|
2703
|
-
},
|
|
2704
|
-
"../../node_modules/.pnpm/async-generator-function@1.0.0/node_modules/async-generator-function/index.js" (module) {
|
|
2705
|
-
const cached = (async function*() {}).constructor;
|
|
2706
|
-
module.exports = ()=>cached;
|
|
2707
|
-
},
|
|
2708
2700
|
"../../node_modules/.pnpm/bn.js@4.12.2/node_modules/bn.js/lib/bn.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2709
2701
|
module = __webpack_require__.nmd(module);
|
|
2710
2702
|
(function(module, exports) {
|
|
@@ -9837,7 +9829,7 @@ __webpack_require__.add({
|
|
|
9837
9829
|
module.exports = "u" > typeof Reflect && Reflect && Reflect.apply;
|
|
9838
9830
|
},
|
|
9839
9831
|
"../../node_modules/.pnpm/call-bind@1.0.8/node_modules/call-bind/callBound.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
9840
|
-
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.
|
|
9832
|
+
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js");
|
|
9841
9833
|
var callBind = __webpack_require__("../../node_modules/.pnpm/call-bind@1.0.8/node_modules/call-bind/index.js");
|
|
9842
9834
|
var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
|
9843
9835
|
module.exports = function(name, allowMissing) {
|
|
@@ -9862,7 +9854,7 @@ __webpack_require__.add({
|
|
|
9862
9854
|
else module.exports.apply = applyBind;
|
|
9863
9855
|
},
|
|
9864
9856
|
"../../node_modules/.pnpm/call-bound@1.0.4/node_modules/call-bound/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
9865
|
-
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.
|
|
9857
|
+
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js");
|
|
9866
9858
|
var callBindBasic = __webpack_require__("../../node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js");
|
|
9867
9859
|
var $indexOf = callBindBasic([
|
|
9868
9860
|
GetIntrinsic('%String.prototype.indexOf%')
|
|
@@ -15340,11 +15332,7 @@ __webpack_require__.add({
|
|
|
15340
15332
|
var implementation = __webpack_require__("../../node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js");
|
|
15341
15333
|
module.exports = Function.prototype.bind || implementation;
|
|
15342
15334
|
},
|
|
15343
|
-
"../../node_modules/.pnpm/
|
|
15344
|
-
const cached = (function*() {}).constructor;
|
|
15345
|
-
module.exports = ()=>cached;
|
|
15346
|
-
},
|
|
15347
|
-
"../../node_modules/.pnpm/get-intrinsic@1.3.1/node_modules/get-intrinsic/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
15335
|
+
"../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
15348
15336
|
var undefined;
|
|
15349
15337
|
var $Object = __webpack_require__("../../node_modules/.pnpm/es-object-atoms@1.1.1/node_modules/es-object-atoms/index.js");
|
|
15350
15338
|
var $Error = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.js");
|
|
@@ -15361,6 +15349,12 @@ __webpack_require__.add({
|
|
|
15361
15349
|
var pow = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js");
|
|
15362
15350
|
var round = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js");
|
|
15363
15351
|
var sign = __webpack_require__("../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js");
|
|
15352
|
+
var $Function = Function;
|
|
15353
|
+
var getEvalledConstructor = function(expressionSyntax) {
|
|
15354
|
+
try {
|
|
15355
|
+
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
15356
|
+
} catch (e) {}
|
|
15357
|
+
};
|
|
15364
15358
|
var $gOPD = __webpack_require__("../../node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/index.js");
|
|
15365
15359
|
var $defineProperty = __webpack_require__("../../node_modules/.pnpm/es-define-property@1.0.1/node_modules/es-define-property/index.js");
|
|
15366
15360
|
var throwTypeError = function() {
|
|
@@ -15415,7 +15409,7 @@ __webpack_require__.add({
|
|
|
15415
15409
|
'%Float32Array%': "u" < typeof Float32Array ? undefined : Float32Array,
|
|
15416
15410
|
'%Float64Array%': "u" < typeof Float64Array ? undefined : Float64Array,
|
|
15417
15411
|
'%FinalizationRegistry%': "u" < typeof FinalizationRegistry ? undefined : FinalizationRegistry,
|
|
15418
|
-
'%Function%': Function,
|
|
15412
|
+
'%Function%': $Function,
|
|
15419
15413
|
'%GeneratorFunction%': needsEval,
|
|
15420
15414
|
'%Int8Array%': "u" < typeof Int8Array ? undefined : Int8Array,
|
|
15421
15415
|
'%Int16Array%': "u" < typeof Int16Array ? undefined : Int16Array,
|
|
@@ -15475,14 +15469,11 @@ __webpack_require__.add({
|
|
|
15475
15469
|
var errorProto = getProto(getProto(e));
|
|
15476
15470
|
INTRINSICS['%Error.prototype%'] = errorProto;
|
|
15477
15471
|
}
|
|
15478
|
-
var getAsyncFunction = __webpack_require__("../../node_modules/.pnpm/async-function@1.0.0/node_modules/async-function/index.js");
|
|
15479
|
-
var getGeneratorFunction = __webpack_require__("../../node_modules/.pnpm/generator-function@2.0.0/node_modules/generator-function/index.js");
|
|
15480
|
-
var getAsyncGeneratorFunction = __webpack_require__("../../node_modules/.pnpm/async-generator-function@1.0.0/node_modules/async-generator-function/index.js");
|
|
15481
15472
|
var doEval = function doEval(name) {
|
|
15482
15473
|
var value;
|
|
15483
|
-
if ('%AsyncFunction%' === name) value =
|
|
15484
|
-
else if ('%GeneratorFunction%' === name) value =
|
|
15485
|
-
else if ('%AsyncGeneratorFunction%' === name) value =
|
|
15474
|
+
if ('%AsyncFunction%' === name) value = getEvalledConstructor('async function () {}');
|
|
15475
|
+
else if ('%GeneratorFunction%' === name) value = getEvalledConstructor('function* () {}');
|
|
15476
|
+
else if ('%AsyncGeneratorFunction%' === name) value = getEvalledConstructor('async function* () {}');
|
|
15486
15477
|
else if ('%AsyncGenerator%' === name) {
|
|
15487
15478
|
var fn = doEval('%AsyncGeneratorFunction%');
|
|
15488
15479
|
if (fn) value = fn.prototype;
|
|
@@ -28610,7 +28601,7 @@ __webpack_require__.add({
|
|
|
28610
28601
|
};
|
|
28611
28602
|
},
|
|
28612
28603
|
"../../node_modules/.pnpm/set-function-length@1.2.2/node_modules/set-function-length/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
28613
|
-
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.
|
|
28604
|
+
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js");
|
|
28614
28605
|
var define1 = __webpack_require__("../../node_modules/.pnpm/define-data-property@1.1.4/node_modules/define-data-property/index.js");
|
|
28615
28606
|
var hasDescriptors = __webpack_require__("../../node_modules/.pnpm/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.js")();
|
|
28616
28607
|
var gOPD = __webpack_require__("../../node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/index.js");
|
|
@@ -29480,7 +29471,7 @@ __webpack_require__.add({
|
|
|
29480
29471
|
};
|
|
29481
29472
|
},
|
|
29482
29473
|
"../../node_modules/.pnpm/side-channel-map@1.0.1/node_modules/side-channel-map/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
29483
|
-
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.
|
|
29474
|
+
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js");
|
|
29484
29475
|
var callBound = __webpack_require__("../../node_modules/.pnpm/call-bound@1.0.4/node_modules/call-bound/index.js");
|
|
29485
29476
|
var inspect = __webpack_require__("../../node_modules/.pnpm/object-inspect@1.13.4/node_modules/object-inspect/index.js");
|
|
29486
29477
|
var $TypeError = __webpack_require__("../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.js");
|
|
@@ -29520,7 +29511,7 @@ __webpack_require__.add({
|
|
|
29520
29511
|
};
|
|
29521
29512
|
},
|
|
29522
29513
|
"../../node_modules/.pnpm/side-channel-weakmap@1.0.2/node_modules/side-channel-weakmap/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
29523
|
-
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.
|
|
29514
|
+
var GetIntrinsic = __webpack_require__("../../node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js");
|
|
29524
29515
|
var callBound = __webpack_require__("../../node_modules/.pnpm/call-bound@1.0.4/node_modules/call-bound/index.js");
|
|
29525
29516
|
var inspect = __webpack_require__("../../node_modules/.pnpm/object-inspect@1.13.4/node_modules/object-inspect/index.js");
|
|
29526
29517
|
var getSideChannelMap = __webpack_require__("../../node_modules/.pnpm/side-channel-map@1.0.1/node_modules/side-channel-map/index.js");
|
|
@@ -51734,6 +51725,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
51734
51725
|
'chunks',
|
|
51735
51726
|
'modules'
|
|
51736
51727
|
]),
|
|
51728
|
+
beforeModuleIds: new SyncHook([
|
|
51729
|
+
'modules'
|
|
51730
|
+
]),
|
|
51737
51731
|
finishModules: new AsyncSeriesHook([
|
|
51738
51732
|
'modules'
|
|
51739
51733
|
]),
|
|
@@ -53181,11 +53175,6 @@ const getSwcLoaderOptions = (o, composeOptions)=>{
|
|
|
53181
53175
|
const { rspackExperiments } = options;
|
|
53182
53176
|
if (rspackExperiments) {
|
|
53183
53177
|
if (rspackExperiments.import || rspackExperiments.pluginImport) rspackExperiments.import = resolvePluginImport(rspackExperiments.import || rspackExperiments.pluginImport);
|
|
53184
|
-
if (rspackExperiments.collectTypeScriptInfo) {
|
|
53185
|
-
deprecate('`rspackExperiments.collectTypeScriptInfo` is deprecated and will be removed in Rspack v2.0. Use top-level `collectTypeScriptInfo` instead.');
|
|
53186
|
-
if (!options.collectTypeScriptInfo) options.collectTypeScriptInfo = resolveCollectTypeScriptInfo(rspackExperiments.collectTypeScriptInfo);
|
|
53187
|
-
delete rspackExperiments.collectTypeScriptInfo;
|
|
53188
|
-
}
|
|
53189
53178
|
}
|
|
53190
53179
|
}
|
|
53191
53180
|
return options;
|
|
@@ -53288,35 +53277,6 @@ Object.defineProperty(external_rspack_wasi_browser_js_["default"].NormalModule.p
|
|
|
53288
53277
|
return this._emitFile(filename, SourceAdapter.toBinding(source), assetInfo);
|
|
53289
53278
|
}
|
|
53290
53279
|
});
|
|
53291
|
-
const createFakeHook = (fakeHook, message, code)=>Object.freeze(Object.assign(message && code ? deprecateAllProperties(fakeHook, message, code) : fakeHook, {
|
|
53292
|
-
_fakeHook: true
|
|
53293
|
-
}));
|
|
53294
|
-
const deprecateAllProperties = (obj, message, code)=>{
|
|
53295
|
-
const newObj = {};
|
|
53296
|
-
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
53297
|
-
for (const name of Object.keys(descriptors)){
|
|
53298
|
-
const descriptor = descriptors[name];
|
|
53299
|
-
if ('function' == typeof descriptor.value) Object.defineProperty(newObj, name, {
|
|
53300
|
-
...descriptor,
|
|
53301
|
-
value: util_0_default().deprecate(descriptor.value, message, code)
|
|
53302
|
-
});
|
|
53303
|
-
else if (descriptor.get || descriptor.set) Object.defineProperty(newObj, name, {
|
|
53304
|
-
...descriptor,
|
|
53305
|
-
get: descriptor.get && util_0_default().deprecate(descriptor.get, message, code),
|
|
53306
|
-
set: descriptor.set && util_0_default().deprecate(descriptor.set, message, code)
|
|
53307
|
-
});
|
|
53308
|
-
else {
|
|
53309
|
-
let value = descriptor.value;
|
|
53310
|
-
Object.defineProperty(newObj, name, {
|
|
53311
|
-
configurable: descriptor.configurable,
|
|
53312
|
-
enumerable: descriptor.enumerable,
|
|
53313
|
-
get: util_0_default().deprecate(()=>value, message, code),
|
|
53314
|
-
set: descriptor.writable ? util_0_default().deprecate((v)=>value = v, message, code) : void 0
|
|
53315
|
-
});
|
|
53316
|
-
}
|
|
53317
|
-
}
|
|
53318
|
-
return newObj;
|
|
53319
|
-
};
|
|
53320
53280
|
Object.defineProperty(external_rspack_wasi_browser_js_["default"].NormalModule, 'getCompilationHooks', {
|
|
53321
53281
|
enumerable: true,
|
|
53322
53282
|
configurable: true,
|
|
@@ -53330,14 +53290,6 @@ Object.defineProperty(external_rspack_wasi_browser_js_["default"].NormalModule,
|
|
|
53330
53290
|
'loaderContext',
|
|
53331
53291
|
'module'
|
|
53332
53292
|
]),
|
|
53333
|
-
readResourceForScheme: new HookMap((scheme)=>{
|
|
53334
|
-
const hook = hooks.readResource.for(scheme);
|
|
53335
|
-
return createFakeHook({
|
|
53336
|
-
tap: (options, fn)=>hook.tap(options, (loaderContext)=>fn(loaderContext.resource)),
|
|
53337
|
-
tapAsync: (options, fn)=>hook.tapAsync(options, (loaderContext, callback)=>fn(loaderContext.resource, callback)),
|
|
53338
|
-
tapPromise: (options, fn)=>hook.tapPromise(options, (loaderContext)=>fn(loaderContext.resource))
|
|
53339
|
-
});
|
|
53340
|
-
}),
|
|
53341
53293
|
readResource: new HookMap(()=>new AsyncSeriesBailHook([
|
|
53342
53294
|
'loaderContext'
|
|
53343
53295
|
]))
|
|
@@ -53714,24 +53666,6 @@ class BulkUpdateDecorator extends Hash {
|
|
|
53714
53666
|
return result;
|
|
53715
53667
|
}
|
|
53716
53668
|
}
|
|
53717
|
-
class DebugHash extends Hash {
|
|
53718
|
-
string;
|
|
53719
|
-
constructor(){
|
|
53720
|
-
super();
|
|
53721
|
-
this.string = '';
|
|
53722
|
-
}
|
|
53723
|
-
update(data) {
|
|
53724
|
-
let normalizedData;
|
|
53725
|
-
normalizedData = createHash_Buffer.isBuffer(data) ? data.toString('utf-8') : data;
|
|
53726
|
-
if (normalizedData.startsWith('debug-digest-')) normalizedData = createHash_Buffer.from(normalizedData.slice(13), 'hex').toString();
|
|
53727
|
-
this.string += `[${normalizedData}](${new Error().stack?.split('\n', 3)[2]})\n`;
|
|
53728
|
-
return this;
|
|
53729
|
-
}
|
|
53730
|
-
digest(encoding) {
|
|
53731
|
-
const result = `debug-digest-${createHash_Buffer.from(this.string).toString('hex')}`;
|
|
53732
|
-
return encoding ? result : createHash_Buffer.from(result);
|
|
53733
|
-
}
|
|
53734
|
-
}
|
|
53735
53669
|
class WasmHashAdapter extends Hash {
|
|
53736
53670
|
wasmHash;
|
|
53737
53671
|
constructor(wasmHash){
|
|
@@ -53750,8 +53684,6 @@ class WasmHashAdapter extends Hash {
|
|
|
53750
53684
|
const createHash_createHash = (algorithm)=>{
|
|
53751
53685
|
if ('function' == typeof algorithm) return new BulkUpdateDecorator(()=>new algorithm());
|
|
53752
53686
|
switch(algorithm){
|
|
53753
|
-
case 'debug':
|
|
53754
|
-
return new DebugHash();
|
|
53755
53687
|
case 'xxhash64':
|
|
53756
53688
|
{
|
|
53757
53689
|
const hash = hash_xxhash64();
|
|
@@ -55019,7 +54951,6 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
55019
54951
|
exportsPresence: false === parser.exportsPresence ? 'false' : parser.exportsPresence,
|
|
55020
54952
|
importExportsPresence: false === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
|
|
55021
54953
|
reexportExportsPresence: false === parser.reexportExportsPresence ? 'false' : parser.reexportExportsPresence,
|
|
55022
|
-
strictExportPresence: parser.strictExportPresence,
|
|
55023
54954
|
worker: 'boolean' == typeof parser.worker ? parser.worker ? [
|
|
55024
54955
|
'...'
|
|
55025
54956
|
] : [] : parser.worker,
|
|
@@ -55053,7 +54984,8 @@ function getRawAssetParserDataUrl(dataUrlCondition) {
|
|
|
55053
54984
|
function getRawCssParserOptions(parser) {
|
|
55054
54985
|
return {
|
|
55055
54986
|
namedExports: parser.namedExports,
|
|
55056
|
-
url: parser.url
|
|
54987
|
+
url: parser.url,
|
|
54988
|
+
resolveImport: parser.resolveImport
|
|
55057
54989
|
};
|
|
55058
54990
|
}
|
|
55059
54991
|
function getRawJsonParserOptions(parser) {
|
|
@@ -57584,7 +57516,7 @@ const applyRspackOptionsDefaults = (options)=>{
|
|
|
57584
57516
|
if ('function' != typeof options.entry) for (const key of Object.keys(options.entry))F(options.entry[key], 'import', ()=>[
|
|
57585
57517
|
'./src'
|
|
57586
57518
|
]);
|
|
57587
|
-
F(options, 'devtool', ()=>development ? '
|
|
57519
|
+
F(options, 'devtool', ()=>development ? 'cheap-module-source-map' : false);
|
|
57588
57520
|
D(options, 'watch', false);
|
|
57589
57521
|
D(options, 'lazyCompilation', false);
|
|
57590
57522
|
D(options, 'bail', false);
|
|
@@ -57697,8 +57629,8 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, { deferImport })=>{
|
|
|
57697
57629
|
D(parserOptions, 'unknownContextCritical', true);
|
|
57698
57630
|
D(parserOptions, 'wrappedContextCritical', false);
|
|
57699
57631
|
D(parserOptions, 'wrappedContextRegExp', /.*/);
|
|
57700
|
-
D(parserOptions, '
|
|
57701
|
-
D(parserOptions, 'requireAsExpression',
|
|
57632
|
+
D(parserOptions, 'exportsPresence', 'error');
|
|
57633
|
+
D(parserOptions, 'requireAsExpression', true);
|
|
57702
57634
|
D(parserOptions, 'requireAlias', false);
|
|
57703
57635
|
D(parserOptions, 'requireDynamic', true);
|
|
57704
57636
|
D(parserOptions, 'requireResolve', true);
|
|
@@ -58089,7 +58021,7 @@ const applyOutputDefaults = (options, { context, targetProperties: tp, isAffecte
|
|
|
58089
58021
|
});
|
|
58090
58022
|
D(output, 'bundlerInfo', {});
|
|
58091
58023
|
if ('object' == typeof output.bundlerInfo) {
|
|
58092
|
-
D(output.bundlerInfo, 'version', "2.0.0-beta.
|
|
58024
|
+
D(output.bundlerInfo, 'version', "2.0.0-beta.2");
|
|
58093
58025
|
D(output.bundlerInfo, 'bundler', 'rspack');
|
|
58094
58026
|
D(output.bundlerInfo, 'force', !output.library);
|
|
58095
58027
|
}
|
|
@@ -58529,7 +58461,8 @@ const getNormalizedRspackOptions = (config)=>({
|
|
|
58529
58461
|
type: 'filesystem',
|
|
58530
58462
|
directory: path_browserify_default().resolve(config.context || normalization_process.cwd(), cache.storage?.directory || 'node_modules/.cache/rspack')
|
|
58531
58463
|
},
|
|
58532
|
-
portable: cache.portable
|
|
58464
|
+
portable: cache.portable,
|
|
58465
|
+
readonly: cache.readonly
|
|
58533
58466
|
};
|
|
58534
58467
|
}),
|
|
58535
58468
|
stats: nestedConfig(config.stats, (stats)=>{
|
|
@@ -59749,7 +59682,7 @@ class MultiStats {
|
|
|
59749
59682
|
return obj;
|
|
59750
59683
|
});
|
|
59751
59684
|
if (childOptions.version) {
|
|
59752
|
-
obj.rspackVersion = "2.0.0-beta.
|
|
59685
|
+
obj.rspackVersion = "2.0.0-beta.2";
|
|
59753
59686
|
obj.version = "5.75.0";
|
|
59754
59687
|
}
|
|
59755
59688
|
if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
|
|
@@ -61435,7 +61368,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
61435
61368
|
},
|
|
61436
61369
|
version: (object)=>{
|
|
61437
61370
|
object.version = "5.75.0";
|
|
61438
|
-
object.rspackVersion = "2.0.0-beta.
|
|
61371
|
+
object.rspackVersion = "2.0.0-beta.2";
|
|
61439
61372
|
},
|
|
61440
61373
|
env: (object, _compilation, _context, { _env })=>{
|
|
61441
61374
|
object.env = _env;
|
|
@@ -63166,7 +63099,7 @@ function createCompiler(userOptions) {
|
|
|
63166
63099
|
function isMultiRspackOptions(o) {
|
|
63167
63100
|
return Array.isArray(o);
|
|
63168
63101
|
}
|
|
63169
|
-
function
|
|
63102
|
+
function rspack_rspack(options, callback) {
|
|
63170
63103
|
try {
|
|
63171
63104
|
if (isMultiRspackOptions(options)) for (const option of options)validateRspackConfig(option);
|
|
63172
63105
|
else validateRspackConfig(options);
|
|
@@ -63475,6 +63408,41 @@ const createCompilationHooksRegisters = (getCompiler, createTap, createMapTap)=>
|
|
|
63475
63408
|
return queried.promise(getCompiler().__internal__get_compilation().chunks, getCompiler().__internal__get_compilation().modules);
|
|
63476
63409
|
};
|
|
63477
63410
|
}),
|
|
63411
|
+
registerCompilationBeforeModuleIdsTaps: createTap(external_rspack_wasi_browser_js_["default"].RegisterJsTapKind.CompilationBeforeModuleIds, function() {
|
|
63412
|
+
return getCompiler().__internal__get_compilation().hooks.beforeModuleIds;
|
|
63413
|
+
}, function(queried) {
|
|
63414
|
+
return function(arg) {
|
|
63415
|
+
const compilation = getCompiler().__internal__get_compilation();
|
|
63416
|
+
const assignments = new Map();
|
|
63417
|
+
const modulesByIdentifier = new Map();
|
|
63418
|
+
for (const module of compilation.modules)modulesByIdentifier.set(module.identifier(), module);
|
|
63419
|
+
const proxiedModules = arg.modules.map((m)=>{
|
|
63420
|
+
const realModule = modulesByIdentifier.get(m.identifier);
|
|
63421
|
+
return new Proxy(realModule, {
|
|
63422
|
+
get (target, prop) {
|
|
63423
|
+
if ('id' === prop) return assignments.get(m.identifier) ?? null;
|
|
63424
|
+
if ('identifier' === prop) return m.identifier;
|
|
63425
|
+
const value = Reflect.get(target, prop);
|
|
63426
|
+
return 'function' == typeof value ? value.bind(target) : value;
|
|
63427
|
+
},
|
|
63428
|
+
set (_target, prop, value) {
|
|
63429
|
+
if ('id' === prop && null !== value) {
|
|
63430
|
+
assignments.set(m.identifier, value);
|
|
63431
|
+
return true;
|
|
63432
|
+
}
|
|
63433
|
+
return false;
|
|
63434
|
+
}
|
|
63435
|
+
});
|
|
63436
|
+
});
|
|
63437
|
+
queried.call(proxiedModules);
|
|
63438
|
+
return {
|
|
63439
|
+
assignments: Object.fromEntries(Array.from(assignments.entries()).map(([k, v])=>[
|
|
63440
|
+
k,
|
|
63441
|
+
String(v)
|
|
63442
|
+
]))
|
|
63443
|
+
};
|
|
63444
|
+
};
|
|
63445
|
+
}),
|
|
63478
63446
|
registerCompilationChunkHashTaps: createTap(external_rspack_wasi_browser_js_["default"].RegisterJsTapKind.CompilationChunkHash, function() {
|
|
63479
63447
|
return getCompiler().__internal__get_compilation().hooks.chunkHash;
|
|
63480
63448
|
}, function(queried) {
|
|
@@ -64293,7 +64261,7 @@ class Compiler {
|
|
|
64293
64261
|
});
|
|
64294
64262
|
const compilerRuntimeGlobals = createCompilerRuntimeGlobals(options);
|
|
64295
64263
|
const compilerFn = function(...params) {
|
|
64296
|
-
return
|
|
64264
|
+
return rspack_rspack(...params);
|
|
64297
64265
|
};
|
|
64298
64266
|
const compilerRspack = Object.assign(compilerFn, exports_namespaceObject, {
|
|
64299
64267
|
RuntimeGlobals: compilerRuntimeGlobals
|
|
@@ -65023,10 +64991,233 @@ class NodeTemplatePlugin {
|
|
|
65023
64991
|
new EnableChunkLoadingPlugin(chunkLoading).apply(compiler);
|
|
65024
64992
|
}
|
|
65025
64993
|
}
|
|
64994
|
+
const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
|
|
64995
|
+
const array = (items)=>{
|
|
64996
|
+
for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
|
|
64997
|
+
else if (item && 'object' == typeof item) object(item);
|
|
64998
|
+
else throw new Error('Unexpected options format');
|
|
64999
|
+
};
|
|
65000
|
+
const object = (obj)=>{
|
|
65001
|
+
for (const [key, value] of Object.entries(obj))'string' == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
|
|
65002
|
+
};
|
|
65003
|
+
if (!options) return;
|
|
65004
|
+
if (Array.isArray(options)) array(options);
|
|
65005
|
+
else if ('object' == typeof options) object(options);
|
|
65006
|
+
else throw new Error('Unexpected options format');
|
|
65007
|
+
};
|
|
65008
|
+
const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
65009
|
+
const items = [];
|
|
65010
|
+
options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
|
|
65011
|
+
items.push([
|
|
65012
|
+
key,
|
|
65013
|
+
value
|
|
65014
|
+
]);
|
|
65015
|
+
});
|
|
65016
|
+
return items;
|
|
65017
|
+
};
|
|
65018
|
+
const compilerSet = new WeakSet();
|
|
65019
|
+
function isSingleton(compiler) {
|
|
65020
|
+
return compilerSet.has(compiler);
|
|
65021
|
+
}
|
|
65022
|
+
function setSingleton(compiler) {
|
|
65023
|
+
compilerSet.add(compiler);
|
|
65024
|
+
}
|
|
65025
|
+
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
65026
|
+
enhanced;
|
|
65027
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ShareRuntimePlugin;
|
|
65028
|
+
constructor(enhanced = false){
|
|
65029
|
+
super(), this.enhanced = enhanced;
|
|
65030
|
+
}
|
|
65031
|
+
raw(compiler) {
|
|
65032
|
+
if (isSingleton(compiler)) return;
|
|
65033
|
+
setSingleton(compiler);
|
|
65034
|
+
return createBuiltinPlugin(this.name, this.enhanced);
|
|
65035
|
+
}
|
|
65036
|
+
}
|
|
65026
65037
|
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
65027
65038
|
function isRequiredVersion(str) {
|
|
65028
65039
|
return VERSION_PATTERN_REGEXP.test(str);
|
|
65029
65040
|
}
|
|
65041
|
+
const encodeName = function(name, prefix = '', withExt = false) {
|
|
65042
|
+
const ext = withExt ? '.js' : '';
|
|
65043
|
+
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${ext}`;
|
|
65044
|
+
};
|
|
65045
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
65046
|
+
return parseOptions(consumes, (item, key)=>{
|
|
65047
|
+
if (Array.isArray(item)) throw new Error('Unexpected array in options');
|
|
65048
|
+
const result = item !== key && isRequiredVersion(item) ? {
|
|
65049
|
+
import: key,
|
|
65050
|
+
shareScope: shareScope || 'default',
|
|
65051
|
+
shareKey: key,
|
|
65052
|
+
requiredVersion: item,
|
|
65053
|
+
strictVersion: true,
|
|
65054
|
+
packageName: void 0,
|
|
65055
|
+
singleton: false,
|
|
65056
|
+
eager: false,
|
|
65057
|
+
treeShakingMode: void 0
|
|
65058
|
+
} : {
|
|
65059
|
+
import: key,
|
|
65060
|
+
shareScope: shareScope || 'default',
|
|
65061
|
+
shareKey: key,
|
|
65062
|
+
requiredVersion: void 0,
|
|
65063
|
+
packageName: void 0,
|
|
65064
|
+
strictVersion: false,
|
|
65065
|
+
singleton: false,
|
|
65066
|
+
eager: false,
|
|
65067
|
+
treeShakingMode: void 0
|
|
65068
|
+
};
|
|
65069
|
+
return result;
|
|
65070
|
+
}, (item, key)=>({
|
|
65071
|
+
import: false === item.import ? void 0 : item.import || key,
|
|
65072
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
65073
|
+
shareKey: item.shareKey || key,
|
|
65074
|
+
requiredVersion: item.requiredVersion,
|
|
65075
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
|
|
65076
|
+
packageName: item.packageName,
|
|
65077
|
+
singleton: !!item.singleton,
|
|
65078
|
+
eager: !!item.eager,
|
|
65079
|
+
treeShakingMode: item.treeShakingMode
|
|
65080
|
+
}));
|
|
65081
|
+
}
|
|
65082
|
+
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
65083
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin;
|
|
65084
|
+
_options;
|
|
65085
|
+
constructor(options){
|
|
65086
|
+
super();
|
|
65087
|
+
this._options = {
|
|
65088
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
65089
|
+
enhanced: options.enhanced ?? false
|
|
65090
|
+
};
|
|
65091
|
+
}
|
|
65092
|
+
raw(compiler) {
|
|
65093
|
+
new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
65094
|
+
const rawOptions = {
|
|
65095
|
+
consumes: this._options.consumes.map(([key, v])=>({
|
|
65096
|
+
key,
|
|
65097
|
+
...v
|
|
65098
|
+
})),
|
|
65099
|
+
enhanced: this._options.enhanced
|
|
65100
|
+
};
|
|
65101
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
65102
|
+
}
|
|
65103
|
+
}
|
|
65104
|
+
function normalizeProvideShareOptions(options, shareScope, enhanced) {
|
|
65105
|
+
return parseOptions(options, (item)=>{
|
|
65106
|
+
if (Array.isArray(item)) throw new Error('Unexpected array of provides');
|
|
65107
|
+
return {
|
|
65108
|
+
shareKey: item,
|
|
65109
|
+
version: void 0,
|
|
65110
|
+
shareScope: shareScope || 'default',
|
|
65111
|
+
eager: false
|
|
65112
|
+
};
|
|
65113
|
+
}, (item)=>{
|
|
65114
|
+
const raw = {
|
|
65115
|
+
shareKey: item.shareKey,
|
|
65116
|
+
version: item.version,
|
|
65117
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
65118
|
+
eager: !!item.eager
|
|
65119
|
+
};
|
|
65120
|
+
if (enhanced) {
|
|
65121
|
+
const enhancedItem = item;
|
|
65122
|
+
return {
|
|
65123
|
+
...raw,
|
|
65124
|
+
singleton: enhancedItem.singleton,
|
|
65125
|
+
requiredVersion: enhancedItem.requiredVersion,
|
|
65126
|
+
strictVersion: enhancedItem.strictVersion,
|
|
65127
|
+
treeShakingMode: enhancedItem.treeShakingMode
|
|
65128
|
+
};
|
|
65129
|
+
}
|
|
65130
|
+
return raw;
|
|
65131
|
+
});
|
|
65132
|
+
}
|
|
65133
|
+
class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
65134
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ProvideSharedPlugin;
|
|
65135
|
+
_provides;
|
|
65136
|
+
_enhanced;
|
|
65137
|
+
constructor(options){
|
|
65138
|
+
super();
|
|
65139
|
+
this._provides = normalizeProvideShareOptions(options.provides, options.shareScope, options.enhanced);
|
|
65140
|
+
this._enhanced = options.enhanced;
|
|
65141
|
+
}
|
|
65142
|
+
raw(compiler) {
|
|
65143
|
+
new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
|
|
65144
|
+
const rawOptions = this._provides.map(([key, v])=>({
|
|
65145
|
+
key,
|
|
65146
|
+
...v
|
|
65147
|
+
}));
|
|
65148
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
65149
|
+
}
|
|
65150
|
+
}
|
|
65151
|
+
function normalizeSharedOptions(shared) {
|
|
65152
|
+
return parseOptions(shared, (item, key)=>{
|
|
65153
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
65154
|
+
const config = item !== key && isRequiredVersion(item) ? {
|
|
65155
|
+
import: key,
|
|
65156
|
+
requiredVersion: item
|
|
65157
|
+
} : {
|
|
65158
|
+
import: item
|
|
65159
|
+
};
|
|
65160
|
+
return config;
|
|
65161
|
+
}, (item)=>item);
|
|
65162
|
+
}
|
|
65163
|
+
function createProvideShareOptions(normalizedSharedOptions) {
|
|
65164
|
+
return normalizedSharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
|
|
65165
|
+
[options.import || key]: {
|
|
65166
|
+
shareKey: options.shareKey || key,
|
|
65167
|
+
shareScope: options.shareScope,
|
|
65168
|
+
version: options.version,
|
|
65169
|
+
eager: options.eager,
|
|
65170
|
+
singleton: options.singleton,
|
|
65171
|
+
requiredVersion: options.requiredVersion,
|
|
65172
|
+
strictVersion: options.strictVersion,
|
|
65173
|
+
treeShakingMode: options.treeShaking?.mode
|
|
65174
|
+
}
|
|
65175
|
+
}));
|
|
65176
|
+
}
|
|
65177
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
65178
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
65179
|
+
[key]: {
|
|
65180
|
+
import: options.import,
|
|
65181
|
+
shareKey: options.shareKey || key,
|
|
65182
|
+
shareScope: options.shareScope,
|
|
65183
|
+
requiredVersion: options.requiredVersion,
|
|
65184
|
+
strictVersion: options.strictVersion,
|
|
65185
|
+
singleton: options.singleton,
|
|
65186
|
+
packageName: options.packageName,
|
|
65187
|
+
eager: options.eager,
|
|
65188
|
+
treeShakingMode: options.treeShaking?.mode
|
|
65189
|
+
}
|
|
65190
|
+
}));
|
|
65191
|
+
}
|
|
65192
|
+
class SharePlugin {
|
|
65193
|
+
_shareScope;
|
|
65194
|
+
_consumes;
|
|
65195
|
+
_provides;
|
|
65196
|
+
_enhanced;
|
|
65197
|
+
_sharedOptions;
|
|
65198
|
+
constructor(options){
|
|
65199
|
+
const sharedOptions = normalizeSharedOptions(options.shared);
|
|
65200
|
+
const consumes = createConsumeShareOptions(sharedOptions);
|
|
65201
|
+
const provides = createProvideShareOptions(sharedOptions);
|
|
65202
|
+
this._shareScope = options.shareScope;
|
|
65203
|
+
this._consumes = consumes;
|
|
65204
|
+
this._provides = provides;
|
|
65205
|
+
this._enhanced = options.enhanced ?? false;
|
|
65206
|
+
this._sharedOptions = sharedOptions;
|
|
65207
|
+
}
|
|
65208
|
+
apply(compiler) {
|
|
65209
|
+
new ConsumeSharedPlugin({
|
|
65210
|
+
shareScope: this._shareScope,
|
|
65211
|
+
consumes: this._consumes,
|
|
65212
|
+
enhanced: this._enhanced
|
|
65213
|
+
}).apply(compiler);
|
|
65214
|
+
new ProvideSharedPlugin({
|
|
65215
|
+
shareScope: this._shareScope,
|
|
65216
|
+
provides: this._provides,
|
|
65217
|
+
enhanced: this._enhanced
|
|
65218
|
+
}).apply(compiler);
|
|
65219
|
+
}
|
|
65220
|
+
}
|
|
65030
65221
|
var ModuleFederationManifestPlugin_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
65031
65222
|
const MANIFEST_FILE_NAME = 'mf-manifest.json';
|
|
65032
65223
|
const STATS_FILE_NAME = 'mf-stats.json';
|
|
@@ -65055,17 +65246,29 @@ function readPKGJson(root) {
|
|
|
65055
65246
|
} catch {}
|
|
65056
65247
|
return {};
|
|
65057
65248
|
}
|
|
65058
|
-
function getBuildInfo(isDev,
|
|
65059
|
-
const rootPath =
|
|
65249
|
+
function getBuildInfo(isDev, compiler, mfConfig) {
|
|
65250
|
+
const rootPath = compiler.options.context || ModuleFederationManifestPlugin_process.cwd();
|
|
65060
65251
|
const pkg = readPKGJson(rootPath);
|
|
65061
65252
|
const buildVersion = isDev ? LOCAL_BUILD_VERSION : pkg?.version;
|
|
65062
|
-
|
|
65253
|
+
const statsBuildInfo = {
|
|
65063
65254
|
buildVersion: ModuleFederationManifestPlugin_process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
65064
65255
|
buildName: ModuleFederationManifestPlugin_process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
65065
65256
|
};
|
|
65257
|
+
const normalizedShared = normalizeSharedOptions(mfConfig.shared || {});
|
|
65258
|
+
const enableTreeShaking = Object.values(normalizedShared).some((config)=>config[1].treeShaking);
|
|
65259
|
+
if (enableTreeShaking) {
|
|
65260
|
+
statsBuildInfo.target = Array.isArray(compiler.options.target) ? compiler.options.target : [];
|
|
65261
|
+
statsBuildInfo.plugins = mfConfig.treeShakingSharedPlugins || [];
|
|
65262
|
+
statsBuildInfo.excludePlugins = mfConfig.treeShakingSharedExcludePlugins || [];
|
|
65263
|
+
}
|
|
65264
|
+
return statsBuildInfo;
|
|
65066
65265
|
}
|
|
65067
65266
|
function getFileName(manifestOptions) {
|
|
65068
65267
|
if (!manifestOptions) return {
|
|
65268
|
+
statsFileName: '',
|
|
65269
|
+
manifestFileName: ''
|
|
65270
|
+
};
|
|
65271
|
+
if ('boolean' == typeof manifestOptions) return {
|
|
65069
65272
|
statsFileName: STATS_FILE_NAME,
|
|
65070
65273
|
manifestFileName: MANIFEST_FILE_NAME
|
|
65071
65274
|
};
|
|
@@ -65083,120 +65286,13 @@ function getFileName(manifestOptions) {
|
|
|
65083
65286
|
manifestFileName: (0, path_browserify.join)(filePath, manifestFileName)
|
|
65084
65287
|
};
|
|
65085
65288
|
}
|
|
65086
|
-
|
|
65087
|
-
|
|
65088
|
-
|
|
65089
|
-
|
|
65090
|
-
|
|
65091
|
-
|
|
65092
|
-
|
|
65093
|
-
raw(compiler) {
|
|
65094
|
-
const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts;
|
|
65095
|
-
const { statsFileName, manifestFileName } = getFileName(this.opts);
|
|
65096
|
-
const rawOptions = {
|
|
65097
|
-
name: this.opts.name,
|
|
65098
|
-
globalName: this.opts.globalName,
|
|
65099
|
-
fileName,
|
|
65100
|
-
filePath,
|
|
65101
|
-
manifestFileName,
|
|
65102
|
-
statsFileName,
|
|
65103
|
-
disableAssetsAnalyze,
|
|
65104
|
-
remoteAliasMap,
|
|
65105
|
-
exposes,
|
|
65106
|
-
shared,
|
|
65107
|
-
buildInfo: getBuildInfo('development' === compiler.options.mode, compiler.context)
|
|
65108
|
-
};
|
|
65109
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
65110
|
-
}
|
|
65111
|
-
}
|
|
65112
|
-
const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
|
|
65113
|
-
const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
|
|
65114
|
-
const array = (items)=>{
|
|
65115
|
-
for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
|
|
65116
|
-
else if (item && 'object' == typeof item) object(item);
|
|
65117
|
-
else throw new Error('Unexpected options format');
|
|
65118
|
-
};
|
|
65119
|
-
const object = (obj)=>{
|
|
65120
|
-
for (const [key, value] of Object.entries(obj))'string' == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
|
|
65121
|
-
};
|
|
65122
|
-
if (!options) return;
|
|
65123
|
-
if (Array.isArray(options)) array(options);
|
|
65124
|
-
else if ('object' == typeof options) object(options);
|
|
65125
|
-
else throw new Error('Unexpected options format');
|
|
65126
|
-
};
|
|
65127
|
-
const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
65128
|
-
const items = [];
|
|
65129
|
-
options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
|
|
65130
|
-
items.push([
|
|
65131
|
-
key,
|
|
65132
|
-
value
|
|
65133
|
-
]);
|
|
65134
|
-
});
|
|
65135
|
-
return items;
|
|
65136
|
-
};
|
|
65137
|
-
class ModuleFederationPlugin {
|
|
65138
|
-
_options;
|
|
65139
|
-
constructor(_options){
|
|
65140
|
-
this._options = _options;
|
|
65141
|
-
}
|
|
65142
|
-
apply(compiler) {
|
|
65143
|
-
const { webpack } = compiler;
|
|
65144
|
-
const paths = getPaths(this._options, compiler);
|
|
65145
|
-
compiler.options.resolve.alias = {
|
|
65146
|
-
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
65147
|
-
'@module-federation/runtime': paths.runtime,
|
|
65148
|
-
...compiler.options.resolve.alias
|
|
65149
|
-
};
|
|
65150
|
-
const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler);
|
|
65151
|
-
const asyncStartup = this._options.experiments?.asyncStartup ?? false;
|
|
65152
|
-
const runtimeExperiments = {
|
|
65153
|
-
asyncStartup
|
|
65154
|
-
};
|
|
65155
|
-
new ModuleFederationRuntimePlugin({
|
|
65156
|
-
entryRuntime,
|
|
65157
|
-
experiments: runtimeExperiments
|
|
65158
|
-
}).apply(compiler);
|
|
65159
|
-
const v1Options = {
|
|
65160
|
-
name: this._options.name,
|
|
65161
|
-
exposes: this._options.exposes,
|
|
65162
|
-
filename: this._options.filename,
|
|
65163
|
-
library: this._options.library,
|
|
65164
|
-
remoteType: this._options.remoteType,
|
|
65165
|
-
remotes: this._options.remotes,
|
|
65166
|
-
runtime: this._options.runtime,
|
|
65167
|
-
shareScope: this._options.shareScope,
|
|
65168
|
-
shared: this._options.shared,
|
|
65169
|
-
enhanced: true
|
|
65170
|
-
};
|
|
65171
|
-
new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler);
|
|
65172
|
-
if (this._options.manifest) {
|
|
65173
|
-
const manifestOptions = true === this._options.manifest ? {} : {
|
|
65174
|
-
...this._options.manifest
|
|
65175
|
-
};
|
|
65176
|
-
const containerName = manifestOptions.name ?? this._options.name;
|
|
65177
|
-
const globalName = manifestOptions.globalName ?? resolveLibraryGlobalName(this._options.library) ?? containerName;
|
|
65178
|
-
const remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
65179
|
-
if (cur[1].length > 1) return sum;
|
|
65180
|
-
const remoteInfo = cur[1][0];
|
|
65181
|
-
const { entry, alias, name } = remoteInfo;
|
|
65182
|
-
if (entry && name) sum[alias] = {
|
|
65183
|
-
name,
|
|
65184
|
-
entry
|
|
65185
|
-
};
|
|
65186
|
-
return sum;
|
|
65187
|
-
}, {});
|
|
65188
|
-
const manifestExposes = collectManifestExposes(this._options.exposes);
|
|
65189
|
-
if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
|
|
65190
|
-
const manifestShared = collectManifestShared(this._options.shared);
|
|
65191
|
-
if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
|
|
65192
|
-
new ModuleFederationManifestPlugin({
|
|
65193
|
-
...manifestOptions,
|
|
65194
|
-
name: containerName,
|
|
65195
|
-
globalName,
|
|
65196
|
-
remoteAliasMap
|
|
65197
|
-
}).apply(compiler);
|
|
65198
|
-
}
|
|
65199
|
-
}
|
|
65289
|
+
function resolveLibraryGlobalName(library) {
|
|
65290
|
+
if (!library) return;
|
|
65291
|
+
const libName = library.name;
|
|
65292
|
+
if (!libName) return;
|
|
65293
|
+
if ('string' == typeof libName) return libName;
|
|
65294
|
+
if (Array.isArray(libName)) return libName[0];
|
|
65295
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
65200
65296
|
}
|
|
65201
65297
|
function collectManifestExposes(exposes) {
|
|
65202
65298
|
if (!exposes) return;
|
|
@@ -65244,13 +65340,560 @@ function collectManifestShared(shared) {
|
|
|
65244
65340
|
});
|
|
65245
65341
|
return result.length > 0 ? result : void 0;
|
|
65246
65342
|
}
|
|
65247
|
-
function
|
|
65248
|
-
|
|
65249
|
-
|
|
65250
|
-
|
|
65251
|
-
|
|
65252
|
-
|
|
65253
|
-
|
|
65343
|
+
function normalizeManifestOptions(mfConfig) {
|
|
65344
|
+
const manifestOptions = true === mfConfig.manifest ? {} : {
|
|
65345
|
+
...mfConfig.manifest
|
|
65346
|
+
};
|
|
65347
|
+
const containerName = mfConfig.name;
|
|
65348
|
+
const globalName = resolveLibraryGlobalName(mfConfig.library) ?? containerName;
|
|
65349
|
+
const remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
65350
|
+
if (cur[1].length > 1) return sum;
|
|
65351
|
+
const remoteInfo = cur[1][0];
|
|
65352
|
+
const { entry, alias, name } = remoteInfo;
|
|
65353
|
+
if (entry && name) sum[alias] = {
|
|
65354
|
+
name,
|
|
65355
|
+
entry
|
|
65356
|
+
};
|
|
65357
|
+
return sum;
|
|
65358
|
+
}, {});
|
|
65359
|
+
const manifestExposes = collectManifestExposes(mfConfig.exposes);
|
|
65360
|
+
if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
|
|
65361
|
+
const manifestShared = collectManifestShared(mfConfig.shared);
|
|
65362
|
+
if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
|
|
65363
|
+
return {
|
|
65364
|
+
...manifestOptions,
|
|
65365
|
+
remoteAliasMap,
|
|
65366
|
+
globalName,
|
|
65367
|
+
name: containerName
|
|
65368
|
+
};
|
|
65369
|
+
}
|
|
65370
|
+
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
65371
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
65372
|
+
rawOpts;
|
|
65373
|
+
constructor(opts){
|
|
65374
|
+
super();
|
|
65375
|
+
this.rawOpts = opts;
|
|
65376
|
+
}
|
|
65377
|
+
raw(compiler) {
|
|
65378
|
+
const opts = normalizeManifestOptions(this.rawOpts);
|
|
65379
|
+
const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = opts;
|
|
65380
|
+
const { statsFileName, manifestFileName } = getFileName(opts);
|
|
65381
|
+
const rawOptions = {
|
|
65382
|
+
name: opts.name,
|
|
65383
|
+
globalName: opts.globalName,
|
|
65384
|
+
fileName,
|
|
65385
|
+
filePath,
|
|
65386
|
+
manifestFileName,
|
|
65387
|
+
statsFileName,
|
|
65388
|
+
disableAssetsAnalyze,
|
|
65389
|
+
remoteAliasMap,
|
|
65390
|
+
exposes,
|
|
65391
|
+
shared,
|
|
65392
|
+
buildInfo: getBuildInfo('development' === compiler.options.mode, compiler, this.rawOpts)
|
|
65393
|
+
};
|
|
65394
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
65395
|
+
}
|
|
65396
|
+
}
|
|
65397
|
+
const SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
65398
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
65399
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.CollectSharedEntryPlugin;
|
|
65400
|
+
sharedOptions;
|
|
65401
|
+
_collectedEntries;
|
|
65402
|
+
constructor(options){
|
|
65403
|
+
super();
|
|
65404
|
+
const { sharedOptions } = options;
|
|
65405
|
+
this.sharedOptions = sharedOptions;
|
|
65406
|
+
this._collectedEntries = {};
|
|
65407
|
+
}
|
|
65408
|
+
getData() {
|
|
65409
|
+
return this._collectedEntries;
|
|
65410
|
+
}
|
|
65411
|
+
getFilename() {
|
|
65412
|
+
return SHARE_ENTRY_ASSET;
|
|
65413
|
+
}
|
|
65414
|
+
apply(compiler) {
|
|
65415
|
+
super.apply(compiler);
|
|
65416
|
+
compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
65417
|
+
compilation.hooks.processAssets.tap({
|
|
65418
|
+
name: 'CollectSharedEntry',
|
|
65419
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
65420
|
+
}, ()=>{
|
|
65421
|
+
compilation.getAssets().forEach((asset)=>{
|
|
65422
|
+
if (asset.name === SHARE_ENTRY_ASSET) this._collectedEntries = JSON.parse(asset.source.source().toString());
|
|
65423
|
+
compilation.deleteAsset(asset.name);
|
|
65424
|
+
});
|
|
65425
|
+
});
|
|
65426
|
+
});
|
|
65427
|
+
}
|
|
65428
|
+
raw() {
|
|
65429
|
+
const consumeShareOptions = createConsumeShareOptions(this.sharedOptions);
|
|
65430
|
+
const normalizedConsumeShareOptions = normalizeConsumeShareOptions(consumeShareOptions);
|
|
65431
|
+
const rawOptions = {
|
|
65432
|
+
consumes: normalizedConsumeShareOptions.map(([key, v])=>({
|
|
65433
|
+
key,
|
|
65434
|
+
...v
|
|
65435
|
+
})),
|
|
65436
|
+
filename: this.getFilename()
|
|
65437
|
+
};
|
|
65438
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
65439
|
+
}
|
|
65440
|
+
}
|
|
65441
|
+
function assert(condition, msg) {
|
|
65442
|
+
if (!condition) throw new Error(msg);
|
|
65443
|
+
}
|
|
65444
|
+
const HOT_UPDATE_SUFFIX = '.hot-update';
|
|
65445
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
65446
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.SharedContainerPlugin;
|
|
65447
|
+
filename = '';
|
|
65448
|
+
_options;
|
|
65449
|
+
_shareName;
|
|
65450
|
+
_globalName;
|
|
65451
|
+
constructor(options){
|
|
65452
|
+
super();
|
|
65453
|
+
const { shareName, library, request, independentShareFileName, mfName } = options;
|
|
65454
|
+
const version = options.version || '0.0.0';
|
|
65455
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
65456
|
+
const fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
65457
|
+
this._shareName = shareName;
|
|
65458
|
+
this._options = {
|
|
65459
|
+
name: shareName,
|
|
65460
|
+
request: request,
|
|
65461
|
+
library: (library ? {
|
|
65462
|
+
...library,
|
|
65463
|
+
name: this._globalName
|
|
65464
|
+
} : void 0) || {
|
|
65465
|
+
type: 'global',
|
|
65466
|
+
name: this._globalName
|
|
65467
|
+
},
|
|
65468
|
+
version,
|
|
65469
|
+
fileName
|
|
65470
|
+
};
|
|
65471
|
+
}
|
|
65472
|
+
getData() {
|
|
65473
|
+
return [
|
|
65474
|
+
this._options.fileName,
|
|
65475
|
+
this._globalName,
|
|
65476
|
+
this._options.version
|
|
65477
|
+
];
|
|
65478
|
+
}
|
|
65479
|
+
raw(compiler) {
|
|
65480
|
+
const { library } = this._options;
|
|
65481
|
+
if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
|
|
65482
|
+
return createBuiltinPlugin(this.name, this._options);
|
|
65483
|
+
}
|
|
65484
|
+
apply(compiler) {
|
|
65485
|
+
super.apply(compiler);
|
|
65486
|
+
const shareName = this._shareName;
|
|
65487
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
65488
|
+
compilation.hooks.processAssets.tap({
|
|
65489
|
+
name: 'getShareContainerFile'
|
|
65490
|
+
}, ()=>{
|
|
65491
|
+
const remoteEntryPoint = compilation.entrypoints.get(shareName);
|
|
65492
|
+
assert(remoteEntryPoint, `Can not get shared ${shareName} entryPoint!`);
|
|
65493
|
+
const remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
65494
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
65495
|
+
const files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith('.css'));
|
|
65496
|
+
assert(files.length > 0, `no files found for shared ${shareName} chunk`);
|
|
65497
|
+
assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(',')}`);
|
|
65498
|
+
this.filename = files[0];
|
|
65499
|
+
});
|
|
65500
|
+
});
|
|
65501
|
+
}
|
|
65502
|
+
}
|
|
65503
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
65504
|
+
name = external_rspack_wasi_browser_js_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
|
|
65505
|
+
sharedOptions;
|
|
65506
|
+
injectTreeShakingUsedExports;
|
|
65507
|
+
manifestOptions;
|
|
65508
|
+
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
65509
|
+
super();
|
|
65510
|
+
this.sharedOptions = sharedOptions;
|
|
65511
|
+
this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;
|
|
65512
|
+
this.manifestOptions = manifestOptions ?? {};
|
|
65513
|
+
}
|
|
65514
|
+
buildOptions() {
|
|
65515
|
+
const shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
65516
|
+
shareKey,
|
|
65517
|
+
treeShaking: !!config.treeShaking,
|
|
65518
|
+
usedExports: config.treeShaking?.usedExports
|
|
65519
|
+
}));
|
|
65520
|
+
const { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
65521
|
+
return {
|
|
65522
|
+
shared,
|
|
65523
|
+
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
65524
|
+
manifestFileName,
|
|
65525
|
+
statsFileName
|
|
65526
|
+
};
|
|
65527
|
+
}
|
|
65528
|
+
raw() {
|
|
65529
|
+
if (!this.sharedOptions.length) return;
|
|
65530
|
+
return createBuiltinPlugin(this.name, this.buildOptions());
|
|
65531
|
+
}
|
|
65532
|
+
}
|
|
65533
|
+
const VIRTUAL_ENTRY = './virtual-entry.js';
|
|
65534
|
+
const VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
65535
|
+
const filterPlugin = (plugin, excludedPlugins = [])=>{
|
|
65536
|
+
if (!plugin) return true;
|
|
65537
|
+
const pluginName = plugin.name || plugin.constructor?.name;
|
|
65538
|
+
if (!pluginName) return true;
|
|
65539
|
+
return ![
|
|
65540
|
+
'TreeShakingSharedPlugin',
|
|
65541
|
+
'IndependentSharedPlugin',
|
|
65542
|
+
'ModuleFederationPlugin',
|
|
65543
|
+
'SharedUsedExportsOptimizerPlugin',
|
|
65544
|
+
'HtmlWebpackPlugin',
|
|
65545
|
+
'HtmlRspackPlugin',
|
|
65546
|
+
'RsbuildHtmlPlugin',
|
|
65547
|
+
...excludedPlugins
|
|
65548
|
+
].includes(pluginName);
|
|
65549
|
+
};
|
|
65550
|
+
class VirtualEntryPlugin {
|
|
65551
|
+
sharedOptions;
|
|
65552
|
+
collectShared = false;
|
|
65553
|
+
constructor(sharedOptions, collectShared){
|
|
65554
|
+
this.sharedOptions = sharedOptions;
|
|
65555
|
+
this.collectShared = collectShared;
|
|
65556
|
+
}
|
|
65557
|
+
createEntry() {
|
|
65558
|
+
const { sharedOptions, collectShared } = this;
|
|
65559
|
+
const entryContent = sharedOptions.reduce((acc, cur, index)=>{
|
|
65560
|
+
const importLine = `import shared_${index} from '${cur[0]}';\n`;
|
|
65561
|
+
const logLine = collectShared ? `console.log(shared_${index});\n` : '';
|
|
65562
|
+
return acc + importLine + logLine;
|
|
65563
|
+
}, '');
|
|
65564
|
+
return entryContent;
|
|
65565
|
+
}
|
|
65566
|
+
static entry() {
|
|
65567
|
+
return {
|
|
65568
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
65569
|
+
};
|
|
65570
|
+
}
|
|
65571
|
+
apply(compiler) {
|
|
65572
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
65573
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
65574
|
+
}).apply(compiler);
|
|
65575
|
+
compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
65576
|
+
compilation.hooks.processAssets.tap({
|
|
65577
|
+
name: 'RemoveVirtualEntryAsset',
|
|
65578
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
65579
|
+
}, ()=>{
|
|
65580
|
+
try {
|
|
65581
|
+
const chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
65582
|
+
chunk?.files.forEach((f)=>{
|
|
65583
|
+
compilation.deleteAsset(f);
|
|
65584
|
+
});
|
|
65585
|
+
} catch (_e) {
|
|
65586
|
+
console.error('Failed to remove virtual entry file!');
|
|
65587
|
+
}
|
|
65588
|
+
});
|
|
65589
|
+
});
|
|
65590
|
+
}
|
|
65591
|
+
}
|
|
65592
|
+
const resolveOutputDir = (outputDir, shareName)=>shareName ? (0, path_browserify.join)(outputDir, encodeName(shareName)) : outputDir;
|
|
65593
|
+
class IndependentSharedPlugin {
|
|
65594
|
+
mfName;
|
|
65595
|
+
shared;
|
|
65596
|
+
library;
|
|
65597
|
+
sharedOptions;
|
|
65598
|
+
outputDir;
|
|
65599
|
+
plugins;
|
|
65600
|
+
treeShaking;
|
|
65601
|
+
manifest;
|
|
65602
|
+
buildAssets = {};
|
|
65603
|
+
injectTreeShakingUsedExports;
|
|
65604
|
+
treeShakingSharedExcludePlugins;
|
|
65605
|
+
name = 'IndependentSharedPlugin';
|
|
65606
|
+
constructor(options){
|
|
65607
|
+
const { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
65608
|
+
this.shared = shared;
|
|
65609
|
+
this.mfName = name;
|
|
65610
|
+
this.outputDir = outputDir || 'independent-packages';
|
|
65611
|
+
this.plugins = plugins || [];
|
|
65612
|
+
this.treeShaking = treeShaking;
|
|
65613
|
+
this.manifest = manifest;
|
|
65614
|
+
this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;
|
|
65615
|
+
this.library = library;
|
|
65616
|
+
this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins || [];
|
|
65617
|
+
this.sharedOptions = parseOptions(shared, (item, key)=>{
|
|
65618
|
+
if ('string' != typeof item) throw new Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
65619
|
+
const config = item !== key && isRequiredVersion(item) ? {
|
|
65620
|
+
import: key,
|
|
65621
|
+
requiredVersion: item
|
|
65622
|
+
} : {
|
|
65623
|
+
import: item
|
|
65624
|
+
};
|
|
65625
|
+
return config;
|
|
65626
|
+
}, (item)=>item);
|
|
65627
|
+
}
|
|
65628
|
+
apply(compiler) {
|
|
65629
|
+
const { manifest } = this;
|
|
65630
|
+
let runCount = 0;
|
|
65631
|
+
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
65632
|
+
if (runCount) return;
|
|
65633
|
+
await this.createIndependentCompilers(compiler);
|
|
65634
|
+
runCount++;
|
|
65635
|
+
});
|
|
65636
|
+
compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
65637
|
+
if (runCount) return;
|
|
65638
|
+
await this.createIndependentCompilers(compiler);
|
|
65639
|
+
runCount++;
|
|
65640
|
+
});
|
|
65641
|
+
if (manifest) compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
65642
|
+
compilation.hooks.processAssets.tap({
|
|
65643
|
+
name: 'injectBuildAssets',
|
|
65644
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
65645
|
+
}, ()=>{
|
|
65646
|
+
const { statsFileName, manifestFileName } = getFileName(manifest);
|
|
65647
|
+
const injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
65648
|
+
const stats = compilation.getAsset(filename);
|
|
65649
|
+
if (!stats) return;
|
|
65650
|
+
const statsContent = JSON.parse(stats.source.source().toString());
|
|
65651
|
+
const { shared } = statsContent;
|
|
65652
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
65653
|
+
const targetShared = shared.find((s)=>s.name === key);
|
|
65654
|
+
if (!targetShared) return;
|
|
65655
|
+
item.forEach(([entry, version, globalName])=>{
|
|
65656
|
+
if (version === targetShared.version) {
|
|
65657
|
+
targetShared.fallback = entry;
|
|
65658
|
+
targetShared.fallbackName = globalName;
|
|
65659
|
+
}
|
|
65660
|
+
});
|
|
65661
|
+
});
|
|
65662
|
+
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
65663
|
+
};
|
|
65664
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName);
|
|
65665
|
+
injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
65666
|
+
});
|
|
65667
|
+
});
|
|
65668
|
+
}
|
|
65669
|
+
async createIndependentCompilers(parentCompiler) {
|
|
65670
|
+
const { sharedOptions, buildAssets, outputDir } = this;
|
|
65671
|
+
console.log('Start building shared fallback resources ...');
|
|
65672
|
+
const shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
65673
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
65674
|
+
if (!shareConfig.treeShaking || false === shareConfig.import) return;
|
|
65675
|
+
const shareRequests = shareRequestsMap[shareName].requests;
|
|
65676
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
65677
|
+
const sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1];
|
|
65678
|
+
const [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
65679
|
+
shareRequestsMap,
|
|
65680
|
+
currentShare: {
|
|
65681
|
+
shareName,
|
|
65682
|
+
version,
|
|
65683
|
+
request,
|
|
65684
|
+
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
65685
|
+
}
|
|
65686
|
+
});
|
|
65687
|
+
if ('string' == typeof shareFileName) {
|
|
65688
|
+
buildAssets[shareName] ||= [];
|
|
65689
|
+
buildAssets[shareName].push([
|
|
65690
|
+
(0, path_browserify.join)(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
65691
|
+
sharedVersion,
|
|
65692
|
+
globalName
|
|
65693
|
+
]);
|
|
65694
|
+
}
|
|
65695
|
+
}));
|
|
65696
|
+
}));
|
|
65697
|
+
console.log('All shared fallback have been compiled successfully!');
|
|
65698
|
+
}
|
|
65699
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
65700
|
+
const { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this;
|
|
65701
|
+
const outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || '');
|
|
65702
|
+
const parentConfig = parentCompiler.options;
|
|
65703
|
+
const finalPlugins = [];
|
|
65704
|
+
const rspack = parentCompiler.rspack;
|
|
65705
|
+
let extraPlugin;
|
|
65706
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
65707
|
+
mfName: `${mfName}_${treeShaking ? 't' : 'f'}`,
|
|
65708
|
+
library,
|
|
65709
|
+
...extraOptions.currentShare
|
|
65710
|
+
}) : new CollectSharedEntryPlugin({
|
|
65711
|
+
sharedOptions,
|
|
65712
|
+
shareScope: 'default'
|
|
65713
|
+
});
|
|
65714
|
+
(parentConfig.plugins || []).forEach((plugin)=>{
|
|
65715
|
+
if (void 0 !== plugin && 'string' != typeof plugin && filterPlugin(plugin, treeShakingSharedExcludePlugins)) finalPlugins.push(plugin);
|
|
65716
|
+
});
|
|
65717
|
+
plugins.forEach((plugin)=>{
|
|
65718
|
+
finalPlugins.push(plugin);
|
|
65719
|
+
});
|
|
65720
|
+
finalPlugins.push(extraPlugin);
|
|
65721
|
+
finalPlugins.push(new ConsumeSharedPlugin({
|
|
65722
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
65723
|
+
[key]: {
|
|
65724
|
+
import: extraOptions ? false : options.import,
|
|
65725
|
+
shareKey: options.shareKey || key,
|
|
65726
|
+
shareScope: options.shareScope,
|
|
65727
|
+
requiredVersion: options.requiredVersion,
|
|
65728
|
+
strictVersion: options.strictVersion,
|
|
65729
|
+
singleton: options.singleton,
|
|
65730
|
+
packageName: options.packageName,
|
|
65731
|
+
eager: options.eager
|
|
65732
|
+
}
|
|
65733
|
+
})),
|
|
65734
|
+
enhanced: true
|
|
65735
|
+
}));
|
|
65736
|
+
if (treeShaking) finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports));
|
|
65737
|
+
finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
65738
|
+
const fullOutputDir = (0, path_browserify.resolve)(parentCompiler.outputPath, outputDirWithShareName);
|
|
65739
|
+
const compilerConfig = {
|
|
65740
|
+
...parentConfig,
|
|
65741
|
+
module: {
|
|
65742
|
+
...parentConfig.module,
|
|
65743
|
+
rules: [
|
|
65744
|
+
{
|
|
65745
|
+
test: /virtual-entry\.js$/,
|
|
65746
|
+
type: "javascript/auto",
|
|
65747
|
+
resolve: {
|
|
65748
|
+
fullySpecified: false
|
|
65749
|
+
},
|
|
65750
|
+
use: {
|
|
65751
|
+
loader: 'builtin:swc-loader'
|
|
65752
|
+
}
|
|
65753
|
+
},
|
|
65754
|
+
...parentConfig.module?.rules || []
|
|
65755
|
+
]
|
|
65756
|
+
},
|
|
65757
|
+
mode: parentConfig.mode || 'development',
|
|
65758
|
+
entry: VirtualEntryPlugin.entry,
|
|
65759
|
+
output: {
|
|
65760
|
+
path: fullOutputDir,
|
|
65761
|
+
clean: true,
|
|
65762
|
+
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
65763
|
+
},
|
|
65764
|
+
plugins: finalPlugins,
|
|
65765
|
+
optimization: {
|
|
65766
|
+
...parentConfig.optimization,
|
|
65767
|
+
splitChunks: false
|
|
65768
|
+
}
|
|
65769
|
+
};
|
|
65770
|
+
const compiler = rspack.rspack(compilerConfig);
|
|
65771
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem;
|
|
65772
|
+
compiler.outputFileSystem = parentCompiler.outputFileSystem;
|
|
65773
|
+
compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
65774
|
+
const { currentShare } = extraOptions || {};
|
|
65775
|
+
return new Promise((resolve, reject)=>{
|
|
65776
|
+
compiler.run((err, stats)=>{
|
|
65777
|
+
if (err || stats?.hasErrors()) {
|
|
65778
|
+
const target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
65779
|
+
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n'));
|
|
65780
|
+
reject(err || new Error(`${target} Compile failed`));
|
|
65781
|
+
return;
|
|
65782
|
+
}
|
|
65783
|
+
currentShare && console.log(`${currentShare.shareName} Compile success`);
|
|
65784
|
+
resolve(extraPlugin.getData());
|
|
65785
|
+
});
|
|
65786
|
+
});
|
|
65787
|
+
}
|
|
65788
|
+
}
|
|
65789
|
+
class TreeShakingSharedPlugin {
|
|
65790
|
+
mfConfig;
|
|
65791
|
+
outputDir;
|
|
65792
|
+
secondary;
|
|
65793
|
+
_independentSharePlugin;
|
|
65794
|
+
name = 'TreeShakingSharedPlugin';
|
|
65795
|
+
constructor(options){
|
|
65796
|
+
const { mfConfig, secondary } = options;
|
|
65797
|
+
this.mfConfig = mfConfig;
|
|
65798
|
+
this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages';
|
|
65799
|
+
this.secondary = Boolean(secondary);
|
|
65800
|
+
}
|
|
65801
|
+
apply(compiler) {
|
|
65802
|
+
const { mfConfig, outputDir, secondary } = this;
|
|
65803
|
+
const { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
65804
|
+
if (!shared) return;
|
|
65805
|
+
const sharedOptions = normalizeSharedOptions(shared);
|
|
65806
|
+
if (!sharedOptions.length) return;
|
|
65807
|
+
if (sharedOptions.some(([_, config])=>config.treeShaking && false !== config.import)) {
|
|
65808
|
+
if (!secondary) new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler);
|
|
65809
|
+
this._independentSharePlugin = new IndependentSharedPlugin({
|
|
65810
|
+
name: name,
|
|
65811
|
+
shared: shared,
|
|
65812
|
+
outputDir,
|
|
65813
|
+
plugins: treeShakingSharedPlugins?.map((p)=>{
|
|
65814
|
+
const _constructor = require(p);
|
|
65815
|
+
return new _constructor();
|
|
65816
|
+
}) || [],
|
|
65817
|
+
treeShaking: secondary,
|
|
65818
|
+
library,
|
|
65819
|
+
manifest: mfConfig.manifest,
|
|
65820
|
+
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
65821
|
+
});
|
|
65822
|
+
this._independentSharePlugin.apply(compiler);
|
|
65823
|
+
}
|
|
65824
|
+
}
|
|
65825
|
+
get buildAssets() {
|
|
65826
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
65827
|
+
}
|
|
65828
|
+
}
|
|
65829
|
+
const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
|
|
65830
|
+
class ModuleFederationPlugin {
|
|
65831
|
+
_options;
|
|
65832
|
+
_treeShakingSharedPlugin;
|
|
65833
|
+
constructor(_options){
|
|
65834
|
+
this._options = _options;
|
|
65835
|
+
}
|
|
65836
|
+
apply(compiler) {
|
|
65837
|
+
const { webpack } = compiler;
|
|
65838
|
+
const paths = getPaths(this._options, compiler);
|
|
65839
|
+
compiler.options.resolve.alias = {
|
|
65840
|
+
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
65841
|
+
'@module-federation/runtime': paths.runtime,
|
|
65842
|
+
...compiler.options.resolve.alias
|
|
65843
|
+
};
|
|
65844
|
+
const sharedOptions = getSharedOptions(this._options);
|
|
65845
|
+
const treeShakingEntries = sharedOptions.filter(([, config])=>config.treeShaking);
|
|
65846
|
+
if (treeShakingEntries.length > 0) {
|
|
65847
|
+
this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
|
|
65848
|
+
mfConfig: this._options,
|
|
65849
|
+
secondary: false
|
|
65850
|
+
});
|
|
65851
|
+
this._treeShakingSharedPlugin.apply(compiler);
|
|
65852
|
+
}
|
|
65853
|
+
const asyncStartup = this._options.experiments?.asyncStartup ?? false;
|
|
65854
|
+
const runtimeExperiments = {
|
|
65855
|
+
asyncStartup
|
|
65856
|
+
};
|
|
65857
|
+
let runtimePluginApplied = false;
|
|
65858
|
+
compiler.hooks.beforeRun.tap({
|
|
65859
|
+
name: 'ModuleFederationPlugin',
|
|
65860
|
+
stage: 100
|
|
65861
|
+
}, ()=>{
|
|
65862
|
+
if (runtimePluginApplied) return;
|
|
65863
|
+
runtimePluginApplied = true;
|
|
65864
|
+
const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets);
|
|
65865
|
+
new ModuleFederationRuntimePlugin({
|
|
65866
|
+
entryRuntime,
|
|
65867
|
+
experiments: runtimeExperiments
|
|
65868
|
+
}).apply(compiler);
|
|
65869
|
+
});
|
|
65870
|
+
compiler.hooks.watchRun.tap({
|
|
65871
|
+
name: 'ModuleFederationPlugin',
|
|
65872
|
+
stage: 100
|
|
65873
|
+
}, ()=>{
|
|
65874
|
+
if (runtimePluginApplied) return;
|
|
65875
|
+
runtimePluginApplied = true;
|
|
65876
|
+
const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {});
|
|
65877
|
+
new ModuleFederationRuntimePlugin({
|
|
65878
|
+
entryRuntime,
|
|
65879
|
+
experiments: runtimeExperiments
|
|
65880
|
+
}).apply(compiler);
|
|
65881
|
+
});
|
|
65882
|
+
const v1Options = {
|
|
65883
|
+
name: this._options.name,
|
|
65884
|
+
exposes: this._options.exposes,
|
|
65885
|
+
filename: this._options.filename,
|
|
65886
|
+
library: this._options.library,
|
|
65887
|
+
remoteType: this._options.remoteType,
|
|
65888
|
+
remotes: this._options.remotes,
|
|
65889
|
+
runtime: this._options.runtime,
|
|
65890
|
+
shareScope: this._options.shareScope,
|
|
65891
|
+
shared: this._options.shared,
|
|
65892
|
+
enhanced: true
|
|
65893
|
+
};
|
|
65894
|
+
new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler);
|
|
65895
|
+
if (this._options.manifest) new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
65896
|
+
}
|
|
65254
65897
|
}
|
|
65255
65898
|
function getRemoteInfos(options) {
|
|
65256
65899
|
if (!options.remotes) return {};
|
|
@@ -65318,6 +65961,18 @@ function getRemoteInfos(options) {
|
|
|
65318
65961
|
function getRuntimePlugins(options) {
|
|
65319
65962
|
return options.runtimePlugins ?? [];
|
|
65320
65963
|
}
|
|
65964
|
+
function getSharedOptions(options) {
|
|
65965
|
+
if (!options.shared) return [];
|
|
65966
|
+
return parseOptions(options.shared, (item, key)=>{
|
|
65967
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
65968
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
65969
|
+
import: key,
|
|
65970
|
+
requiredVersion: item
|
|
65971
|
+
} : {
|
|
65972
|
+
import: item
|
|
65973
|
+
};
|
|
65974
|
+
}, (item)=>item);
|
|
65975
|
+
}
|
|
65321
65976
|
function getPaths(options, compiler) {
|
|
65322
65977
|
return {
|
|
65323
65978
|
runtimeTools: '@module-federation/runtime-tools',
|
|
@@ -65325,11 +65980,12 @@ function getPaths(options, compiler) {
|
|
|
65325
65980
|
runtime: '@module-federation/runtime'
|
|
65326
65981
|
};
|
|
65327
65982
|
}
|
|
65328
|
-
function getDefaultEntryRuntime(paths, options, compiler) {
|
|
65983
|
+
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
65329
65984
|
const runtimePlugins = getRuntimePlugins(options);
|
|
65330
65985
|
const remoteInfos = getRemoteInfos(options);
|
|
65331
65986
|
const runtimePluginImports = [];
|
|
65332
65987
|
const runtimePluginVars = [];
|
|
65988
|
+
const libraryType = options.library?.type || 'var';
|
|
65333
65989
|
for(let i = 0; i < runtimePlugins.length; i++){
|
|
65334
65990
|
const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
|
|
65335
65991
|
const pluginSpec = runtimePlugins[i];
|
|
@@ -65346,182 +66002,12 @@ function getDefaultEntryRuntime(paths, options, compiler) {
|
|
|
65346
66002
|
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
65347
66003
|
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
65348
66004
|
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
65349
|
-
|
|
66005
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
66006
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
66007
|
+
'if((__webpack_require__.initializeSharingData||__webpack_require__.initializeExposesData)&&__webpack_require__.federation){var _ref,_ref1,_ref2,_ref3,_ref4;var __webpack_require___remotesLoadingData,__webpack_require___remotesLoadingData1,__webpack_require___initializeSharingData,__webpack_require___consumesLoadingData,__webpack_require___consumesLoadingData1,__webpack_require___initializeExposesData,__webpack_require___consumesLoadingData2;const override=(obj,key,value)=>{if(!obj)return;if(obj[key])obj[key]=value};const merge=(obj,key,fn)=>{const value=fn();if(Array.isArray(value)){var _obj,_key,_;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=[];obj[key].push(...value)}else if(typeof value==="object"&&value!==null){var _obj1,_key1,_1;(_1=(_obj1=obj)[_key1=key])!==null&&_1!==void 0?_1:_obj1[_key1]={};Object.assign(obj[key],value)}};const early=(obj,key,initial)=>{var _obj,_key,_;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=initial()};const remotesLoadingChunkMapping=(_ref=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&_ref!==void 0?_ref:{};const remotesLoadingModuleIdToRemoteDataMapping=(_ref1=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&_ref1!==void 0?_ref1:{};const initializeSharingScopeToInitDataMapping=(_ref2=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&_ref2!==void 0?_ref2:{};const consumesLoadingChunkMapping=(_ref3=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&_ref3!==void 0?_ref3:{};const consumesLoadingModuleToConsumeDataMapping=(_ref4=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&_ref4!==void 0?_ref4:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens={};const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"libraryType",()=>__module_federation_library_type__);early(__webpack_require__.federation,"sharedFallback",()=>__module_federation_share_fallbacks__);const sharedFallback=__webpack_require__.federation.sharedFallback;early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){var __webpack_require___federation_bundlerRuntime;consumesLoadingModuleToHandlerMapping[moduleId]={getter:sharedFallback?(__webpack_require___federation_bundlerRuntime=__webpack_require__.federation.bundlerRuntime)===null||__webpack_require___federation_bundlerRuntime===void 0?void 0:__webpack_require___federation_bundlerRuntime.getSharedFallbackGetter({shareKey:data.shareKey,factory:data.fallback,webpackRequire:__webpack_require__,libraryType:__webpack_require__.federation.libraryType}):data.fallback,treeShakingGetter:sharedFallback?data.fallback:undefined,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey,treeShaking:__webpack_require__.federation.sharedFallback?{get:data.fallback,mode:data.treeShakingMode}:undefined}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shareStrategy",()=>__module_federation_share_strategy__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion,treeShakingMode}=stage;const shareConfig={};const isValidValue=function(val){return typeof val!=="undefined"};if(isValidValue(singleton)){shareConfig.singleton=singleton}if(isValidValue(requiredVersion)){shareConfig.requiredVersion=requiredVersion}if(isValidValue(eager)){shareConfig.eager=eager}if(isValidValue(strictVersion)){shareConfig.strictVersion=strictVersion}const options={version,scope:[scope],shareConfig,get:factory,treeShaking:treeShakingMode?{mode:treeShakingMode}:undefined};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>__module_federation_remote_infos__);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module)?moduleMap[module]():Promise.resolve().then(()=>{throw new Error(\'Module "\'+module+\'" does not exist in container.\')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.bundlerRuntime.init({webpackRequire:__webpack_require__});if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}'
|
|
65350
66008
|
].join(';');
|
|
65351
66009
|
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
65352
66010
|
}
|
|
65353
|
-
const compilerSet = new WeakSet();
|
|
65354
|
-
function isSingleton(compiler) {
|
|
65355
|
-
return compilerSet.has(compiler);
|
|
65356
|
-
}
|
|
65357
|
-
function setSingleton(compiler) {
|
|
65358
|
-
compilerSet.add(compiler);
|
|
65359
|
-
}
|
|
65360
|
-
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
65361
|
-
enhanced;
|
|
65362
|
-
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ShareRuntimePlugin;
|
|
65363
|
-
constructor(enhanced = false){
|
|
65364
|
-
super(), this.enhanced = enhanced;
|
|
65365
|
-
}
|
|
65366
|
-
raw(compiler) {
|
|
65367
|
-
if (isSingleton(compiler)) return;
|
|
65368
|
-
setSingleton(compiler);
|
|
65369
|
-
return createBuiltinPlugin(this.name, this.enhanced);
|
|
65370
|
-
}
|
|
65371
|
-
}
|
|
65372
|
-
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
65373
|
-
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin;
|
|
65374
|
-
_options;
|
|
65375
|
-
constructor(options){
|
|
65376
|
-
super();
|
|
65377
|
-
this._options = {
|
|
65378
|
-
consumes: parseOptions(options.consumes, (item, key)=>{
|
|
65379
|
-
if (Array.isArray(item)) throw new Error('Unexpected array in options');
|
|
65380
|
-
const result = item !== key && isRequiredVersion(item) ? {
|
|
65381
|
-
import: key,
|
|
65382
|
-
shareScope: options.shareScope || 'default',
|
|
65383
|
-
shareKey: key,
|
|
65384
|
-
requiredVersion: item,
|
|
65385
|
-
strictVersion: true,
|
|
65386
|
-
packageName: void 0,
|
|
65387
|
-
singleton: false,
|
|
65388
|
-
eager: false
|
|
65389
|
-
} : {
|
|
65390
|
-
import: key,
|
|
65391
|
-
shareScope: options.shareScope || 'default',
|
|
65392
|
-
shareKey: key,
|
|
65393
|
-
requiredVersion: void 0,
|
|
65394
|
-
packageName: void 0,
|
|
65395
|
-
strictVersion: false,
|
|
65396
|
-
singleton: false,
|
|
65397
|
-
eager: false
|
|
65398
|
-
};
|
|
65399
|
-
return result;
|
|
65400
|
-
}, (item, key)=>({
|
|
65401
|
-
import: false === item.import ? void 0 : item.import || key,
|
|
65402
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
65403
|
-
shareKey: item.shareKey || key,
|
|
65404
|
-
requiredVersion: item.requiredVersion,
|
|
65405
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
|
|
65406
|
-
packageName: item.packageName,
|
|
65407
|
-
singleton: !!item.singleton,
|
|
65408
|
-
eager: !!item.eager
|
|
65409
|
-
})),
|
|
65410
|
-
enhanced: options.enhanced ?? false
|
|
65411
|
-
};
|
|
65412
|
-
}
|
|
65413
|
-
raw(compiler) {
|
|
65414
|
-
new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
65415
|
-
const rawOptions = {
|
|
65416
|
-
consumes: this._options.consumes.map(([key, v])=>({
|
|
65417
|
-
key,
|
|
65418
|
-
...v
|
|
65419
|
-
})),
|
|
65420
|
-
enhanced: this._options.enhanced
|
|
65421
|
-
};
|
|
65422
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
65423
|
-
}
|
|
65424
|
-
}
|
|
65425
|
-
class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
65426
|
-
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ProvideSharedPlugin;
|
|
65427
|
-
_provides;
|
|
65428
|
-
_enhanced;
|
|
65429
|
-
constructor(options){
|
|
65430
|
-
super();
|
|
65431
|
-
this._provides = parseOptions(options.provides, (item)=>{
|
|
65432
|
-
if (Array.isArray(item)) throw new Error('Unexpected array of provides');
|
|
65433
|
-
return {
|
|
65434
|
-
shareKey: item,
|
|
65435
|
-
version: void 0,
|
|
65436
|
-
shareScope: options.shareScope || 'default',
|
|
65437
|
-
eager: false
|
|
65438
|
-
};
|
|
65439
|
-
}, (item)=>{
|
|
65440
|
-
const raw = {
|
|
65441
|
-
shareKey: item.shareKey,
|
|
65442
|
-
version: item.version,
|
|
65443
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
65444
|
-
eager: !!item.eager
|
|
65445
|
-
};
|
|
65446
|
-
if (options.enhanced) {
|
|
65447
|
-
const enhancedItem = item;
|
|
65448
|
-
return {
|
|
65449
|
-
...raw,
|
|
65450
|
-
singleton: enhancedItem.singleton,
|
|
65451
|
-
requiredVersion: enhancedItem.requiredVersion,
|
|
65452
|
-
strictVersion: enhancedItem.strictVersion
|
|
65453
|
-
};
|
|
65454
|
-
}
|
|
65455
|
-
return raw;
|
|
65456
|
-
});
|
|
65457
|
-
this._enhanced = options.enhanced;
|
|
65458
|
-
}
|
|
65459
|
-
raw(compiler) {
|
|
65460
|
-
new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
|
|
65461
|
-
const rawOptions = this._provides.map(([key, v])=>({
|
|
65462
|
-
key,
|
|
65463
|
-
...v
|
|
65464
|
-
}));
|
|
65465
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
65466
|
-
}
|
|
65467
|
-
}
|
|
65468
|
-
class SharePlugin {
|
|
65469
|
-
_shareScope;
|
|
65470
|
-
_consumes;
|
|
65471
|
-
_provides;
|
|
65472
|
-
_enhanced;
|
|
65473
|
-
constructor(options){
|
|
65474
|
-
const sharedOptions = parseOptions(options.shared, (item, key)=>{
|
|
65475
|
-
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
65476
|
-
const config = item !== key && isRequiredVersion(item) ? {
|
|
65477
|
-
import: key,
|
|
65478
|
-
requiredVersion: item
|
|
65479
|
-
} : {
|
|
65480
|
-
import: item
|
|
65481
|
-
};
|
|
65482
|
-
return config;
|
|
65483
|
-
}, (item)=>item);
|
|
65484
|
-
const consumes = sharedOptions.map(([key, options])=>({
|
|
65485
|
-
[key]: {
|
|
65486
|
-
import: options.import,
|
|
65487
|
-
shareKey: options.shareKey || key,
|
|
65488
|
-
shareScope: options.shareScope,
|
|
65489
|
-
requiredVersion: options.requiredVersion,
|
|
65490
|
-
strictVersion: options.strictVersion,
|
|
65491
|
-
singleton: options.singleton,
|
|
65492
|
-
packageName: options.packageName,
|
|
65493
|
-
eager: options.eager
|
|
65494
|
-
}
|
|
65495
|
-
}));
|
|
65496
|
-
const provides = sharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
|
|
65497
|
-
[options.import || key]: {
|
|
65498
|
-
shareKey: options.shareKey || key,
|
|
65499
|
-
shareScope: options.shareScope,
|
|
65500
|
-
version: options.version,
|
|
65501
|
-
eager: options.eager,
|
|
65502
|
-
singleton: options.singleton,
|
|
65503
|
-
requiredVersion: options.requiredVersion,
|
|
65504
|
-
strictVersion: options.strictVersion
|
|
65505
|
-
}
|
|
65506
|
-
}));
|
|
65507
|
-
this._shareScope = options.shareScope;
|
|
65508
|
-
this._consumes = consumes;
|
|
65509
|
-
this._provides = provides;
|
|
65510
|
-
this._enhanced = options.enhanced ?? false;
|
|
65511
|
-
}
|
|
65512
|
-
apply(compiler) {
|
|
65513
|
-
new ConsumeSharedPlugin({
|
|
65514
|
-
shareScope: this._shareScope,
|
|
65515
|
-
consumes: this._consumes,
|
|
65516
|
-
enhanced: this._enhanced
|
|
65517
|
-
}).apply(compiler);
|
|
65518
|
-
new ProvideSharedPlugin({
|
|
65519
|
-
shareScope: this._shareScope,
|
|
65520
|
-
provides: this._provides,
|
|
65521
|
-
enhanced: this._enhanced
|
|
65522
|
-
}).apply(compiler);
|
|
65523
|
-
}
|
|
65524
|
-
}
|
|
65525
66011
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
65526
66012
|
name = external_rspack_wasi_browser_js_.BuiltinPluginName.ContainerPlugin;
|
|
65527
66013
|
_options;
|
|
@@ -65531,7 +66017,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
65531
66017
|
name: options.name,
|
|
65532
66018
|
shareScope: options.shareScope || 'default',
|
|
65533
66019
|
library: options.library || {
|
|
65534
|
-
type: '
|
|
66020
|
+
type: 'global',
|
|
65535
66021
|
name: options.name
|
|
65536
66022
|
},
|
|
65537
66023
|
runtime: options.runtime,
|
|
@@ -65673,7 +66159,7 @@ function transformSync(source, options) {
|
|
|
65673
66159
|
const _options = JSON.stringify(options || {});
|
|
65674
66160
|
return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
|
|
65675
66161
|
}
|
|
65676
|
-
const exports_rspackVersion = "2.0.0-beta.
|
|
66162
|
+
const exports_rspackVersion = "2.0.0-beta.2";
|
|
65677
66163
|
const exports_version = "5.75.0";
|
|
65678
66164
|
const exports_WebpackError = Error;
|
|
65679
66165
|
const exports_config = {
|
|
@@ -65723,6 +66209,7 @@ const container = {
|
|
|
65723
66209
|
};
|
|
65724
66210
|
const sharing = {
|
|
65725
66211
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
66212
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
65726
66213
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
65727
66214
|
SharePlugin: SharePlugin
|
|
65728
66215
|
};
|
|
@@ -65760,7 +66247,7 @@ const exports_experiments = {
|
|
|
65760
66247
|
VirtualModulesPlugin: VirtualModulesPlugin,
|
|
65761
66248
|
rsc: rsc
|
|
65762
66249
|
};
|
|
65763
|
-
const src_fn = Object.assign(
|
|
66250
|
+
const src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
|
|
65764
66251
|
src_fn.rspack = src_fn;
|
|
65765
66252
|
src_fn.webpack = src_fn;
|
|
65766
66253
|
const src_rspack_0 = src_fn;
|