@rspack-debug/core 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/compiled/@rspack/lite-tapable/dist/index.d.ts +175 -0
- package/compiled/@rspack/lite-tapable/license +22 -0
- package/compiled/@rspack/lite-tapable/package.json +1 -0
- package/dist/Compilation.d.ts +2 -1
- package/dist/Compiler.d.ts +1 -1
- package/dist/ContextModuleFactory.d.ts +1 -1
- package/dist/MultiCompiler.d.ts +1 -1
- package/dist/MultiWatching.d.ts +1 -1
- package/dist/NormalModule.d.ts +1 -2
- package/dist/NormalModuleFactory.d.ts +1 -1
- package/dist/RuntimeGlobals.d.ts +1 -1
- package/dist/Watching.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RsdoctorPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/html-plugin/hooks.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.d.ts +1 -1
- package/dist/index.js +1196 -355
- package/dist/lib/Cache.d.ts +1 -1
- package/dist/lib/HookWebpackError.d.ts +1 -1
- package/dist/moduleFederationDefaultRuntime.js +1 -1
- package/dist/rspack.d.ts +1 -1
- 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/stats/StatsFactory.d.ts +1 -1
- package/dist/stats/StatsPrinter.d.ts +1 -1
- package/dist/taps/types.d.ts +1 -1
- package/dist/util/createHash.d.ts +1 -1
- package/dist/worker.js +0 -16
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import * as __rspack_external_process from "process";
|
|
|
3
3
|
import { createRequire as __rspack_createRequire, createRequire } from "node:module";
|
|
4
4
|
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
5
5
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
6
|
-
import { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook, AsyncSeriesWaterfallHook, HookMap, MultiHook, SyncBailHook, SyncHook, SyncWaterfallHook, maxStage, minStage, safeStage } from "@rspack/lite-tapable";
|
|
7
6
|
import node_util, { format as external_node_util_format, inspect, promisify } from "node:util";
|
|
8
7
|
import node_path, { isAbsolute, join, relative, resolve as external_node_path_resolve, sep } from "node:path";
|
|
9
8
|
import node_querystring from "node:querystring";
|
|
@@ -302,6 +301,479 @@ __webpack_require__.r(ModuleFilenameHelpers_namespaceObject), __webpack_require_
|
|
|
302
301
|
});
|
|
303
302
|
let binding_namespaceObject = __rspack_createRequire_require(process.env.RSPACK_BINDING ? process.env.RSPACK_BINDING : "@rspack/binding");
|
|
304
303
|
var binding_default = __webpack_require__.n(binding_namespaceObject);
|
|
304
|
+
function _define_property(obj, key, value) {
|
|
305
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
306
|
+
value: value,
|
|
307
|
+
enumerable: !0,
|
|
308
|
+
configurable: !0,
|
|
309
|
+
writable: !0
|
|
310
|
+
}) : obj[key] = value, obj;
|
|
311
|
+
}
|
|
312
|
+
class HookBase {
|
|
313
|
+
intercept(interceptor) {
|
|
314
|
+
if (this.interceptors.push(Object.assign({}, interceptor)), interceptor.register) for(let i = 0; i < this.taps.length; i++)this.taps[i] = interceptor.register(this.taps[i]);
|
|
315
|
+
}
|
|
316
|
+
_runRegisterInterceptors(options) {
|
|
317
|
+
return this.interceptors.reduce((options, interceptor)=>interceptor.register?.(options) ?? options, options);
|
|
318
|
+
}
|
|
319
|
+
_runCallInterceptors(...args) {
|
|
320
|
+
for (let interceptor of this.interceptors)interceptor.call && interceptor.call(...args);
|
|
321
|
+
}
|
|
322
|
+
_runErrorInterceptors(e) {
|
|
323
|
+
for (let interceptor of this.interceptors)interceptor.error && interceptor.error(e);
|
|
324
|
+
}
|
|
325
|
+
_runTapInterceptors(tap) {
|
|
326
|
+
for (let interceptor of this.interceptors)interceptor.tap && interceptor.tap(tap);
|
|
327
|
+
}
|
|
328
|
+
_runDoneInterceptors() {
|
|
329
|
+
for (let interceptor of this.interceptors)interceptor.done && interceptor.done();
|
|
330
|
+
}
|
|
331
|
+
_runResultInterceptors(r) {
|
|
332
|
+
for (let interceptor of this.interceptors)interceptor.result && interceptor.result(r);
|
|
333
|
+
}
|
|
334
|
+
withOptions(options) {
|
|
335
|
+
let mergeOptions = (opt)=>Object.assign({}, options, 'string' == typeof opt ? {
|
|
336
|
+
name: opt
|
|
337
|
+
} : opt);
|
|
338
|
+
return {
|
|
339
|
+
name: this.name,
|
|
340
|
+
tap: (opt, fn)=>this.tap(mergeOptions(opt), fn),
|
|
341
|
+
tapAsync: (opt, fn)=>this.tapAsync(mergeOptions(opt), fn),
|
|
342
|
+
tapPromise: (opt, fn)=>this.tapPromise(mergeOptions(opt), fn),
|
|
343
|
+
intercept: (interceptor)=>this.intercept(interceptor),
|
|
344
|
+
isUsed: ()=>this.isUsed(),
|
|
345
|
+
withOptions: (opt)=>this.withOptions(mergeOptions(opt)),
|
|
346
|
+
queryStageRange: (stageRange)=>this.queryStageRange(stageRange)
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
isUsed() {
|
|
350
|
+
return this.taps.length > 0 || this.interceptors.length > 0;
|
|
351
|
+
}
|
|
352
|
+
queryStageRange(stageRange) {
|
|
353
|
+
return new QueriedHook(stageRange, this);
|
|
354
|
+
}
|
|
355
|
+
callAsyncStageRange(queried) {
|
|
356
|
+
throw Error('Hook should implement there own _callAsyncStageRange');
|
|
357
|
+
}
|
|
358
|
+
callAsync(...args) {
|
|
359
|
+
return this.callAsyncStageRange(this.queryStageRange(allStageRange), ...args);
|
|
360
|
+
}
|
|
361
|
+
promiseStageRange(queried, ...args) {
|
|
362
|
+
return new Promise((resolve, reject)=>{
|
|
363
|
+
this.callAsyncStageRange(queried, ...args, (e, r)=>e ? reject(e) : resolve(r));
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
promise(...args) {
|
|
367
|
+
return this.promiseStageRange(this.queryStageRange(allStageRange), ...args);
|
|
368
|
+
}
|
|
369
|
+
tap(options, fn) {
|
|
370
|
+
this._tap('sync', options, fn);
|
|
371
|
+
}
|
|
372
|
+
tapAsync(options, fn) {
|
|
373
|
+
this._tap('async', options, fn);
|
|
374
|
+
}
|
|
375
|
+
tapPromise(options, fn) {
|
|
376
|
+
this._tap('promise', options, fn);
|
|
377
|
+
}
|
|
378
|
+
_tap(type, options, fn) {
|
|
379
|
+
let normalizedOptions = options;
|
|
380
|
+
if ('string' == typeof options) normalizedOptions = {
|
|
381
|
+
name: options.trim()
|
|
382
|
+
};
|
|
383
|
+
else if ('object' != typeof options || null === options) throw Error('Invalid tap options');
|
|
384
|
+
if ('string' != typeof normalizedOptions.name || '' === normalizedOptions.name) throw Error('Missing name for tap');
|
|
385
|
+
this._insert(this._runRegisterInterceptors(Object.assign({
|
|
386
|
+
type,
|
|
387
|
+
fn
|
|
388
|
+
}, normalizedOptions)));
|
|
389
|
+
}
|
|
390
|
+
_insert(item) {
|
|
391
|
+
let before;
|
|
392
|
+
'string' == typeof item.before ? before = new Set([
|
|
393
|
+
item.before
|
|
394
|
+
]) : Array.isArray(item.before) && (before = new Set(item.before));
|
|
395
|
+
let stage = 0;
|
|
396
|
+
'number' == typeof item.stage && (stage = item.stage);
|
|
397
|
+
let i = this.taps.length;
|
|
398
|
+
for(; i > 0;){
|
|
399
|
+
i--;
|
|
400
|
+
let x = this.taps[i];
|
|
401
|
+
this.taps[i + 1] = x;
|
|
402
|
+
let xStage = x.stage || 0;
|
|
403
|
+
if (before) {
|
|
404
|
+
if (before.has(x.name)) {
|
|
405
|
+
before.delete(x.name);
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (before.size > 0) continue;
|
|
409
|
+
}
|
|
410
|
+
if (!(xStage > stage)) {
|
|
411
|
+
i++;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
this.taps[i] = item;
|
|
416
|
+
}
|
|
417
|
+
_prepareArgs(args) {
|
|
418
|
+
let len = this.args.length;
|
|
419
|
+
return args.length < len ? (args.length = len, args.fill(void 0, args.length, len)) : (args.length > len && (args.length = len), args);
|
|
420
|
+
}
|
|
421
|
+
constructor(args = [], name){
|
|
422
|
+
_define_property(this, "args", void 0), _define_property(this, "name", void 0), _define_property(this, "taps", void 0), _define_property(this, "interceptors", void 0), this.args = args, this.name = name, this.taps = [], this.interceptors = [];
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
let minStage = -1 / 0, maxStage = 1 / 0, allStageRange = [
|
|
426
|
+
minStage,
|
|
427
|
+
1 / 0
|
|
428
|
+
], i32MAX = 2147483648 - 1, safeStage = (stage)=>stage < -2147483648 ? -2147483648 : stage > i32MAX ? i32MAX : stage;
|
|
429
|
+
class QueriedHook {
|
|
430
|
+
isUsed() {
|
|
431
|
+
return !!(this.tapsInRange.length > 0 || this.stageRange[0] === minStage && this.hook.interceptors.some((i)=>i.call) || this.stageRange[1] === maxStage && this.hook.interceptors.some((i)=>i.done));
|
|
432
|
+
}
|
|
433
|
+
call(...args) {
|
|
434
|
+
if ('function' != typeof this.hook.callStageRange) throw Error('hook is not a SyncHook, call methods only exists on SyncHook');
|
|
435
|
+
return this.hook.callStageRange(this, ...args);
|
|
436
|
+
}
|
|
437
|
+
callAsync(...args) {
|
|
438
|
+
return this.hook.callAsyncStageRange(this, ...args);
|
|
439
|
+
}
|
|
440
|
+
promise(...args) {
|
|
441
|
+
return this.hook.promiseStageRange(this, ...args);
|
|
442
|
+
}
|
|
443
|
+
constructor(stageRange, hook){
|
|
444
|
+
_define_property(this, "stageRange", void 0), _define_property(this, "hook", void 0), _define_property(this, "tapsInRange", void 0);
|
|
445
|
+
let tapsInRange = [], [from, to] = stageRange;
|
|
446
|
+
for (let tap of hook.taps){
|
|
447
|
+
let stage = tap.stage ?? 0;
|
|
448
|
+
from <= stage && stage < to ? tapsInRange.push(tap) : to === maxStage && stage === maxStage && tapsInRange.push(tap);
|
|
449
|
+
}
|
|
450
|
+
this.stageRange = stageRange, this.hook = hook, this.tapsInRange = tapsInRange;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
class SyncHook extends HookBase {
|
|
454
|
+
callAsyncStageRange(queried, ...args) {
|
|
455
|
+
let { stageRange: [from, to], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
456
|
+
for (let tap of (from === minStage && this._runCallInterceptors(...args2), tapsInRange)){
|
|
457
|
+
this._runTapInterceptors(tap);
|
|
458
|
+
try {
|
|
459
|
+
tap.fn(...args2);
|
|
460
|
+
} catch (e) {
|
|
461
|
+
return this._runErrorInterceptors(e), cb(e);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
to === maxStage && (this._runDoneInterceptors(), cb(null));
|
|
465
|
+
}
|
|
466
|
+
call(...args) {
|
|
467
|
+
return this.callStageRange(this.queryStageRange(allStageRange), ...args);
|
|
468
|
+
}
|
|
469
|
+
callStageRange(queried, ...args) {
|
|
470
|
+
let result, error;
|
|
471
|
+
if (this.callAsyncStageRange(queried, ...args, (e, r)=>{
|
|
472
|
+
error = e, result = r;
|
|
473
|
+
}), error) throw error;
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
tapAsync() {
|
|
477
|
+
throw Error('tapAsync is not supported on a SyncHook');
|
|
478
|
+
}
|
|
479
|
+
tapPromise() {
|
|
480
|
+
throw Error('tapPromise is not supported on a SyncHook');
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
class SyncBailHook extends HookBase {
|
|
484
|
+
callAsyncStageRange(queried, ...args) {
|
|
485
|
+
let { stageRange: [from, to], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
486
|
+
for (let tap of (from === minStage && this._runCallInterceptors(...args2), tapsInRange)){
|
|
487
|
+
let r;
|
|
488
|
+
this._runTapInterceptors(tap);
|
|
489
|
+
try {
|
|
490
|
+
r = tap.fn(...args2);
|
|
491
|
+
} catch (e) {
|
|
492
|
+
return this._runErrorInterceptors(e), cb(e);
|
|
493
|
+
}
|
|
494
|
+
if (void 0 !== r) return this._runResultInterceptors(r), cb(null, r);
|
|
495
|
+
}
|
|
496
|
+
to === maxStage && (this._runDoneInterceptors(), cb(null));
|
|
497
|
+
}
|
|
498
|
+
call(...args) {
|
|
499
|
+
return this.callStageRange(this.queryStageRange(allStageRange), ...args);
|
|
500
|
+
}
|
|
501
|
+
callStageRange(queried, ...args) {
|
|
502
|
+
let result, error;
|
|
503
|
+
if (this.callAsyncStageRange(queried, ...args, (e, r)=>{
|
|
504
|
+
error = e, result = r;
|
|
505
|
+
}), error) throw error;
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
tapAsync() {
|
|
509
|
+
throw Error('tapAsync is not supported on a SyncBailHook');
|
|
510
|
+
}
|
|
511
|
+
tapPromise() {
|
|
512
|
+
throw Error('tapPromise is not supported on a SyncBailHook');
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
class SyncWaterfallHook extends HookBase {
|
|
516
|
+
callAsyncStageRange(queried, ...args) {
|
|
517
|
+
let { stageRange: [from, to], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
518
|
+
for (let tap of (from === minStage && this._runCallInterceptors(...args2), tapsInRange)){
|
|
519
|
+
this._runTapInterceptors(tap);
|
|
520
|
+
try {
|
|
521
|
+
let r = tap.fn(...args2);
|
|
522
|
+
void 0 !== r && (args2[0] = r);
|
|
523
|
+
} catch (e) {
|
|
524
|
+
return this._runErrorInterceptors(e), cb(e);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
to === maxStage && (this._runDoneInterceptors(), cb(null, args2[0]));
|
|
528
|
+
}
|
|
529
|
+
call(...args) {
|
|
530
|
+
return this.callStageRange(this.queryStageRange(allStageRange), ...args);
|
|
531
|
+
}
|
|
532
|
+
callStageRange(queried, ...args) {
|
|
533
|
+
let result, error;
|
|
534
|
+
if (this.callAsyncStageRange(queried, ...args, (e, r)=>{
|
|
535
|
+
error = e, result = r;
|
|
536
|
+
}), error) throw error;
|
|
537
|
+
return result;
|
|
538
|
+
}
|
|
539
|
+
tapAsync() {
|
|
540
|
+
throw Error('tapAsync is not supported on a SyncWaterfallHook');
|
|
541
|
+
}
|
|
542
|
+
tapPromise() {
|
|
543
|
+
throw Error('tapPromise is not supported on a SyncWaterfallHook');
|
|
544
|
+
}
|
|
545
|
+
constructor(args = [], name){
|
|
546
|
+
if (args.length < 1) throw Error('Waterfall hooks must have at least one argument');
|
|
547
|
+
super(args, name);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
class AsyncParallelHook extends HookBase {
|
|
551
|
+
callAsyncStageRange(queried, ...args) {
|
|
552
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
553
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
554
|
+
let done = ()=>{
|
|
555
|
+
this._runDoneInterceptors(), cb(null);
|
|
556
|
+
}, error = (e)=>{
|
|
557
|
+
this._runErrorInterceptors(e), cb(e);
|
|
558
|
+
};
|
|
559
|
+
if (0 === tapsInRange.length) return done();
|
|
560
|
+
let counter = tapsInRange.length;
|
|
561
|
+
for (let tap of tapsInRange){
|
|
562
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
563
|
+
let promise = tap.fn(...args2);
|
|
564
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
565
|
+
promise.then(()=>{
|
|
566
|
+
0 == (counter -= 1) && done();
|
|
567
|
+
}, (e)=>{
|
|
568
|
+
counter = 0, error(e);
|
|
569
|
+
});
|
|
570
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e)=>{
|
|
571
|
+
e ? (counter = 0, error(e)) : 0 == (counter -= 1) && done();
|
|
572
|
+
});
|
|
573
|
+
else {
|
|
574
|
+
let hasError = !1;
|
|
575
|
+
try {
|
|
576
|
+
tap.fn(...args2);
|
|
577
|
+
} catch (e) {
|
|
578
|
+
hasError = !0, counter = 0, error(e);
|
|
579
|
+
}
|
|
580
|
+
hasError || 0 != --counter || done();
|
|
581
|
+
}
|
|
582
|
+
if (counter <= 0) return;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
class AsyncSeriesHook extends HookBase {
|
|
587
|
+
callAsyncStageRange(queried, ...args) {
|
|
588
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
589
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
590
|
+
let done = ()=>{
|
|
591
|
+
this._runDoneInterceptors(), cb(null);
|
|
592
|
+
}, error = (e)=>{
|
|
593
|
+
this._runErrorInterceptors(e), cb(e);
|
|
594
|
+
};
|
|
595
|
+
if (0 === tapsInRange.length) return done();
|
|
596
|
+
let index = 0, next = ()=>{
|
|
597
|
+
let tap = tapsInRange[index];
|
|
598
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
599
|
+
let promise = tap.fn(...args2);
|
|
600
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
601
|
+
promise.then(()=>{
|
|
602
|
+
(index += 1) === tapsInRange.length ? done() : next();
|
|
603
|
+
}, (e)=>{
|
|
604
|
+
index = tapsInRange.length, error(e);
|
|
605
|
+
});
|
|
606
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e)=>{
|
|
607
|
+
e ? (index = tapsInRange.length, error(e)) : (index += 1) === tapsInRange.length ? done() : next();
|
|
608
|
+
});
|
|
609
|
+
else {
|
|
610
|
+
let hasError = !1;
|
|
611
|
+
try {
|
|
612
|
+
tap.fn(...args2);
|
|
613
|
+
} catch (e) {
|
|
614
|
+
hasError = !0, index = tapsInRange.length, error(e);
|
|
615
|
+
}
|
|
616
|
+
hasError || ((index += 1) === tapsInRange.length ? done() : next());
|
|
617
|
+
}
|
|
618
|
+
if (index === tapsInRange.length) return;
|
|
619
|
+
};
|
|
620
|
+
next();
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
class AsyncSeriesBailHook extends HookBase {
|
|
624
|
+
callAsyncStageRange(queried, ...args) {
|
|
625
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
626
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
627
|
+
let done = ()=>{
|
|
628
|
+
this._runDoneInterceptors(), cb(null);
|
|
629
|
+
}, error = (e)=>{
|
|
630
|
+
this._runErrorInterceptors(e), cb(e);
|
|
631
|
+
}, result = (r)=>{
|
|
632
|
+
this._runResultInterceptors(r), cb(null, r);
|
|
633
|
+
};
|
|
634
|
+
if (0 === tapsInRange.length) return done();
|
|
635
|
+
let index = 0, next = ()=>{
|
|
636
|
+
let tap = tapsInRange[index];
|
|
637
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
638
|
+
let promise = tap.fn(...args2);
|
|
639
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
640
|
+
promise.then((r)=>{
|
|
641
|
+
index += 1, void 0 !== r ? result(r) : index === tapsInRange.length ? done() : next();
|
|
642
|
+
}, (e)=>{
|
|
643
|
+
index = tapsInRange.length, error(e);
|
|
644
|
+
});
|
|
645
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e, r)=>{
|
|
646
|
+
e ? (index = tapsInRange.length, error(e)) : (index += 1, void 0 !== r ? result(r) : index === tapsInRange.length ? done() : next());
|
|
647
|
+
});
|
|
648
|
+
else {
|
|
649
|
+
let r, hasError = !1;
|
|
650
|
+
try {
|
|
651
|
+
r = tap.fn(...args2);
|
|
652
|
+
} catch (e) {
|
|
653
|
+
hasError = !0, index = tapsInRange.length, error(e);
|
|
654
|
+
}
|
|
655
|
+
hasError || (index += 1, void 0 !== r ? result(r) : index === tapsInRange.length ? done() : next());
|
|
656
|
+
}
|
|
657
|
+
if (index === tapsInRange.length) return;
|
|
658
|
+
};
|
|
659
|
+
next();
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
class AsyncSeriesWaterfallHook extends HookBase {
|
|
663
|
+
callAsyncStageRange(queried, ...args) {
|
|
664
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
665
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
666
|
+
let result = (r)=>{
|
|
667
|
+
this._runResultInterceptors(r), cb(null, r);
|
|
668
|
+
}, error = (e)=>{
|
|
669
|
+
this._runErrorInterceptors(e), cb(e);
|
|
670
|
+
};
|
|
671
|
+
if (0 === tapsInRange.length) return result(args2[0]);
|
|
672
|
+
let index = 0, next = ()=>{
|
|
673
|
+
let tap = tapsInRange[index];
|
|
674
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
675
|
+
let promise = tap.fn(...args2);
|
|
676
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
677
|
+
promise.then((r)=>{
|
|
678
|
+
index += 1, void 0 !== r && (args2[0] = r), index === tapsInRange.length ? result(args2[0]) : next();
|
|
679
|
+
}, (e)=>{
|
|
680
|
+
index = tapsInRange.length, error(e);
|
|
681
|
+
});
|
|
682
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e, r)=>{
|
|
683
|
+
e ? (index = tapsInRange.length, error(e)) : (index += 1, void 0 !== r && (args2[0] = r), index === tapsInRange.length ? result(args2[0]) : next());
|
|
684
|
+
});
|
|
685
|
+
else {
|
|
686
|
+
let hasError = !1;
|
|
687
|
+
try {
|
|
688
|
+
let r = tap.fn(...args2);
|
|
689
|
+
void 0 !== r && (args2[0] = r);
|
|
690
|
+
} catch (e) {
|
|
691
|
+
hasError = !0, index = tapsInRange.length, error(e);
|
|
692
|
+
}
|
|
693
|
+
hasError || ((index += 1) === tapsInRange.length ? result(args2[0]) : next());
|
|
694
|
+
}
|
|
695
|
+
if (index === tapsInRange.length) return;
|
|
696
|
+
};
|
|
697
|
+
next();
|
|
698
|
+
}
|
|
699
|
+
constructor(args = [], name){
|
|
700
|
+
if (args.length < 1) throw Error('Waterfall hooks must have at least one argument');
|
|
701
|
+
super(args, name);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
let defaultFactory = (key, hook)=>hook;
|
|
705
|
+
class HookMap {
|
|
706
|
+
get(key) {
|
|
707
|
+
return this._map.get(key);
|
|
708
|
+
}
|
|
709
|
+
for(key) {
|
|
710
|
+
let hook = this.get(key);
|
|
711
|
+
if (void 0 !== hook) return hook;
|
|
712
|
+
let newHook = this._factory(key), interceptors = this._interceptors;
|
|
713
|
+
for(let i = 0; i < interceptors.length; i++){
|
|
714
|
+
let factory = interceptors[i].factory;
|
|
715
|
+
factory && (newHook = factory(key, newHook));
|
|
716
|
+
}
|
|
717
|
+
return this._map.set(key, newHook), newHook;
|
|
718
|
+
}
|
|
719
|
+
intercept(interceptor) {
|
|
720
|
+
this._interceptors.push(Object.assign({
|
|
721
|
+
factory: defaultFactory
|
|
722
|
+
}, interceptor));
|
|
723
|
+
}
|
|
724
|
+
isUsed() {
|
|
725
|
+
for (let key of this._map.keys()){
|
|
726
|
+
let hook = this.get(key);
|
|
727
|
+
if (hook?.isUsed()) return !0;
|
|
728
|
+
}
|
|
729
|
+
return !1;
|
|
730
|
+
}
|
|
731
|
+
queryStageRange(stageRange) {
|
|
732
|
+
return new QueriedHookMap(stageRange, this);
|
|
733
|
+
}
|
|
734
|
+
constructor(factory, name){
|
|
735
|
+
_define_property(this, "_map", new Map()), _define_property(this, "_factory", void 0), _define_property(this, "name", void 0), _define_property(this, "_interceptors", void 0), this.name = name, this._factory = factory, this._interceptors = [];
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
class QueriedHookMap {
|
|
739
|
+
get(key) {
|
|
740
|
+
return this.hookMap.get(key)?.queryStageRange(this.stageRange);
|
|
741
|
+
}
|
|
742
|
+
for(key) {
|
|
743
|
+
return this.hookMap.for(key).queryStageRange(this.stageRange);
|
|
744
|
+
}
|
|
745
|
+
isUsed() {
|
|
746
|
+
for (let key of this.hookMap._map.keys())if (this.get(key)?.isUsed()) return !0;
|
|
747
|
+
return !1;
|
|
748
|
+
}
|
|
749
|
+
constructor(stageRange, hookMap){
|
|
750
|
+
_define_property(this, "stageRange", void 0), _define_property(this, "hookMap", void 0), this.stageRange = stageRange, this.hookMap = hookMap;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
class MultiHook {
|
|
754
|
+
tap(options, fn) {
|
|
755
|
+
for (let hook of this.hooks)hook.tap(options, fn);
|
|
756
|
+
}
|
|
757
|
+
tapAsync(options, fn) {
|
|
758
|
+
for (let hook of this.hooks)hook.tapAsync(options, fn);
|
|
759
|
+
}
|
|
760
|
+
tapPromise(options, fn) {
|
|
761
|
+
for (let hook of this.hooks)hook.tapPromise(options, fn);
|
|
762
|
+
}
|
|
763
|
+
isUsed() {
|
|
764
|
+
for (let hook of this.hooks)if (hook.isUsed()) return !0;
|
|
765
|
+
return !1;
|
|
766
|
+
}
|
|
767
|
+
intercept(interceptor) {
|
|
768
|
+
for (let hook of this.hooks)hook.intercept(interceptor);
|
|
769
|
+
}
|
|
770
|
+
withOptions(options) {
|
|
771
|
+
return new MultiHook(this.hooks.map((h)=>h.withOptions(options)), this.name);
|
|
772
|
+
}
|
|
773
|
+
constructor(hooks, name){
|
|
774
|
+
_define_property(this, "hooks", void 0), _define_property(this, "name", void 0), this.hooks = hooks, this.name = name;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
305
777
|
let cutOffLoaderExecution = (stack)=>((stack, flag)=>{
|
|
306
778
|
let stacks = stack.split('\n');
|
|
307
779
|
for(let i = 0; i < stacks.length; i++)stacks[i].includes(flag) && (stacks.length = i);
|
|
@@ -1417,6 +1889,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1417
1889
|
'chunks',
|
|
1418
1890
|
'modules'
|
|
1419
1891
|
]),
|
|
1892
|
+
beforeModuleIds: new SyncHook([
|
|
1893
|
+
'modules'
|
|
1894
|
+
]),
|
|
1420
1895
|
finishModules: new AsyncSeriesHook([
|
|
1421
1896
|
'modules'
|
|
1422
1897
|
]),
|
|
@@ -2238,11 +2713,7 @@ function stringifyLoaderObject(o) {
|
|
|
2238
2713
|
let unsupported = (name, issue)=>{
|
|
2239
2714
|
let s = `${name} is not supported by Rspack.`;
|
|
2240
2715
|
throw issue && (s += ` Refer to issue ${issue} for more information.`), Error(s);
|
|
2241
|
-
}, warnedMessages = new Set()
|
|
2242
|
-
function deprecate(message) {
|
|
2243
|
-
warnedMessages.has(message) || (warnedMessages.add(message), console.warn(`[Rspack Deprecation] ${message}`));
|
|
2244
|
-
}
|
|
2245
|
-
let WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, relativePathToRequest = (relativePath)=>'' === relativePath ? './.' : '..' === relativePath ? '../.' : relativePath.startsWith('../') ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
|
|
2716
|
+
}, warnedMessages = new Set(), WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, relativePathToRequest = (relativePath)=>'' === relativePath ? './.' : '..' === relativePath ? '../.' : relativePath.startsWith('../') ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
|
|
2246
2717
|
if ('/' === maybeAbsolutePath[0]) {
|
|
2247
2718
|
if (maybeAbsolutePath.length > 1 && '/' === maybeAbsolutePath[maybeAbsolutePath.length - 1]) return maybeAbsolutePath;
|
|
2248
2719
|
let querySplitPos = maybeAbsolutePath.indexOf('?'), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
|
|
@@ -2431,12 +2902,6 @@ function toFeatures(featureOptions) {
|
|
|
2431
2902
|
}
|
|
2432
2903
|
return feature;
|
|
2433
2904
|
}
|
|
2434
|
-
function resolveCollectTypeScriptInfo(options) {
|
|
2435
|
-
return {
|
|
2436
|
-
typeExports: options.typeExports,
|
|
2437
|
-
exportedEnum: !0 === options.exportedEnum ? 'all' : !1 === options.exportedEnum || void 0 === options.exportedEnum ? 'none' : 'const-only'
|
|
2438
|
-
};
|
|
2439
|
-
}
|
|
2440
2905
|
let $assets = Symbol('assets');
|
|
2441
2906
|
Object.defineProperty(binding_default().KnownBuildInfo.prototype, node_util.inspect.custom, {
|
|
2442
2907
|
enumerable: !0,
|
|
@@ -2520,8 +2985,7 @@ Object.defineProperty(binding_default().NormalModule.prototype, 'identifier', {
|
|
|
2520
2985
|
value (filename, source, assetInfo) {
|
|
2521
2986
|
return this._emitFile(filename, SourceAdapter.toBinding(source), assetInfo);
|
|
2522
2987
|
}
|
|
2523
|
-
})
|
|
2524
|
-
Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
2988
|
+
}), Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
2525
2989
|
enumerable: !0,
|
|
2526
2990
|
configurable: !0,
|
|
2527
2991
|
value (compilation) {
|
|
@@ -2532,40 +2996,6 @@ Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
|
2532
2996
|
'loaderContext',
|
|
2533
2997
|
'module'
|
|
2534
2998
|
]),
|
|
2535
|
-
readResourceForScheme: new HookMap((scheme)=>{
|
|
2536
|
-
let fakeHook, message, code, hook = hooks.readResource.for(scheme);
|
|
2537
|
-
return fakeHook = {
|
|
2538
|
-
tap: (options, fn)=>hook.tap(options, (loaderContext)=>fn(loaderContext.resource)),
|
|
2539
|
-
tapAsync: (options, fn)=>hook.tapAsync(options, (loaderContext, callback)=>fn(loaderContext.resource, callback)),
|
|
2540
|
-
tapPromise: (options, fn)=>hook.tapPromise(options, (loaderContext)=>fn(loaderContext.resource))
|
|
2541
|
-
}, Object.freeze(Object.assign(message && code ? ((obj, message, code)=>{
|
|
2542
|
-
let newObj = {}, descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
2543
|
-
for (let name of Object.keys(descriptors)){
|
|
2544
|
-
let descriptor = descriptors[name];
|
|
2545
|
-
if ('function' == typeof descriptor.value) Object.defineProperty(newObj, name, {
|
|
2546
|
-
...descriptor,
|
|
2547
|
-
value: node_util.deprecate(descriptor.value, message, code)
|
|
2548
|
-
});
|
|
2549
|
-
else if (descriptor.get || descriptor.set) Object.defineProperty(newObj, name, {
|
|
2550
|
-
...descriptor,
|
|
2551
|
-
get: descriptor.get && node_util.deprecate(descriptor.get, message, code),
|
|
2552
|
-
set: descriptor.set && node_util.deprecate(descriptor.set, message, code)
|
|
2553
|
-
});
|
|
2554
|
-
else {
|
|
2555
|
-
let value = descriptor.value;
|
|
2556
|
-
Object.defineProperty(newObj, name, {
|
|
2557
|
-
configurable: descriptor.configurable,
|
|
2558
|
-
enumerable: descriptor.enumerable,
|
|
2559
|
-
get: node_util.deprecate(()=>value, message, code),
|
|
2560
|
-
set: descriptor.writable ? node_util.deprecate((v)=>value = v, message, code) : void 0
|
|
2561
|
-
});
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
return newObj;
|
|
2565
|
-
})(fakeHook, message, code) : fakeHook, {
|
|
2566
|
-
_fakeHook: !0
|
|
2567
|
-
}));
|
|
2568
|
-
}),
|
|
2569
2999
|
readResource: new HookMap(()=>new AsyncSeriesBailHook([
|
|
2570
3000
|
'loaderContext'
|
|
2571
3001
|
]))
|
|
@@ -2820,20 +3250,6 @@ class BulkUpdateDecorator extends Hash {
|
|
|
2820
3250
|
return void 0 !== digestCache && 'string' == typeof result && digestCache.set(buffer, result), result;
|
|
2821
3251
|
}
|
|
2822
3252
|
}
|
|
2823
|
-
class DebugHash extends Hash {
|
|
2824
|
-
string;
|
|
2825
|
-
constructor(){
|
|
2826
|
-
super(), this.string = '';
|
|
2827
|
-
}
|
|
2828
|
-
update(data) {
|
|
2829
|
-
let normalizedData;
|
|
2830
|
-
return (normalizedData = Buffer.isBuffer(data) ? data.toString('utf-8') : data).startsWith('debug-digest-') && (normalizedData = Buffer.from(normalizedData.slice(13), 'hex').toString()), this.string += `[${normalizedData}](${Error().stack?.split('\n', 3)[2]})\n`, this;
|
|
2831
|
-
}
|
|
2832
|
-
digest(encoding) {
|
|
2833
|
-
let result = `debug-digest-${Buffer.from(this.string).toString('hex')}`;
|
|
2834
|
-
return encoding ? result : Buffer.from(result);
|
|
2835
|
-
}
|
|
2836
|
-
}
|
|
2837
3253
|
class WasmHashAdapter extends Hash {
|
|
2838
3254
|
wasmHash;
|
|
2839
3255
|
constructor(wasmHash){
|
|
@@ -2849,8 +3265,6 @@ class WasmHashAdapter extends Hash {
|
|
|
2849
3265
|
let createHash_createHash = (algorithm)=>{
|
|
2850
3266
|
if ('function' == typeof algorithm) return new BulkUpdateDecorator(()=>new algorithm());
|
|
2851
3267
|
switch(algorithm){
|
|
2852
|
-
case 'debug':
|
|
2853
|
-
return new DebugHash();
|
|
2854
3268
|
case 'xxhash64':
|
|
2855
3269
|
return new WasmHashAdapter((()=>{
|
|
2856
3270
|
if (!createXxhash64) {
|
|
@@ -3656,6 +4070,7 @@ function createRawModuleRuleUses(uses, path, options) {
|
|
|
3656
4070
|
if (identifier.startsWith(`${BUILTIN_LOADER_PREFIX}swc-loader`)) return ((o, composeOptions)=>{
|
|
3657
4071
|
let options = o ?? {};
|
|
3658
4072
|
if ('object' == typeof options) {
|
|
4073
|
+
var options1;
|
|
3659
4074
|
if (options.jsc ??= {}, options.jsc.experimental ??= {}, options.jsc.experimental.disableAllLints ??= !0, options.env?.targets === void 0 && options.jsc?.target === void 0) {
|
|
3660
4075
|
if (composeOptions.compiler.target?.targets) options.env ??= {}, options.env.targets ??= function(targets) {
|
|
3661
4076
|
let REMAP = {
|
|
@@ -3682,9 +4097,12 @@ function createRawModuleRuleUses(uses, path, options) {
|
|
|
3682
4097
|
options.jsc.target ??= esVersion >= 2015 ? `es${esVersion}` : 'es5';
|
|
3683
4098
|
}
|
|
3684
4099
|
}
|
|
3685
|
-
options.collectTypeScriptInfo && (options.collectTypeScriptInfo =
|
|
4100
|
+
options.collectTypeScriptInfo && (options.collectTypeScriptInfo = {
|
|
4101
|
+
typeExports: (options1 = options.collectTypeScriptInfo).typeExports,
|
|
4102
|
+
exportedEnum: !0 === options1.exportedEnum ? 'all' : !1 === options1.exportedEnum || void 0 === options1.exportedEnum ? 'none' : 'const-only'
|
|
4103
|
+
});
|
|
3686
4104
|
let { rspackExperiments } = options;
|
|
3687
|
-
rspackExperiments && (
|
|
4105
|
+
rspackExperiments && (rspackExperiments.import || rspackExperiments.pluginImport) && (rspackExperiments.import = function(pluginImport) {
|
|
3688
4106
|
if (pluginImport) return pluginImport.map((config)=>{
|
|
3689
4107
|
let rawConfig = {
|
|
3690
4108
|
...config,
|
|
@@ -3702,7 +4120,7 @@ function createRawModuleRuleUses(uses, path, options) {
|
|
|
3702
4120
|
styleLibraryDirectory: config.styleLibraryDirectory
|
|
3703
4121
|
}), rawConfig;
|
|
3704
4122
|
});
|
|
3705
|
-
}(rspackExperiments.import || rspackExperiments.pluginImport))
|
|
4123
|
+
}(rspackExperiments.import || rspackExperiments.pluginImport));
|
|
3706
4124
|
}
|
|
3707
4125
|
return options;
|
|
3708
4126
|
})(o, options);
|
|
@@ -3939,7 +4357,6 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3939
4357
|
exportsPresence: !1 === parser.exportsPresence ? 'false' : parser.exportsPresence,
|
|
3940
4358
|
importExportsPresence: !1 === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
|
|
3941
4359
|
reexportExportsPresence: !1 === parser.reexportExportsPresence ? 'false' : parser.reexportExportsPresence,
|
|
3942
|
-
strictExportPresence: parser.strictExportPresence,
|
|
3943
4360
|
worker: 'boolean' == typeof parser.worker ? parser.worker ? [
|
|
3944
4361
|
'...'
|
|
3945
4362
|
] : [] : parser.worker,
|
|
@@ -3959,7 +4376,8 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3959
4376
|
function getRawCssParserOptions(parser) {
|
|
3960
4377
|
return {
|
|
3961
4378
|
namedExports: parser.namedExports,
|
|
3962
|
-
url: parser.url
|
|
4379
|
+
url: parser.url,
|
|
4380
|
+
resolveImport: parser.resolveImport
|
|
3963
4381
|
};
|
|
3964
4382
|
}
|
|
3965
4383
|
function getRawGeneratorOptions(generator, type) {
|
|
@@ -4413,7 +4831,7 @@ let JsLoaderRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName
|
|
|
4413
4831
|
test,
|
|
4414
4832
|
client,
|
|
4415
4833
|
currentActiveModules
|
|
4416
|
-
}), 'thisCompilation'), middleware_require = createRequire(import.meta.url), LAZY_COMPILATION_PREFIX = '/lazy
|
|
4834
|
+
}), 'thisCompilation'), middleware_require = createRequire(import.meta.url), LAZY_COMPILATION_PREFIX = '/_rspack/lazy/trigger', noop = (_req, _res, next)=>{
|
|
4417
4835
|
'function' == typeof next && next();
|
|
4418
4836
|
}, lazyCompilationMiddleware = (compiler)=>{
|
|
4419
4837
|
if (compiler instanceof MultiCompiler) {
|
|
@@ -6042,7 +6460,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6042
6460
|
if ('function' != typeof options.entry) for (let key of Object.keys(options.entry))F(options.entry[key], 'import', ()=>[
|
|
6043
6461
|
'./src'
|
|
6044
6462
|
]);
|
|
6045
|
-
return F(options, 'devtool', ()=>!!development && '
|
|
6463
|
+
return F(options, 'devtool', ()=>!!development && 'cheap-module-source-map'), D(options, 'watch', !1), D(options, 'lazyCompilation', !1), D(options, 'bail', !1), F(options, 'cache', ()=>development), applyIncrementalDefaults(options), applyExperimentsDefaults(options.experiments), applyOptimizationDefaults(options.optimization, {
|
|
6046
6464
|
production,
|
|
6047
6465
|
development
|
|
6048
6466
|
}), applySnapshotDefaults(options.snapshot, {
|
|
@@ -6094,7 +6512,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6094
6512
|
D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
|
|
6095
6513
|
}, applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport })=>{
|
|
6096
6514
|
assertNotNill(module.parser), assertNotNill(module.generator), F(module.parser, "asset", ()=>({})), assertNotNill(module.parser.asset), F(module.parser.asset, 'dataUrlCondition', ()=>({})), 'object' == typeof module.parser.asset.dataUrlCondition && D(module.parser.asset.dataUrlCondition, 'maxSize', 8096), F(module.parser, "javascript", ()=>({})), assertNotNill(module.parser.javascript), ((parserOptions, { deferImport })=>{
|
|
6097
|
-
D(parserOptions, 'dynamicImportMode', 'lazy'), D(parserOptions, 'dynamicImportPrefetch', !1), D(parserOptions, 'dynamicImportPreload', !1), D(parserOptions, 'url', !0), D(parserOptions, 'exprContextCritical', !0), D(parserOptions, 'unknownContextCritical', !0), D(parserOptions, 'wrappedContextCritical', !1), D(parserOptions, 'wrappedContextRegExp', /.*/), D(parserOptions, '
|
|
6515
|
+
D(parserOptions, 'dynamicImportMode', 'lazy'), D(parserOptions, 'dynamicImportPrefetch', !1), D(parserOptions, 'dynamicImportPreload', !1), D(parserOptions, 'url', !0), D(parserOptions, 'exprContextCritical', !0), D(parserOptions, 'unknownContextCritical', !0), D(parserOptions, 'wrappedContextCritical', !1), D(parserOptions, 'wrappedContextRegExp', /.*/), D(parserOptions, 'exportsPresence', 'error'), D(parserOptions, 'requireAsExpression', !0), D(parserOptions, 'requireAlias', !1), D(parserOptions, 'requireDynamic', !0), D(parserOptions, 'requireResolve', !0), D(parserOptions, 'commonjs', !0), D(parserOptions, 'importDynamic', !0), D(parserOptions, 'worker', [
|
|
6098
6516
|
'...'
|
|
6099
6517
|
]), D(parserOptions, 'importMeta', !0), D(parserOptions, 'typeReexportsPresence', 'no-tolerant'), D(parserOptions, 'jsx', !1), D(parserOptions, 'deferImport', deferImport);
|
|
6100
6518
|
})(module.parser.javascript, {
|
|
@@ -6366,7 +6784,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6366
6784
|
return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
|
|
6367
6785
|
desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
|
|
6368
6786
|
}), Array.from(enabledWasmLoadingTypes);
|
|
6369
|
-
}), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.
|
|
6787
|
+
}), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.2"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
|
|
6370
6788
|
}, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
|
|
6371
6789
|
let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
|
|
6372
6790
|
D(externalsPresets, 'web', !buildHttp && targetProperties && (targetProperties.web || isUniversal('node'))), D(externalsPresets, 'node', targetProperties && (targetProperties.node || isUniversal('node'))), D(externalsPresets, 'electron', targetProperties && targetProperties.electron || isUniversal('electron')), D(externalsPresets, 'electronMain', targetProperties && !!targetProperties.electron && (targetProperties.electronMain || isUniversal('electronMain'))), D(externalsPresets, 'electronPreload', targetProperties && !!targetProperties.electron && (targetProperties.electronPreload || isUniversal('electronPreload'))), D(externalsPresets, 'electronRenderer', targetProperties && !!targetProperties.electron && (targetProperties.electronRenderer || isUniversal('electronRenderer'))), D(externalsPresets, 'nwjs', targetProperties && (targetProperties.nwjs || isUniversal('nwjs')));
|
|
@@ -6684,7 +7102,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6684
7102
|
type: 'filesystem',
|
|
6685
7103
|
directory: node_path.resolve(config.context || process.cwd(), cache.storage?.directory || 'node_modules/.cache/rspack')
|
|
6686
7104
|
},
|
|
6687
|
-
portable: cache.portable
|
|
7105
|
+
portable: cache.portable,
|
|
7106
|
+
readonly: cache.readonly
|
|
6688
7107
|
};
|
|
6689
7108
|
}),
|
|
6690
7109
|
stats: nestedConfig(config.stats, (stats)=>!1 === stats ? {
|
|
@@ -7618,7 +8037,7 @@ class MultiStats {
|
|
|
7618
8037
|
obj.children = this.stats.map((stat, idx)=>{
|
|
7619
8038
|
let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
|
|
7620
8039
|
return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
|
|
7621
|
-
}), childOptions.version && (obj.rspackVersion = "2.0.0-beta.
|
|
8040
|
+
}), childOptions.version && (obj.rspackVersion = "2.0.0-beta.2", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
|
|
7622
8041
|
let mapError = (j, obj)=>({
|
|
7623
8042
|
...obj,
|
|
7624
8043
|
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
|
@@ -8877,7 +9296,7 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8877
9296
|
object.hash = context.getStatsCompilation(compilation).hash;
|
|
8878
9297
|
},
|
|
8879
9298
|
version: (object)=>{
|
|
8880
|
-
object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.
|
|
9299
|
+
object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.2";
|
|
8881
9300
|
},
|
|
8882
9301
|
env: (object, _compilation, _context, { _env })=>{
|
|
8883
9302
|
object.env = _env;
|
|
@@ -10242,7 +10661,7 @@ function createCompiler(userOptions) {
|
|
|
10242
10661
|
function isMultiRspackOptions(o) {
|
|
10243
10662
|
return Array.isArray(o);
|
|
10244
10663
|
}
|
|
10245
|
-
function
|
|
10664
|
+
function rspack_rspack(options, callback) {
|
|
10246
10665
|
try {
|
|
10247
10666
|
if (isMultiRspackOptions(options)) for (let option of options)validateRspackConfig(option);
|
|
10248
10667
|
else validateRspackConfig(options);
|
|
@@ -10281,8 +10700,9 @@ function rspack(options, callback) {
|
|
|
10281
10700
|
return process.nextTick(()=>callback(err)), null;
|
|
10282
10701
|
}
|
|
10283
10702
|
{
|
|
10703
|
+
var message;
|
|
10284
10704
|
let { compiler, watch } = create();
|
|
10285
|
-
return watch &&
|
|
10705
|
+
return watch && (message = "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.", warnedMessages.has(message) || (warnedMessages.add(message), console.warn(`[Rspack Deprecation] ${message}`))), compiler;
|
|
10286
10706
|
}
|
|
10287
10707
|
}
|
|
10288
10708
|
class CodeGenerationResult {
|
|
@@ -10538,7 +10958,7 @@ class TraceHookPlugin {
|
|
|
10538
10958
|
});
|
|
10539
10959
|
}
|
|
10540
10960
|
}
|
|
10541
|
-
let CORE_VERSION = "2.0.0-beta.
|
|
10961
|
+
let CORE_VERSION = "2.0.0-beta.2", VFILES_BY_COMPILER = new WeakMap();
|
|
10542
10962
|
class VirtualModulesPlugin {
|
|
10543
10963
|
#staticModules;
|
|
10544
10964
|
#compiler;
|
|
@@ -10862,7 +11282,7 @@ class Compiler {
|
|
|
10862
11282
|
}
|
|
10863
11283
|
});
|
|
10864
11284
|
let compilerRspack = Object.assign(function(...params) {
|
|
10865
|
-
return
|
|
11285
|
+
return rspack_rspack(...params);
|
|
10866
11286
|
}, exports_namespaceObject, {
|
|
10867
11287
|
RuntimeGlobals: createCompilerRuntimeGlobals(options)
|
|
10868
11288
|
});
|
|
@@ -11423,6 +11843,29 @@ Help:
|
|
|
11423
11843
|
return queried.promise(getCompiler().__internal__get_compilation().chunks, getCompiler().__internal__get_compilation().modules);
|
|
11424
11844
|
};
|
|
11425
11845
|
}),
|
|
11846
|
+
registerCompilationBeforeModuleIdsTaps: createTap(binding_default().RegisterJsTapKind.CompilationBeforeModuleIds, function() {
|
|
11847
|
+
return getCompiler().__internal__get_compilation().hooks.beforeModuleIds;
|
|
11848
|
+
}, function(queried) {
|
|
11849
|
+
return function(arg) {
|
|
11850
|
+
let compilation = getCompiler().__internal__get_compilation(), assignments = new Map(), modulesByIdentifier = new Map();
|
|
11851
|
+
for (let module of compilation.modules)modulesByIdentifier.set(module.identifier(), module);
|
|
11852
|
+
let proxiedModules = arg.modules.map((m)=>new Proxy(modulesByIdentifier.get(m.identifier), {
|
|
11853
|
+
get (target, prop) {
|
|
11854
|
+
if ('id' === prop) return assignments.get(m.identifier) ?? null;
|
|
11855
|
+
if ('identifier' === prop) return m.identifier;
|
|
11856
|
+
let value = Reflect.get(target, prop);
|
|
11857
|
+
return 'function' == typeof value ? value.bind(target) : value;
|
|
11858
|
+
},
|
|
11859
|
+
set: (_target, prop, value)=>'id' === prop && null !== value && (assignments.set(m.identifier, value), !0)
|
|
11860
|
+
}));
|
|
11861
|
+
return queried.call(proxiedModules), {
|
|
11862
|
+
assignments: Object.fromEntries(Array.from(assignments.entries()).map(([k, v])=>[
|
|
11863
|
+
k,
|
|
11864
|
+
String(v)
|
|
11865
|
+
]))
|
|
11866
|
+
};
|
|
11867
|
+
};
|
|
11868
|
+
}),
|
|
11426
11869
|
registerCompilationChunkHashTaps: createTap(binding_default().RegisterJsTapKind.CompilationChunkHash, function() {
|
|
11427
11870
|
return getCompiler().__internal__get_compilation().hooks.chunkHash;
|
|
11428
11871
|
}, function(queried) {
|
|
@@ -11965,68 +12408,7 @@ class LoaderTargetPlugin {
|
|
|
11965
12408
|
});
|
|
11966
12409
|
}
|
|
11967
12410
|
}
|
|
11968
|
-
let
|
|
11969
|
-
function isRequiredVersion(str) {
|
|
11970
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
11971
|
-
}
|
|
11972
|
-
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
11973
|
-
function isPlainObject(value) {
|
|
11974
|
-
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
11975
|
-
}
|
|
11976
|
-
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
11977
|
-
name = binding_namespaceObject.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
11978
|
-
opts;
|
|
11979
|
-
constructor(opts){
|
|
11980
|
-
super(), this.opts = opts;
|
|
11981
|
-
}
|
|
11982
|
-
raw(compiler) {
|
|
11983
|
-
var isDev;
|
|
11984
|
-
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
|
|
11985
|
-
if (!manifestOptions) return {
|
|
11986
|
-
statsFileName: STATS_FILE_NAME,
|
|
11987
|
-
manifestFileName: MANIFEST_FILE_NAME
|
|
11988
|
-
};
|
|
11989
|
-
let filePath = 'boolean' == typeof manifestOptions ? '' : manifestOptions.filePath || '', fileName = 'boolean' == typeof manifestOptions ? '' : manifestOptions.fileName || '', manifestFileName = fileName ? fileName.endsWith(JSON_EXT) ? fileName : `${fileName}${JSON_EXT}` : MANIFEST_FILE_NAME;
|
|
11990
|
-
return {
|
|
11991
|
-
statsFileName: join(filePath, fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME),
|
|
11992
|
-
manifestFileName: join(filePath, manifestFileName)
|
|
11993
|
-
};
|
|
11994
|
-
}(this.opts), rawOptions = {
|
|
11995
|
-
name: this.opts.name,
|
|
11996
|
-
globalName: this.opts.globalName,
|
|
11997
|
-
fileName,
|
|
11998
|
-
filePath,
|
|
11999
|
-
manifestFileName,
|
|
12000
|
-
statsFileName,
|
|
12001
|
-
disableAssetsAnalyze,
|
|
12002
|
-
remoteAliasMap,
|
|
12003
|
-
exposes,
|
|
12004
|
-
shared,
|
|
12005
|
-
buildInfo: (isDev = 'development' === compiler.options.mode, pkg = function(root) {
|
|
12006
|
-
let pkgPath = join(root ? external_node_path_resolve(root) : process.cwd(), 'package.json');
|
|
12007
|
-
try {
|
|
12008
|
-
let content = readFileSync(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
12009
|
-
try {
|
|
12010
|
-
let parsed = JSON.parse(input);
|
|
12011
|
-
if (guard(parsed)) return parsed;
|
|
12012
|
-
} catch {}
|
|
12013
|
-
}(content, isPlainObject);
|
|
12014
|
-
if (parsed) {
|
|
12015
|
-
let filtered = {};
|
|
12016
|
-
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
12017
|
-
if (Object.keys(filtered).length > 0) return filtered;
|
|
12018
|
-
}
|
|
12019
|
-
} catch {}
|
|
12020
|
-
return {};
|
|
12021
|
-
}(compiler.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, {
|
|
12022
|
-
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
12023
|
-
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
12024
|
-
})
|
|
12025
|
-
};
|
|
12026
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
12027
|
-
}
|
|
12028
|
-
}
|
|
12029
|
-
let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
12411
|
+
let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
12030
12412
|
let items = [];
|
|
12031
12413
|
var fn = (key, value)=>{
|
|
12032
12414
|
items.push([
|
|
@@ -12043,63 +12425,7 @@ let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinP
|
|
|
12043
12425
|
else if ('object' == typeof options) object(options);
|
|
12044
12426
|
else throw Error('Unexpected options format');
|
|
12045
12427
|
return items;
|
|
12046
|
-
},
|
|
12047
|
-
function getRemoteInfos(options) {
|
|
12048
|
-
if (!options.remotes) return {};
|
|
12049
|
-
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
12050
|
-
external: Array.isArray(item) ? item : [
|
|
12051
|
-
item
|
|
12052
|
-
],
|
|
12053
|
-
shareScope: options.shareScope || 'default'
|
|
12054
|
-
}), (item)=>({
|
|
12055
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
12056
|
-
item.external
|
|
12057
|
-
],
|
|
12058
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
12059
|
-
})), remoteInfos = {};
|
|
12060
|
-
for (let [key, config] of remotes)for (let external of config.external){
|
|
12061
|
-
let [externalType, externalRequest] = function(external) {
|
|
12062
|
-
let result = function(external) {
|
|
12063
|
-
if (/^[a-z0-9-]+ /.test(external)) {
|
|
12064
|
-
let idx = external.indexOf(' ');
|
|
12065
|
-
return [
|
|
12066
|
-
external.slice(0, idx),
|
|
12067
|
-
external.slice(idx + 1)
|
|
12068
|
-
];
|
|
12069
|
-
}
|
|
12070
|
-
return null;
|
|
12071
|
-
}(external);
|
|
12072
|
-
return null === result ? [
|
|
12073
|
-
remoteType,
|
|
12074
|
-
external
|
|
12075
|
-
] : result;
|
|
12076
|
-
}(external);
|
|
12077
|
-
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
12078
|
-
let [url, global] = function(urlAndGlobal) {
|
|
12079
|
-
let index = urlAndGlobal.indexOf('@');
|
|
12080
|
-
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
12081
|
-
urlAndGlobal.substring(index + 1),
|
|
12082
|
-
urlAndGlobal.substring(0, index)
|
|
12083
|
-
];
|
|
12084
|
-
}(externalRequest);
|
|
12085
|
-
remoteInfos[key].push({
|
|
12086
|
-
alias: key,
|
|
12087
|
-
name: global,
|
|
12088
|
-
entry: url,
|
|
12089
|
-
externalType,
|
|
12090
|
-
shareScope: config.shareScope
|
|
12091
|
-
});
|
|
12092
|
-
} else remoteInfos[key].push({
|
|
12093
|
-
alias: key,
|
|
12094
|
-
name: void 0,
|
|
12095
|
-
entry: void 0,
|
|
12096
|
-
externalType,
|
|
12097
|
-
shareScope: config.shareScope
|
|
12098
|
-
});
|
|
12099
|
-
}
|
|
12100
|
-
return remoteInfos;
|
|
12101
|
-
}
|
|
12102
|
-
let compilerSet = new WeakSet();
|
|
12428
|
+
}, compilerSet = new WeakSet();
|
|
12103
12429
|
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
12104
12430
|
enhanced;
|
|
12105
12431
|
name = binding_namespaceObject.BuiltinPluginName.ShareRuntimePlugin;
|
|
@@ -12110,42 +12436,55 @@ class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
|
12110
12436
|
if (!compilerSet.has(compiler)) return compilerSet.add(compiler), createBuiltinPlugin(this.name, this.enhanced);
|
|
12111
12437
|
}
|
|
12112
12438
|
}
|
|
12439
|
+
let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
12440
|
+
function isRequiredVersion(str) {
|
|
12441
|
+
return VERSION_PATTERN_REGEXP.test(str);
|
|
12442
|
+
}
|
|
12443
|
+
let encodeName = function(name, prefix = '', withExt = !1) {
|
|
12444
|
+
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${withExt ? '.js' : ''}`;
|
|
12445
|
+
};
|
|
12446
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
12447
|
+
return parseOptions(consumes, (item, key)=>{
|
|
12448
|
+
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
12449
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12450
|
+
import: key,
|
|
12451
|
+
shareScope: shareScope || 'default',
|
|
12452
|
+
shareKey: key,
|
|
12453
|
+
requiredVersion: item,
|
|
12454
|
+
strictVersion: !0,
|
|
12455
|
+
packageName: void 0,
|
|
12456
|
+
singleton: !1,
|
|
12457
|
+
eager: !1,
|
|
12458
|
+
treeShakingMode: void 0
|
|
12459
|
+
} : {
|
|
12460
|
+
import: key,
|
|
12461
|
+
shareScope: shareScope || 'default',
|
|
12462
|
+
shareKey: key,
|
|
12463
|
+
requiredVersion: void 0,
|
|
12464
|
+
packageName: void 0,
|
|
12465
|
+
strictVersion: !1,
|
|
12466
|
+
singleton: !1,
|
|
12467
|
+
eager: !1,
|
|
12468
|
+
treeShakingMode: void 0
|
|
12469
|
+
};
|
|
12470
|
+
}, (item, key)=>({
|
|
12471
|
+
import: !1 === item.import ? void 0 : item.import || key,
|
|
12472
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
12473
|
+
shareKey: item.shareKey || key,
|
|
12474
|
+
requiredVersion: item.requiredVersion,
|
|
12475
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12476
|
+
packageName: item.packageName,
|
|
12477
|
+
singleton: !!item.singleton,
|
|
12478
|
+
eager: !!item.eager,
|
|
12479
|
+
treeShakingMode: item.treeShakingMode
|
|
12480
|
+
}));
|
|
12481
|
+
}
|
|
12113
12482
|
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
12114
12483
|
name = binding_namespaceObject.BuiltinPluginName.ConsumeSharedPlugin;
|
|
12115
12484
|
_options;
|
|
12116
12485
|
constructor(options){
|
|
12117
12486
|
super(), this._options = {
|
|
12118
|
-
consumes:
|
|
12119
|
-
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
12120
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12121
|
-
import: key,
|
|
12122
|
-
shareScope: options.shareScope || 'default',
|
|
12123
|
-
shareKey: key,
|
|
12124
|
-
requiredVersion: item,
|
|
12125
|
-
strictVersion: !0,
|
|
12126
|
-
packageName: void 0,
|
|
12127
|
-
singleton: !1,
|
|
12128
|
-
eager: !1
|
|
12129
|
-
} : {
|
|
12130
|
-
import: key,
|
|
12131
|
-
shareScope: options.shareScope || 'default',
|
|
12132
|
-
shareKey: key,
|
|
12133
|
-
requiredVersion: void 0,
|
|
12134
|
-
packageName: void 0,
|
|
12135
|
-
strictVersion: !1,
|
|
12136
|
-
singleton: !1,
|
|
12137
|
-
eager: !1
|
|
12138
|
-
};
|
|
12139
|
-
}, (item, key)=>({
|
|
12140
|
-
import: !1 === item.import ? void 0 : item.import || key,
|
|
12141
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
12142
|
-
shareKey: item.shareKey || key,
|
|
12143
|
-
requiredVersion: item.requiredVersion,
|
|
12144
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12145
|
-
packageName: item.packageName,
|
|
12146
|
-
singleton: !!item.singleton,
|
|
12147
|
-
eager: !!item.eager
|
|
12148
|
-
})),
|
|
12487
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
12149
12488
|
enhanced: options.enhanced ?? !1
|
|
12150
12489
|
};
|
|
12151
12490
|
}
|
|
@@ -12166,28 +12505,30 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
12166
12505
|
_provides;
|
|
12167
12506
|
_enhanced;
|
|
12168
12507
|
constructor(options){
|
|
12169
|
-
|
|
12508
|
+
var options1, shareScope, enhanced;
|
|
12509
|
+
super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
|
|
12170
12510
|
if (Array.isArray(item)) throw Error('Unexpected array of provides');
|
|
12171
12511
|
return {
|
|
12172
12512
|
shareKey: item,
|
|
12173
12513
|
version: void 0,
|
|
12174
|
-
shareScope:
|
|
12514
|
+
shareScope: shareScope || 'default',
|
|
12175
12515
|
eager: !1
|
|
12176
12516
|
};
|
|
12177
12517
|
}, (item)=>{
|
|
12178
12518
|
let raw = {
|
|
12179
12519
|
shareKey: item.shareKey,
|
|
12180
12520
|
version: item.version,
|
|
12181
|
-
shareScope: item.shareScope ||
|
|
12521
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
12182
12522
|
eager: !!item.eager
|
|
12183
12523
|
};
|
|
12184
|
-
return
|
|
12524
|
+
return enhanced ? {
|
|
12185
12525
|
...raw,
|
|
12186
12526
|
singleton: item.singleton,
|
|
12187
12527
|
requiredVersion: item.requiredVersion,
|
|
12188
|
-
strictVersion: item.strictVersion
|
|
12528
|
+
strictVersion: item.strictVersion,
|
|
12529
|
+
treeShakingMode: item.treeShakingMode
|
|
12189
12530
|
} : raw;
|
|
12190
|
-
}), this._enhanced = options.enhanced;
|
|
12531
|
+
})), this._enhanced = options.enhanced;
|
|
12191
12532
|
}
|
|
12192
12533
|
raw(compiler) {
|
|
12193
12534
|
new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
|
|
@@ -12198,32 +12539,40 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
12198
12539
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
12199
12540
|
}
|
|
12200
12541
|
}
|
|
12542
|
+
function normalizeSharedOptions(shared) {
|
|
12543
|
+
return parseOptions(shared, (item, key)=>{
|
|
12544
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12545
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12546
|
+
import: key,
|
|
12547
|
+
requiredVersion: item
|
|
12548
|
+
} : {
|
|
12549
|
+
import: item
|
|
12550
|
+
};
|
|
12551
|
+
}, (item)=>item);
|
|
12552
|
+
}
|
|
12553
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
12554
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
12555
|
+
[key]: {
|
|
12556
|
+
import: options.import,
|
|
12557
|
+
shareKey: options.shareKey || key,
|
|
12558
|
+
shareScope: options.shareScope,
|
|
12559
|
+
requiredVersion: options.requiredVersion,
|
|
12560
|
+
strictVersion: options.strictVersion,
|
|
12561
|
+
singleton: options.singleton,
|
|
12562
|
+
packageName: options.packageName,
|
|
12563
|
+
eager: options.eager,
|
|
12564
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12565
|
+
}
|
|
12566
|
+
}));
|
|
12567
|
+
}
|
|
12201
12568
|
class SharePlugin {
|
|
12202
12569
|
_shareScope;
|
|
12203
12570
|
_consumes;
|
|
12204
12571
|
_provides;
|
|
12205
12572
|
_enhanced;
|
|
12573
|
+
_sharedOptions;
|
|
12206
12574
|
constructor(options){
|
|
12207
|
-
let sharedOptions =
|
|
12208
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12209
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12210
|
-
import: key,
|
|
12211
|
-
requiredVersion: item
|
|
12212
|
-
} : {
|
|
12213
|
-
import: item
|
|
12214
|
-
};
|
|
12215
|
-
}, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
|
|
12216
|
-
[key]: {
|
|
12217
|
-
import: options.import,
|
|
12218
|
-
shareKey: options.shareKey || key,
|
|
12219
|
-
shareScope: options.shareScope,
|
|
12220
|
-
requiredVersion: options.requiredVersion,
|
|
12221
|
-
strictVersion: options.strictVersion,
|
|
12222
|
-
singleton: options.singleton,
|
|
12223
|
-
packageName: options.packageName,
|
|
12224
|
-
eager: options.eager
|
|
12225
|
-
}
|
|
12226
|
-
})), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12575
|
+
let sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12227
12576
|
[options.import || key]: {
|
|
12228
12577
|
shareKey: options.shareKey || key,
|
|
12229
12578
|
shareScope: options.shareScope,
|
|
@@ -12231,10 +12580,11 @@ class SharePlugin {
|
|
|
12231
12580
|
eager: options.eager,
|
|
12232
12581
|
singleton: options.singleton,
|
|
12233
12582
|
requiredVersion: options.requiredVersion,
|
|
12234
|
-
strictVersion: options.strictVersion
|
|
12583
|
+
strictVersion: options.strictVersion,
|
|
12584
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12235
12585
|
}
|
|
12236
12586
|
}));
|
|
12237
|
-
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
|
|
12587
|
+
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
|
|
12238
12588
|
}
|
|
12239
12589
|
apply(compiler) {
|
|
12240
12590
|
new ConsumeSharedPlugin({
|
|
@@ -12248,6 +12598,555 @@ class SharePlugin {
|
|
|
12248
12598
|
}).apply(compiler);
|
|
12249
12599
|
}
|
|
12250
12600
|
}
|
|
12601
|
+
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
12602
|
+
function isPlainObject(value) {
|
|
12603
|
+
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
12604
|
+
}
|
|
12605
|
+
function getFileName(manifestOptions) {
|
|
12606
|
+
if (!manifestOptions) return {
|
|
12607
|
+
statsFileName: '',
|
|
12608
|
+
manifestFileName: ''
|
|
12609
|
+
};
|
|
12610
|
+
if ('boolean' == typeof manifestOptions) return {
|
|
12611
|
+
statsFileName: STATS_FILE_NAME,
|
|
12612
|
+
manifestFileName: MANIFEST_FILE_NAME
|
|
12613
|
+
};
|
|
12614
|
+
let filePath = 'boolean' == typeof manifestOptions ? '' : manifestOptions.filePath || '', fileName = 'boolean' == typeof manifestOptions ? '' : manifestOptions.fileName || '', manifestFileName = fileName ? fileName.endsWith(JSON_EXT) ? fileName : `${fileName}${JSON_EXT}` : MANIFEST_FILE_NAME;
|
|
12615
|
+
return {
|
|
12616
|
+
statsFileName: join(filePath, fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME),
|
|
12617
|
+
manifestFileName: join(filePath, manifestFileName)
|
|
12618
|
+
};
|
|
12619
|
+
}
|
|
12620
|
+
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
12621
|
+
name = binding_namespaceObject.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
12622
|
+
rawOpts;
|
|
12623
|
+
constructor(opts){
|
|
12624
|
+
super(), this.rawOpts = opts;
|
|
12625
|
+
}
|
|
12626
|
+
raw(compiler) {
|
|
12627
|
+
var mfConfig, isDev, mfConfig1;
|
|
12628
|
+
let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared, pkg, buildVersion, statsBuildInfo, opts = (manifestOptions = !0 === (mfConfig = this.rawOpts).manifest ? {} : {
|
|
12629
|
+
...mfConfig.manifest
|
|
12630
|
+
}, containerName = mfConfig.name, globalName = function(library) {
|
|
12631
|
+
if (!library) return;
|
|
12632
|
+
let libName = library.name;
|
|
12633
|
+
if (libName) {
|
|
12634
|
+
if ('string' == typeof libName) return libName;
|
|
12635
|
+
if (Array.isArray(libName)) return libName[0];
|
|
12636
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12637
|
+
}
|
|
12638
|
+
}(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
12639
|
+
if (cur[1].length > 1) return sum;
|
|
12640
|
+
let { entry, alias, name } = cur[1][0];
|
|
12641
|
+
return entry && name && (sum[alias] = {
|
|
12642
|
+
name,
|
|
12643
|
+
entry
|
|
12644
|
+
}), sum;
|
|
12645
|
+
}, {}), manifestExposes = function(exposes) {
|
|
12646
|
+
if (!exposes) return;
|
|
12647
|
+
let result = parseOptions(exposes, (value)=>({
|
|
12648
|
+
import: Array.isArray(value) ? value : [
|
|
12649
|
+
value
|
|
12650
|
+
],
|
|
12651
|
+
name: void 0
|
|
12652
|
+
}), (value)=>({
|
|
12653
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
12654
|
+
value.import
|
|
12655
|
+
],
|
|
12656
|
+
name: value.name ?? void 0
|
|
12657
|
+
})).map(([exposeKey, info])=>{
|
|
12658
|
+
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12659
|
+
return {
|
|
12660
|
+
path: exposeKey,
|
|
12661
|
+
name: exposeName
|
|
12662
|
+
};
|
|
12663
|
+
});
|
|
12664
|
+
return result.length > 0 ? result : void 0;
|
|
12665
|
+
}(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
|
|
12666
|
+
if (!shared) return;
|
|
12667
|
+
let result = parseOptions(shared, (item, key)=>{
|
|
12668
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12669
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12670
|
+
import: key,
|
|
12671
|
+
requiredVersion: item
|
|
12672
|
+
} : {
|
|
12673
|
+
import: item
|
|
12674
|
+
};
|
|
12675
|
+
}, (item)=>item).map(([key, config])=>{
|
|
12676
|
+
let name = config.shareKey || key;
|
|
12677
|
+
return {
|
|
12678
|
+
name,
|
|
12679
|
+
version: 'string' == typeof config.version ? config.version : void 0,
|
|
12680
|
+
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12681
|
+
singleton: config.singleton
|
|
12682
|
+
};
|
|
12683
|
+
});
|
|
12684
|
+
return result.length > 0 ? result : void 0;
|
|
12685
|
+
}(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
|
|
12686
|
+
...manifestOptions,
|
|
12687
|
+
remoteAliasMap,
|
|
12688
|
+
globalName,
|
|
12689
|
+
name: containerName
|
|
12690
|
+
}), { fileName, filePath, disableAssetsAnalyze, remoteAliasMap: remoteAliasMap1, exposes, shared } = opts, { statsFileName, manifestFileName } = getFileName(opts), rawOptions = {
|
|
12691
|
+
name: opts.name,
|
|
12692
|
+
globalName: opts.globalName,
|
|
12693
|
+
fileName,
|
|
12694
|
+
filePath,
|
|
12695
|
+
manifestFileName,
|
|
12696
|
+
statsFileName,
|
|
12697
|
+
disableAssetsAnalyze,
|
|
12698
|
+
remoteAliasMap: remoteAliasMap1,
|
|
12699
|
+
exposes,
|
|
12700
|
+
shared,
|
|
12701
|
+
buildInfo: (isDev = 'development' === compiler.options.mode, mfConfig1 = this.rawOpts, pkg = function(root) {
|
|
12702
|
+
let pkgPath = join(root ? external_node_path_resolve(root) : process.cwd(), 'package.json');
|
|
12703
|
+
try {
|
|
12704
|
+
let content = readFileSync(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
12705
|
+
try {
|
|
12706
|
+
let parsed = JSON.parse(input);
|
|
12707
|
+
if (guard(parsed)) return parsed;
|
|
12708
|
+
} catch {}
|
|
12709
|
+
}(content, isPlainObject);
|
|
12710
|
+
if (parsed) {
|
|
12711
|
+
let filtered = {};
|
|
12712
|
+
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
12713
|
+
if (Object.keys(filtered).length > 0) return filtered;
|
|
12714
|
+
}
|
|
12715
|
+
} catch {}
|
|
12716
|
+
return {};
|
|
12717
|
+
}(compiler.options.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, statsBuildInfo = {
|
|
12718
|
+
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
12719
|
+
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
12720
|
+
}, Object.values(normalizeSharedOptions(mfConfig1.shared || {})).some((config)=>config[1].treeShaking) && (statsBuildInfo.target = Array.isArray(compiler.options.target) ? compiler.options.target : [], statsBuildInfo.plugins = mfConfig1.treeShakingSharedPlugins || [], statsBuildInfo.excludePlugins = mfConfig1.treeShakingSharedExcludePlugins || []), statsBuildInfo)
|
|
12721
|
+
};
|
|
12722
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12723
|
+
}
|
|
12724
|
+
}
|
|
12725
|
+
let SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
12726
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
12727
|
+
name = binding_namespaceObject.BuiltinPluginName.CollectSharedEntryPlugin;
|
|
12728
|
+
sharedOptions;
|
|
12729
|
+
_collectedEntries;
|
|
12730
|
+
constructor(options){
|
|
12731
|
+
super();
|
|
12732
|
+
let { sharedOptions } = options;
|
|
12733
|
+
this.sharedOptions = sharedOptions, this._collectedEntries = {};
|
|
12734
|
+
}
|
|
12735
|
+
getData() {
|
|
12736
|
+
return this._collectedEntries;
|
|
12737
|
+
}
|
|
12738
|
+
getFilename() {
|
|
12739
|
+
return SHARE_ENTRY_ASSET;
|
|
12740
|
+
}
|
|
12741
|
+
apply(compiler) {
|
|
12742
|
+
super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
12743
|
+
compilation.hooks.processAssets.tap({
|
|
12744
|
+
name: 'CollectSharedEntry',
|
|
12745
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
12746
|
+
}, ()=>{
|
|
12747
|
+
compilation.getAssets().forEach((asset)=>{
|
|
12748
|
+
asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
|
|
12749
|
+
});
|
|
12750
|
+
});
|
|
12751
|
+
});
|
|
12752
|
+
}
|
|
12753
|
+
raw() {
|
|
12754
|
+
let rawOptions = {
|
|
12755
|
+
consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
|
|
12756
|
+
key,
|
|
12757
|
+
...v
|
|
12758
|
+
})),
|
|
12759
|
+
filename: this.getFilename()
|
|
12760
|
+
};
|
|
12761
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12762
|
+
}
|
|
12763
|
+
}
|
|
12764
|
+
function assert(condition, msg) {
|
|
12765
|
+
if (!condition) throw Error(msg);
|
|
12766
|
+
}
|
|
12767
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
12768
|
+
name = binding_namespaceObject.BuiltinPluginName.SharedContainerPlugin;
|
|
12769
|
+
filename = '';
|
|
12770
|
+
_options;
|
|
12771
|
+
_shareName;
|
|
12772
|
+
_globalName;
|
|
12773
|
+
constructor(options){
|
|
12774
|
+
super();
|
|
12775
|
+
let { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || '0.0.0';
|
|
12776
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
12777
|
+
let fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
12778
|
+
this._shareName = shareName, this._options = {
|
|
12779
|
+
name: shareName,
|
|
12780
|
+
request: request,
|
|
12781
|
+
library: (library ? {
|
|
12782
|
+
...library,
|
|
12783
|
+
name: this._globalName
|
|
12784
|
+
} : void 0) || {
|
|
12785
|
+
type: 'global',
|
|
12786
|
+
name: this._globalName
|
|
12787
|
+
},
|
|
12788
|
+
version,
|
|
12789
|
+
fileName
|
|
12790
|
+
};
|
|
12791
|
+
}
|
|
12792
|
+
getData() {
|
|
12793
|
+
return [
|
|
12794
|
+
this._options.fileName,
|
|
12795
|
+
this._globalName,
|
|
12796
|
+
this._options.version
|
|
12797
|
+
];
|
|
12798
|
+
}
|
|
12799
|
+
raw(compiler) {
|
|
12800
|
+
let { library } = this._options;
|
|
12801
|
+
return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
|
|
12802
|
+
}
|
|
12803
|
+
apply(compiler) {
|
|
12804
|
+
super.apply(compiler);
|
|
12805
|
+
let shareName = this._shareName;
|
|
12806
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
12807
|
+
compilation.hooks.processAssets.tap({
|
|
12808
|
+
name: 'getShareContainerFile'
|
|
12809
|
+
}, ()=>{
|
|
12810
|
+
assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
|
|
12811
|
+
let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
12812
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
12813
|
+
let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes('.hot-update') && !f.endsWith('.css'));
|
|
12814
|
+
assert(files.length > 0, `no files found for shared ${shareName} chunk`), assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(',')}`), this.filename = files[0];
|
|
12815
|
+
});
|
|
12816
|
+
});
|
|
12817
|
+
}
|
|
12818
|
+
}
|
|
12819
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
12820
|
+
name = binding_namespaceObject.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
|
|
12821
|
+
sharedOptions;
|
|
12822
|
+
injectTreeShakingUsedExports;
|
|
12823
|
+
manifestOptions;
|
|
12824
|
+
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
12825
|
+
super(), this.sharedOptions = sharedOptions, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
|
|
12826
|
+
}
|
|
12827
|
+
buildOptions() {
|
|
12828
|
+
let shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
12829
|
+
shareKey,
|
|
12830
|
+
treeShaking: !!config.treeShaking,
|
|
12831
|
+
usedExports: config.treeShaking?.usedExports
|
|
12832
|
+
})), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
12833
|
+
return {
|
|
12834
|
+
shared,
|
|
12835
|
+
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
12836
|
+
manifestFileName,
|
|
12837
|
+
statsFileName
|
|
12838
|
+
};
|
|
12839
|
+
}
|
|
12840
|
+
raw() {
|
|
12841
|
+
if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
|
|
12842
|
+
}
|
|
12843
|
+
}
|
|
12844
|
+
let VIRTUAL_ENTRY = './virtual-entry.js', VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
12845
|
+
class VirtualEntryPlugin {
|
|
12846
|
+
sharedOptions;
|
|
12847
|
+
collectShared = !1;
|
|
12848
|
+
constructor(sharedOptions, collectShared){
|
|
12849
|
+
this.sharedOptions = sharedOptions, this.collectShared = collectShared;
|
|
12850
|
+
}
|
|
12851
|
+
createEntry() {
|
|
12852
|
+
let { sharedOptions, collectShared } = this;
|
|
12853
|
+
return sharedOptions.reduce((acc, cur, index)=>acc + `import shared_${index} from '${cur[0]}';\n` + (collectShared ? `console.log(shared_${index});\n` : ''), '');
|
|
12854
|
+
}
|
|
12855
|
+
static entry() {
|
|
12856
|
+
return {
|
|
12857
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
12858
|
+
};
|
|
12859
|
+
}
|
|
12860
|
+
apply(compiler) {
|
|
12861
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
12862
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
12863
|
+
}).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
12864
|
+
compilation.hooks.processAssets.tap({
|
|
12865
|
+
name: 'RemoveVirtualEntryAsset',
|
|
12866
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12867
|
+
}, ()=>{
|
|
12868
|
+
try {
|
|
12869
|
+
let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
12870
|
+
chunk?.files.forEach((f)=>{
|
|
12871
|
+
compilation.deleteAsset(f);
|
|
12872
|
+
});
|
|
12873
|
+
} catch (_e) {
|
|
12874
|
+
console.error('Failed to remove virtual entry file!');
|
|
12875
|
+
}
|
|
12876
|
+
});
|
|
12877
|
+
});
|
|
12878
|
+
}
|
|
12879
|
+
}
|
|
12880
|
+
let resolveOutputDir = (outputDir, shareName)=>shareName ? join(outputDir, encodeName(shareName)) : outputDir;
|
|
12881
|
+
class IndependentSharedPlugin {
|
|
12882
|
+
mfName;
|
|
12883
|
+
shared;
|
|
12884
|
+
library;
|
|
12885
|
+
sharedOptions;
|
|
12886
|
+
outputDir;
|
|
12887
|
+
plugins;
|
|
12888
|
+
treeShaking;
|
|
12889
|
+
manifest;
|
|
12890
|
+
buildAssets = {};
|
|
12891
|
+
injectTreeShakingUsedExports;
|
|
12892
|
+
treeShakingSharedExcludePlugins;
|
|
12893
|
+
name = 'IndependentSharedPlugin';
|
|
12894
|
+
constructor(options){
|
|
12895
|
+
let { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
12896
|
+
this.shared = shared, this.mfName = name, this.outputDir = outputDir || 'independent-packages', this.plugins = plugins || [], this.treeShaking = treeShaking, this.manifest = manifest, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.library = library, this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins || [], this.sharedOptions = parseOptions(shared, (item, key)=>{
|
|
12897
|
+
if ('string' != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
12898
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12899
|
+
import: key,
|
|
12900
|
+
requiredVersion: item
|
|
12901
|
+
} : {
|
|
12902
|
+
import: item
|
|
12903
|
+
};
|
|
12904
|
+
}, (item)=>item);
|
|
12905
|
+
}
|
|
12906
|
+
apply(compiler) {
|
|
12907
|
+
let { manifest } = this, runCount = 0;
|
|
12908
|
+
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12909
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12910
|
+
}), compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12911
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12912
|
+
}), manifest && compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
12913
|
+
compilation.hooks.processAssets.tap({
|
|
12914
|
+
name: 'injectBuildAssets',
|
|
12915
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
12916
|
+
}, ()=>{
|
|
12917
|
+
let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
12918
|
+
let stats = compilation.getAsset(filename);
|
|
12919
|
+
if (!stats) return;
|
|
12920
|
+
let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
|
|
12921
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
12922
|
+
let targetShared = shared.find((s)=>s.name === key);
|
|
12923
|
+
targetShared && item.forEach(([entry, version, globalName])=>{
|
|
12924
|
+
version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
|
|
12925
|
+
});
|
|
12926
|
+
}), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
12927
|
+
};
|
|
12928
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
12929
|
+
});
|
|
12930
|
+
});
|
|
12931
|
+
}
|
|
12932
|
+
async createIndependentCompilers(parentCompiler) {
|
|
12933
|
+
let { sharedOptions, buildAssets, outputDir } = this;
|
|
12934
|
+
console.log('Start building shared fallback resources ...');
|
|
12935
|
+
let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
12936
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
12937
|
+
if (!shareConfig.treeShaking || !1 === shareConfig.import) return;
|
|
12938
|
+
let shareRequests = shareRequestsMap[shareName].requests;
|
|
12939
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
12940
|
+
let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
12941
|
+
shareRequestsMap,
|
|
12942
|
+
currentShare: {
|
|
12943
|
+
shareName,
|
|
12944
|
+
version,
|
|
12945
|
+
request,
|
|
12946
|
+
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
12947
|
+
}
|
|
12948
|
+
});
|
|
12949
|
+
'string' == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
|
|
12950
|
+
join(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
12951
|
+
sharedVersion,
|
|
12952
|
+
globalName
|
|
12953
|
+
]));
|
|
12954
|
+
}));
|
|
12955
|
+
})), console.log('All shared fallback have been compiled successfully!');
|
|
12956
|
+
}
|
|
12957
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
12958
|
+
let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ''), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
|
|
12959
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
12960
|
+
mfName: `${mfName}_${treeShaking ? 't' : 'f'}`,
|
|
12961
|
+
library,
|
|
12962
|
+
...extraOptions.currentShare
|
|
12963
|
+
}) : new CollectSharedEntryPlugin({
|
|
12964
|
+
sharedOptions,
|
|
12965
|
+
shareScope: 'default'
|
|
12966
|
+
}), (parentConfig.plugins || []).forEach((plugin)=>{
|
|
12967
|
+
void 0 !== plugin && 'string' != typeof plugin && ((plugin, excludedPlugins = [])=>{
|
|
12968
|
+
if (!plugin) return !0;
|
|
12969
|
+
let pluginName = plugin.name || plugin.constructor?.name;
|
|
12970
|
+
return !pluginName || ![
|
|
12971
|
+
'TreeShakingSharedPlugin',
|
|
12972
|
+
'IndependentSharedPlugin',
|
|
12973
|
+
'ModuleFederationPlugin',
|
|
12974
|
+
'SharedUsedExportsOptimizerPlugin',
|
|
12975
|
+
'HtmlWebpackPlugin',
|
|
12976
|
+
'HtmlRspackPlugin',
|
|
12977
|
+
'RsbuildHtmlPlugin',
|
|
12978
|
+
...excludedPlugins
|
|
12979
|
+
].includes(pluginName);
|
|
12980
|
+
})(plugin, treeShakingSharedExcludePlugins) && finalPlugins.push(plugin);
|
|
12981
|
+
}), plugins.forEach((plugin)=>{
|
|
12982
|
+
finalPlugins.push(plugin);
|
|
12983
|
+
}), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
|
|
12984
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
12985
|
+
[key]: {
|
|
12986
|
+
import: !extraOptions && options.import,
|
|
12987
|
+
shareKey: options.shareKey || key,
|
|
12988
|
+
shareScope: options.shareScope,
|
|
12989
|
+
requiredVersion: options.requiredVersion,
|
|
12990
|
+
strictVersion: options.strictVersion,
|
|
12991
|
+
singleton: options.singleton,
|
|
12992
|
+
packageName: options.packageName,
|
|
12993
|
+
eager: options.eager
|
|
12994
|
+
}
|
|
12995
|
+
})),
|
|
12996
|
+
enhanced: !0
|
|
12997
|
+
})), treeShaking && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
12998
|
+
let fullOutputDir = external_node_path_resolve(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
|
|
12999
|
+
...parentConfig,
|
|
13000
|
+
module: {
|
|
13001
|
+
...parentConfig.module,
|
|
13002
|
+
rules: [
|
|
13003
|
+
{
|
|
13004
|
+
test: /virtual-entry\.js$/,
|
|
13005
|
+
type: "javascript/auto",
|
|
13006
|
+
resolve: {
|
|
13007
|
+
fullySpecified: !1
|
|
13008
|
+
},
|
|
13009
|
+
use: {
|
|
13010
|
+
loader: 'builtin:swc-loader'
|
|
13011
|
+
}
|
|
13012
|
+
},
|
|
13013
|
+
...parentConfig.module?.rules || []
|
|
13014
|
+
]
|
|
13015
|
+
},
|
|
13016
|
+
mode: parentConfig.mode || 'development',
|
|
13017
|
+
entry: VirtualEntryPlugin.entry,
|
|
13018
|
+
output: {
|
|
13019
|
+
path: fullOutputDir,
|
|
13020
|
+
clean: !0,
|
|
13021
|
+
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
13022
|
+
},
|
|
13023
|
+
plugins: finalPlugins,
|
|
13024
|
+
optimization: {
|
|
13025
|
+
...parentConfig.optimization,
|
|
13026
|
+
splitChunks: !1
|
|
13027
|
+
}
|
|
13028
|
+
}, compiler = rspack.rspack(compilerConfig);
|
|
13029
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
13030
|
+
let { currentShare } = extraOptions || {};
|
|
13031
|
+
return new Promise((resolve, reject)=>{
|
|
13032
|
+
compiler.run((err, stats)=>{
|
|
13033
|
+
if (err || stats?.hasErrors()) {
|
|
13034
|
+
let target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
13035
|
+
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n')), reject(err || Error(`${target} Compile failed`));
|
|
13036
|
+
return;
|
|
13037
|
+
}
|
|
13038
|
+
currentShare && console.log(`${currentShare.shareName} Compile success`), resolve(extraPlugin.getData());
|
|
13039
|
+
});
|
|
13040
|
+
});
|
|
13041
|
+
}
|
|
13042
|
+
}
|
|
13043
|
+
let TreeShakingSharedPlugin_require = createRequire(import.meta.url);
|
|
13044
|
+
class TreeShakingSharedPlugin {
|
|
13045
|
+
mfConfig;
|
|
13046
|
+
outputDir;
|
|
13047
|
+
secondary;
|
|
13048
|
+
_independentSharePlugin;
|
|
13049
|
+
name = 'TreeShakingSharedPlugin';
|
|
13050
|
+
constructor(options){
|
|
13051
|
+
let { mfConfig, secondary } = options;
|
|
13052
|
+
this.mfConfig = mfConfig, this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages', this.secondary = !!secondary;
|
|
13053
|
+
}
|
|
13054
|
+
apply(compiler) {
|
|
13055
|
+
let { mfConfig, outputDir, secondary } = this, { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
13056
|
+
if (!shared) return;
|
|
13057
|
+
let sharedOptions = normalizeSharedOptions(shared);
|
|
13058
|
+
sharedOptions.length && sharedOptions.some(([_, config])=>config.treeShaking && !1 !== config.import) && (secondary || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
|
|
13059
|
+
name: name,
|
|
13060
|
+
shared: shared,
|
|
13061
|
+
outputDir,
|
|
13062
|
+
plugins: treeShakingSharedPlugins?.map((p)=>new (TreeShakingSharedPlugin_require(p))()) || [],
|
|
13063
|
+
treeShaking: secondary,
|
|
13064
|
+
library,
|
|
13065
|
+
manifest: mfConfig.manifest,
|
|
13066
|
+
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
13067
|
+
}), this._independentSharePlugin.apply(compiler));
|
|
13068
|
+
}
|
|
13069
|
+
get buildAssets() {
|
|
13070
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
13071
|
+
}
|
|
13072
|
+
}
|
|
13073
|
+
let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), ModuleFederationPlugin_require = createRequire(import.meta.url);
|
|
13074
|
+
function getRemoteInfos(options) {
|
|
13075
|
+
if (!options.remotes) return {};
|
|
13076
|
+
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
13077
|
+
external: Array.isArray(item) ? item : [
|
|
13078
|
+
item
|
|
13079
|
+
],
|
|
13080
|
+
shareScope: options.shareScope || 'default'
|
|
13081
|
+
}), (item)=>({
|
|
13082
|
+
external: Array.isArray(item.external) ? item.external : [
|
|
13083
|
+
item.external
|
|
13084
|
+
],
|
|
13085
|
+
shareScope: item.shareScope || options.shareScope || 'default'
|
|
13086
|
+
})), remoteInfos = {};
|
|
13087
|
+
for (let [key, config] of remotes)for (let external of config.external){
|
|
13088
|
+
let [externalType, externalRequest] = function(external) {
|
|
13089
|
+
let result = function(external) {
|
|
13090
|
+
if (/^[a-z0-9-]+ /.test(external)) {
|
|
13091
|
+
let idx = external.indexOf(' ');
|
|
13092
|
+
return [
|
|
13093
|
+
external.slice(0, idx),
|
|
13094
|
+
external.slice(idx + 1)
|
|
13095
|
+
];
|
|
13096
|
+
}
|
|
13097
|
+
return null;
|
|
13098
|
+
}(external);
|
|
13099
|
+
return null === result ? [
|
|
13100
|
+
remoteType,
|
|
13101
|
+
external
|
|
13102
|
+
] : result;
|
|
13103
|
+
}(external);
|
|
13104
|
+
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
13105
|
+
let [url, global] = function(urlAndGlobal) {
|
|
13106
|
+
let index = urlAndGlobal.indexOf('@');
|
|
13107
|
+
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
13108
|
+
urlAndGlobal.substring(index + 1),
|
|
13109
|
+
urlAndGlobal.substring(0, index)
|
|
13110
|
+
];
|
|
13111
|
+
}(externalRequest);
|
|
13112
|
+
remoteInfos[key].push({
|
|
13113
|
+
alias: key,
|
|
13114
|
+
name: global,
|
|
13115
|
+
entry: url,
|
|
13116
|
+
externalType,
|
|
13117
|
+
shareScope: config.shareScope
|
|
13118
|
+
});
|
|
13119
|
+
} else remoteInfos[key].push({
|
|
13120
|
+
alias: key,
|
|
13121
|
+
name: void 0,
|
|
13122
|
+
entry: void 0,
|
|
13123
|
+
externalType,
|
|
13124
|
+
shareScope: config.shareScope
|
|
13125
|
+
});
|
|
13126
|
+
}
|
|
13127
|
+
return remoteInfos;
|
|
13128
|
+
}
|
|
13129
|
+
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
13130
|
+
let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || 'var';
|
|
13131
|
+
for(let i = 0; i < runtimePlugins.length; i++){
|
|
13132
|
+
let runtimePluginVar = `__module_federation_runtime_plugin_${i}__`, pluginSpec = runtimePlugins[i], pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec, pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
|
|
13133
|
+
runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
|
|
13134
|
+
let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
|
|
13135
|
+
runtimePluginVars.push(`{ plugin: ${runtimePluginVar}, params: ${paramsCode} }`);
|
|
13136
|
+
}
|
|
13137
|
+
let content = [
|
|
13138
|
+
`import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
|
|
13139
|
+
...runtimePluginImports,
|
|
13140
|
+
`const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}].filter(({ plugin }) => plugin).map(({ plugin, params }) => plugin(params))`,
|
|
13141
|
+
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
13142
|
+
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
13143
|
+
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
13144
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
13145
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
13146
|
+
compiler.webpack.Template.getFunctionContent(ModuleFederationPlugin_require('./moduleFederationDefaultRuntime.js').default)
|
|
13147
|
+
].join(';');
|
|
13148
|
+
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
13149
|
+
}
|
|
12251
13150
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
12252
13151
|
name = binding_namespaceObject.BuiltinPluginName.ContainerPlugin;
|
|
12253
13152
|
_options;
|
|
@@ -12256,7 +13155,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
12256
13155
|
name: options.name,
|
|
12257
13156
|
shareScope: options.shareScope || 'default',
|
|
12258
13157
|
library: options.library || {
|
|
12259
|
-
type: '
|
|
13158
|
+
type: 'global',
|
|
12260
13159
|
name: options.name
|
|
12261
13160
|
},
|
|
12262
13161
|
runtime: options.runtime,
|
|
@@ -12343,7 +13242,7 @@ async function transform(source, options) {
|
|
|
12343
13242
|
let _options = JSON.stringify(options || {});
|
|
12344
13243
|
return binding_default().transform(source, _options);
|
|
12345
13244
|
}
|
|
12346
|
-
let exports_rspackVersion = "2.0.0-beta.
|
|
13245
|
+
let exports_rspackVersion = "2.0.0-beta.2", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
|
|
12347
13246
|
getNormalizedRspackOptions: getNormalizedRspackOptions,
|
|
12348
13247
|
applyRspackOptionsDefaults: applyRspackOptionsDefaults,
|
|
12349
13248
|
getNormalizedWebpackOptions: getNormalizedRspackOptions,
|
|
@@ -12386,10 +13285,12 @@ let exports_rspackVersion = "2.0.0-beta.0", exports_version = "5.75.0", exports_
|
|
|
12386
13285
|
ContainerReferencePlugin: ContainerReferencePlugin,
|
|
12387
13286
|
ModuleFederationPlugin: class {
|
|
12388
13287
|
_options;
|
|
13288
|
+
_treeShakingSharedPlugin;
|
|
12389
13289
|
constructor(_options){
|
|
12390
13290
|
this._options = _options;
|
|
12391
13291
|
}
|
|
12392
13292
|
apply(compiler) {
|
|
13293
|
+
var options;
|
|
12393
13294
|
let { webpack } = compiler, paths = function(options, compiler) {
|
|
12394
13295
|
let runtimeToolsPath;
|
|
12395
13296
|
if (options.implementation) runtimeToolsPath = options.implementation;
|
|
@@ -12422,32 +13323,38 @@ let exports_rspackVersion = "2.0.0-beta.0", exports_version = "5.75.0", exports_
|
|
|
12422
13323
|
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
12423
13324
|
'@module-federation/runtime': paths.runtime,
|
|
12424
13325
|
...compiler.options.resolve.alias
|
|
12425
|
-
}
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
13326
|
+
}, ((options = this._options).shared ? parseOptions(options.shared, (item, key)=>{
|
|
13327
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
13328
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
13329
|
+
import: key,
|
|
13330
|
+
requiredVersion: item
|
|
13331
|
+
} : {
|
|
13332
|
+
import: item
|
|
13333
|
+
};
|
|
13334
|
+
}, (item)=>item) : []).filter(([, config])=>config.treeShaking).length > 0 && (this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
|
|
13335
|
+
mfConfig: this._options,
|
|
13336
|
+
secondary: !1
|
|
13337
|
+
}), this._treeShakingSharedPlugin.apply(compiler));
|
|
13338
|
+
let runtimeExperiments = {
|
|
13339
|
+
asyncStartup: this._options.experiments?.asyncStartup ?? !1
|
|
13340
|
+
}, runtimePluginApplied = !1;
|
|
13341
|
+
compiler.hooks.beforeRun.tap({
|
|
13342
|
+
name: 'ModuleFederationPlugin',
|
|
13343
|
+
stage: 100
|
|
13344
|
+
}, ()=>{
|
|
13345
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
13346
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets),
|
|
13347
|
+
experiments: runtimeExperiments
|
|
13348
|
+
}).apply(compiler));
|
|
13349
|
+
}), compiler.hooks.watchRun.tap({
|
|
13350
|
+
name: 'ModuleFederationPlugin',
|
|
13351
|
+
stage: 100
|
|
13352
|
+
}, ()=>{
|
|
13353
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
13354
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {}),
|
|
13355
|
+
experiments: runtimeExperiments
|
|
13356
|
+
}).apply(compiler));
|
|
13357
|
+
});
|
|
12451
13358
|
let v1Options = {
|
|
12452
13359
|
name: this._options.name,
|
|
12453
13360
|
exposes: this._options.exposes,
|
|
@@ -12460,74 +13367,7 @@ let exports_rspackVersion = "2.0.0-beta.0", exports_version = "5.75.0", exports_
|
|
|
12460
13367
|
shared: this._options.shared,
|
|
12461
13368
|
enhanced: !0
|
|
12462
13369
|
};
|
|
12463
|
-
|
|
12464
|
-
let manifestOptions = !0 === this._options.manifest ? {} : {
|
|
12465
|
-
...this._options.manifest
|
|
12466
|
-
}, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
|
|
12467
|
-
if (!library) return;
|
|
12468
|
-
let libName = library.name;
|
|
12469
|
-
if (libName) {
|
|
12470
|
-
if ('string' == typeof libName) return libName;
|
|
12471
|
-
if (Array.isArray(libName)) return libName[0];
|
|
12472
|
-
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12473
|
-
}
|
|
12474
|
-
}(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
12475
|
-
if (cur[1].length > 1) return sum;
|
|
12476
|
-
let { entry, alias, name } = cur[1][0];
|
|
12477
|
-
return entry && name && (sum[alias] = {
|
|
12478
|
-
name,
|
|
12479
|
-
entry
|
|
12480
|
-
}), sum;
|
|
12481
|
-
}, {}), manifestExposes = function(exposes) {
|
|
12482
|
-
if (!exposes) return;
|
|
12483
|
-
let result = parseOptions(exposes, (value)=>({
|
|
12484
|
-
import: Array.isArray(value) ? value : [
|
|
12485
|
-
value
|
|
12486
|
-
],
|
|
12487
|
-
name: void 0
|
|
12488
|
-
}), (value)=>({
|
|
12489
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
12490
|
-
value.import
|
|
12491
|
-
],
|
|
12492
|
-
name: value.name ?? void 0
|
|
12493
|
-
})).map(([exposeKey, info])=>{
|
|
12494
|
-
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12495
|
-
return {
|
|
12496
|
-
path: exposeKey,
|
|
12497
|
-
name: exposeName
|
|
12498
|
-
};
|
|
12499
|
-
});
|
|
12500
|
-
return result.length > 0 ? result : void 0;
|
|
12501
|
-
}(this._options.exposes);
|
|
12502
|
-
void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
|
|
12503
|
-
let manifestShared = function(shared) {
|
|
12504
|
-
if (!shared) return;
|
|
12505
|
-
let result = parseOptions(shared, (item, key)=>{
|
|
12506
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12507
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12508
|
-
import: key,
|
|
12509
|
-
requiredVersion: item
|
|
12510
|
-
} : {
|
|
12511
|
-
import: item
|
|
12512
|
-
};
|
|
12513
|
-
}, (item)=>item).map(([key, config])=>{
|
|
12514
|
-
let name = config.shareKey || key;
|
|
12515
|
-
return {
|
|
12516
|
-
name,
|
|
12517
|
-
version: 'string' == typeof config.version ? config.version : void 0,
|
|
12518
|
-
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12519
|
-
singleton: config.singleton
|
|
12520
|
-
};
|
|
12521
|
-
});
|
|
12522
|
-
return result.length > 0 ? result : void 0;
|
|
12523
|
-
}(this._options.shared);
|
|
12524
|
-
void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
|
|
12525
|
-
...manifestOptions,
|
|
12526
|
-
name: containerName,
|
|
12527
|
-
globalName,
|
|
12528
|
-
remoteAliasMap
|
|
12529
|
-
}).apply(compiler);
|
|
12530
|
-
}
|
|
13370
|
+
new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
12531
13371
|
}
|
|
12532
13372
|
},
|
|
12533
13373
|
ModuleFederationPluginV1: class {
|
|
@@ -12564,6 +13404,7 @@ let exports_rspackVersion = "2.0.0-beta.0", exports_version = "5.75.0", exports_
|
|
|
12564
13404
|
}
|
|
12565
13405
|
}, sharing = {
|
|
12566
13406
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
13407
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
12567
13408
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
12568
13409
|
SharePlugin: SharePlugin
|
|
12569
13410
|
}, exports_experiments = {
|
|
@@ -12629,7 +13470,7 @@ let exports_rspackVersion = "2.0.0-beta.0", exports_version = "5.75.0", exports_
|
|
|
12629
13470
|
ssr: 'server-side-rendering'
|
|
12630
13471
|
}
|
|
12631
13472
|
}
|
|
12632
|
-
}, src_fn = Object.assign(
|
|
13473
|
+
}, src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
|
|
12633
13474
|
src_fn.rspack = src_fn, src_fn.webpack = src_fn;
|
|
12634
13475
|
let src_rspack_0 = src_fn;
|
|
12635
13476
|
var AsyncDependenciesBlock = binding_namespaceObject.AsyncDependenciesBlock, ConcatenatedModule = binding_namespaceObject.ConcatenatedModule, ContextModule = binding_namespaceObject.ContextModule, Dependency = binding_namespaceObject.Dependency, EntryDependency = binding_namespaceObject.EntryDependency, ExternalModule = binding_namespaceObject.ExternalModule, Module = binding_namespaceObject.Module, NormalModule = binding_namespaceObject.NormalModule;
|