@rspack-debug/core 2.0.0-alpha.1 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Compilation.d.ts +1 -0
- package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +1 -1
- package/dist/config/normalization.d.ts +1 -2
- package/dist/config/types.d.ts +106 -30
- 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 -0
- package/dist/index.js +1233 -332
- package/dist/moduleFederationDefaultRuntime.js +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/util/createHash.d.ts +1 -1
- package/dist/worker.js +0 -16
- package/package.json +8 -8
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
|
]),
|
|
@@ -1475,7 +1950,18 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1475
1950
|
seal: new SyncHook([]),
|
|
1476
1951
|
afterSeal: new AsyncSeriesHook([]),
|
|
1477
1952
|
needAdditionalPass: new SyncBailHook([])
|
|
1478
|
-
}
|
|
1953
|
+
};
|
|
1954
|
+
let availableHooks = Object.keys(this.hooks);
|
|
1955
|
+
this.hooks = new Proxy(this.hooks, {
|
|
1956
|
+
get (target, prop, receiver) {
|
|
1957
|
+
let value = Reflect.get(target, prop, receiver);
|
|
1958
|
+
if (void 0 === value && 'string' == typeof prop) {
|
|
1959
|
+
let hooksList = availableHooks.join(', ');
|
|
1960
|
+
throw Error(`Compilation.hooks.${prop} is not supported in rspack. This typically happens when using webpack plugins that rely on webpack-specific hooks. Consider using an rspack-compatible alternative or removing the incompatible plugin.\n\nAvailable compilation hooks: ${hooksList}`);
|
|
1961
|
+
}
|
|
1962
|
+
return value;
|
|
1963
|
+
}
|
|
1964
|
+
}), this.compiler = compiler, this.resolverFactory = compiler.resolverFactory, this.inputFileSystem = compiler.inputFileSystem, this.options = compiler.options, this.outputOptions = compiler.options.output, this.logging = new Map(), this.childrenCounters = {}, this.children = [], this.needAdditionalPass = !1, this.chunkGraph = inner.chunkGraph, this.moduleGraph = ModuleGraph.__from_binding(inner.moduleGraph), this.#addIncludeDispatcher = new AddEntryItemDispatcher(inner.addInclude.bind(inner)), this.#addEntryDispatcher = new AddEntryItemDispatcher(inner.addEntry.bind(inner)), this[binding_default().COMPILATION_HOOKS_MAP_SYMBOL] = new WeakMap();
|
|
1479
1965
|
}
|
|
1480
1966
|
get hash() {
|
|
1481
1967
|
return this.#inner.hash;
|
|
@@ -2186,7 +2672,7 @@ class EnableLibraryPlugin extends RspackBuiltinPlugin {
|
|
|
2186
2672
|
}
|
|
2187
2673
|
let EnableWasmLoadingPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EnableWasmLoadingPlugin, (type)=>type), EnsureChunkConditionsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EnsureChunkConditionsPlugin, ()=>{}), RemoveDuplicateModulesPlugin = base_create(binding_namespaceObject.BuiltinPluginName.RemoveDuplicateModulesPlugin, ()=>({}));
|
|
2188
2674
|
function applyLimits(options) {
|
|
2189
|
-
options.optimization.concatenateModules = !1, options.optimization.removeEmptyChunks = !1, options.output.chunkFormat = !1, options.output.
|
|
2675
|
+
options.optimization.concatenateModules = !1, options.optimization.removeEmptyChunks = !1, options.output.chunkFormat = !1, options.output.chunkLoading && 'import' !== options.output.chunkLoading && (options.output.chunkLoading = 'import'), void 0 === options.output.chunkLoading && (options.output.chunkLoading = 'import');
|
|
2190
2676
|
let { splitChunks } = options.optimization;
|
|
2191
2677
|
void 0 === splitChunks && (splitChunks = options.optimization.splitChunks = {}), !1 !== splitChunks && (splitChunks.chunks = 'all', splitChunks.minSize = 0, splitChunks.maxAsyncRequests = 1 / 0, splitChunks.maxInitialRequests = 1 / 0, splitChunks.cacheGroups ??= {}, splitChunks.cacheGroups.default = !1, splitChunks.cacheGroups.defaultVendors = !1);
|
|
2192
2678
|
}
|
|
@@ -2809,20 +3295,6 @@ class BulkUpdateDecorator extends Hash {
|
|
|
2809
3295
|
return void 0 !== digestCache && 'string' == typeof result && digestCache.set(buffer, result), result;
|
|
2810
3296
|
}
|
|
2811
3297
|
}
|
|
2812
|
-
class DebugHash extends Hash {
|
|
2813
|
-
string;
|
|
2814
|
-
constructor(){
|
|
2815
|
-
super(), this.string = '';
|
|
2816
|
-
}
|
|
2817
|
-
update(data) {
|
|
2818
|
-
let normalizedData;
|
|
2819
|
-
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;
|
|
2820
|
-
}
|
|
2821
|
-
digest(encoding) {
|
|
2822
|
-
let result = `debug-digest-${Buffer.from(this.string).toString('hex')}`;
|
|
2823
|
-
return encoding ? result : Buffer.from(result);
|
|
2824
|
-
}
|
|
2825
|
-
}
|
|
2826
3298
|
class WasmHashAdapter extends Hash {
|
|
2827
3299
|
wasmHash;
|
|
2828
3300
|
constructor(wasmHash){
|
|
@@ -2838,8 +3310,6 @@ class WasmHashAdapter extends Hash {
|
|
|
2838
3310
|
let createHash_createHash = (algorithm)=>{
|
|
2839
3311
|
if ('function' == typeof algorithm) return new BulkUpdateDecorator(()=>new algorithm());
|
|
2840
3312
|
switch(algorithm){
|
|
2841
|
-
case 'debug':
|
|
2842
|
-
return new DebugHash();
|
|
2843
3313
|
case 'xxhash64':
|
|
2844
3314
|
return new WasmHashAdapter((()=>{
|
|
2845
3315
|
if (!createXxhash64) {
|
|
@@ -3928,7 +4398,6 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3928
4398
|
exportsPresence: !1 === parser.exportsPresence ? 'false' : parser.exportsPresence,
|
|
3929
4399
|
importExportsPresence: !1 === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
|
|
3930
4400
|
reexportExportsPresence: !1 === parser.reexportExportsPresence ? 'false' : parser.reexportExportsPresence,
|
|
3931
|
-
strictExportPresence: parser.strictExportPresence,
|
|
3932
4401
|
worker: 'boolean' == typeof parser.worker ? parser.worker ? [
|
|
3933
4402
|
'...'
|
|
3934
4403
|
] : [] : parser.worker,
|
|
@@ -3948,7 +4417,8 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3948
4417
|
function getRawCssParserOptions(parser) {
|
|
3949
4418
|
return {
|
|
3950
4419
|
namedExports: parser.namedExports,
|
|
3951
|
-
url: parser.url
|
|
4420
|
+
url: parser.url,
|
|
4421
|
+
resolveImport: parser.resolveImport
|
|
3952
4422
|
};
|
|
3953
4423
|
}
|
|
3954
4424
|
function getRawGeneratorOptions(generator, type) {
|
|
@@ -4402,7 +4872,7 @@ let JsLoaderRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName
|
|
|
4402
4872
|
test,
|
|
4403
4873
|
client,
|
|
4404
4874
|
currentActiveModules
|
|
4405
|
-
}), 'thisCompilation'), middleware_require = createRequire(import.meta.url), LAZY_COMPILATION_PREFIX = '/lazy
|
|
4875
|
+
}), 'thisCompilation'), middleware_require = createRequire(import.meta.url), LAZY_COMPILATION_PREFIX = '/_rspack/lazy/trigger', noop = (_req, _res, next)=>{
|
|
4406
4876
|
'function' == typeof next && next();
|
|
4407
4877
|
}, lazyCompilationMiddleware = (compiler)=>{
|
|
4408
4878
|
if (compiler instanceof MultiCompiler) {
|
|
@@ -6031,13 +6501,12 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6031
6501
|
if ('function' != typeof options.entry) for (let key of Object.keys(options.entry))F(options.entry[key], 'import', ()=>[
|
|
6032
6502
|
'./src'
|
|
6033
6503
|
]);
|
|
6034
|
-
return F(options, 'devtool', ()=>!!development && '
|
|
6504
|
+
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, {
|
|
6035
6505
|
production,
|
|
6036
6506
|
development
|
|
6037
6507
|
}), applySnapshotDefaults(options.snapshot, {
|
|
6038
6508
|
production
|
|
6039
6509
|
}), applyModuleDefaults(options.module, {
|
|
6040
|
-
cache: !!options.cache,
|
|
6041
6510
|
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
|
6042
6511
|
targetProperties,
|
|
6043
6512
|
mode: options.mode,
|
|
@@ -6047,7 +6516,6 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6047
6516
|
context: options.context,
|
|
6048
6517
|
targetProperties,
|
|
6049
6518
|
isAffectedByBrowserslist: void 0 === target || 'string' == typeof target && target.startsWith('browserslist') || Array.isArray(target) && target.some((target)=>target.startsWith('browserslist')),
|
|
6050
|
-
outputModule: options.experiments.outputModule,
|
|
6051
6519
|
entry: options.entry
|
|
6052
6520
|
}), applyExternalsPresetsDefaults(options.externalsPresets, {
|
|
6053
6521
|
targetProperties,
|
|
@@ -6080,12 +6548,12 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6080
6548
|
}, applyExperimentsDefaults = (experiments)=>{
|
|
6081
6549
|
D(experiments, 'futureDefaults', !1), D(experiments, 'asyncWebAssembly', !0), D(experiments, 'deferImport', !1), D(experiments, 'buildHttp', void 0), experiments.buildHttp && 'object' == typeof experiments.buildHttp && D(experiments.buildHttp, 'upgrade', !1), D(experiments, 'useInputFileSystem', !1);
|
|
6082
6550
|
}, applyIncrementalDefaults = (options)=>{
|
|
6083
|
-
D(options, 'incremental', {}), 'object' == typeof options.incremental && (D(options.incremental, 'silent', !0), D(options.incremental, 'buildModuleGraph', !0), D(options.incremental, 'finishModules', !0), D(options.incremental, 'optimizeDependencies', !0), D(options.incremental, 'buildChunkGraph', !
|
|
6551
|
+
D(options, 'incremental', {}), 'object' == typeof options.incremental && (D(options.incremental, 'silent', !0), D(options.incremental, 'buildModuleGraph', !0), D(options.incremental, 'finishModules', !0), D(options.incremental, 'optimizeDependencies', !0), D(options.incremental, 'buildChunkGraph', !0), D(options.incremental, 'moduleIds', !0), D(options.incremental, 'chunkIds', !0), D(options.incremental, 'modulesHashes', !0), D(options.incremental, 'modulesCodegen', !0), D(options.incremental, 'modulesRuntimeRequirements', !0), D(options.incremental, 'chunksRuntimeRequirements', !0), D(options.incremental, 'chunksHashes', !0), D(options.incremental, 'chunkAsset', !0), D(options.incremental, 'emitAssets', !0));
|
|
6084
6552
|
}, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
|
|
6085
6553
|
D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
|
|
6086
|
-
}, applyModuleDefaults = (module, {
|
|
6087
|
-
assertNotNill(module.parser), assertNotNill(module.generator),
|
|
6088
|
-
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, '
|
|
6554
|
+
}, applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport })=>{
|
|
6555
|
+
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 })=>{
|
|
6556
|
+
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', [
|
|
6089
6557
|
'...'
|
|
6090
6558
|
]), D(parserOptions, 'importMeta', !0), D(parserOptions, 'typeReexportsPresence', 'no-tolerant'), D(parserOptions, 'jsx', !1), D(parserOptions, 'deferImport', deferImport);
|
|
6091
6559
|
})(module.parser.javascript, {
|
|
@@ -6205,7 +6673,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6205
6673
|
type: 'asset/bytes'
|
|
6206
6674
|
}), rules;
|
|
6207
6675
|
});
|
|
6208
|
-
}, applyOutputDefaults = (options, { context,
|
|
6676
|
+
}, applyOutputDefaults = (options, { context, targetProperties: tp, isAffectedByBrowserslist, entry })=>{
|
|
6209
6677
|
let { output } = options, getLibraryName = (library)=>{
|
|
6210
6678
|
let libraryName = 'object' == typeof library && library && !Array.isArray(library) ? library.name : library;
|
|
6211
6679
|
return Array.isArray(libraryName) ? libraryName.join('.') : 'object' == typeof libraryName ? getLibraryName(libraryName.root) : 'string' == typeof libraryName ? libraryName : '';
|
|
@@ -6223,7 +6691,19 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6223
6691
|
if ('ENOENT' !== err.code) throw err.message += `\nwhile determining default 'output.uniqueName' from 'name' in ${pkgPath}`, err;
|
|
6224
6692
|
return '';
|
|
6225
6693
|
}
|
|
6226
|
-
}), F(output, 'devtoolNamespace', ()=>output.uniqueName), F(output, '
|
|
6694
|
+
}), F(output, 'devtoolNamespace', ()=>output.uniqueName), output.library && F(output.library, 'type', ()=>output.module ? 'modern-module' : 'var');
|
|
6695
|
+
let forEachEntry = (fn)=>{
|
|
6696
|
+
if ('function' != typeof entry) for (let name of Object.keys(entry))fn(entry[name]);
|
|
6697
|
+
};
|
|
6698
|
+
A(output, 'enabledLibraryTypes', ()=>{
|
|
6699
|
+
let enabledLibraryTypes = [];
|
|
6700
|
+
return output.library && enabledLibraryTypes.push(output.library.type), forEachEntry((desc)=>{
|
|
6701
|
+
desc.library && enabledLibraryTypes.push(desc.library.type);
|
|
6702
|
+
}), enabledLibraryTypes.includes('modern-module') && applyLimits(options), enabledLibraryTypes;
|
|
6703
|
+
}), D(output, 'module', [
|
|
6704
|
+
'modern-module',
|
|
6705
|
+
'module'
|
|
6706
|
+
].some((ty)=>output.enabledLibraryTypes.includes(ty)));
|
|
6227
6707
|
let environment = output.environment, conditionallyOptimistic = (v, c)=>void 0 === v && c || v;
|
|
6228
6708
|
F(environment, 'globalThis', ()=>tp && tp.globalThis), F(environment, 'bigIntLiteral', ()=>{
|
|
6229
6709
|
let v;
|
|
@@ -6273,7 +6753,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6273
6753
|
return 'function' != typeof chunkFilename ? chunkFilename.replace(/\.[mc]?js(\?|$)/, '.css$1') : '[id].css';
|
|
6274
6754
|
}), D(output, 'hotUpdateChunkFilename', `[id].[fullhash].hot-update.${output.module ? 'mjs' : 'js'}`), F(output, 'hotUpdateMainFilename', ()=>`[runtime].[fullhash].hot-update.${output.module ? 'json.mjs' : 'json'}`);
|
|
6275
6755
|
let uniqueNameId = Template.toIdentifier(output.uniqueName);
|
|
6276
|
-
F(output, 'hotUpdateGlobal', ()=>`rspackHotUpdate${uniqueNameId}`), F(output, 'chunkLoadingGlobal', ()=>`rspackChunk${uniqueNameId}`), D(output, 'assetModuleFilename', '[hash][ext][query]'), D(output, 'webassemblyModuleFilename', '[hash].module.wasm'), D(output, 'compareBeforeEmit', !0), F(output, 'path', ()=>node_path.join(process.cwd(), 'dist')), F(output, 'pathinfo', ()=>!1), D(output, 'publicPath', tp && (tp.document || tp.importScripts) ? 'auto' : ''), D(output, 'hashFunction', 'xxhash64'), D(output, 'hashDigest', 'hex'), D(output, 'hashDigestLength', 16), D(output, 'strictModuleErrorHandling', !1),
|
|
6756
|
+
F(output, 'hotUpdateGlobal', ()=>`rspackHotUpdate${uniqueNameId}`), F(output, 'chunkLoadingGlobal', ()=>`rspackChunk${uniqueNameId}`), D(output, 'assetModuleFilename', '[hash][ext][query]'), D(output, 'webassemblyModuleFilename', '[hash].module.wasm'), D(output, 'compareBeforeEmit', !0), F(output, 'path', ()=>node_path.join(process.cwd(), 'dist')), F(output, 'pathinfo', ()=>!1), D(output, 'publicPath', tp && (tp.document || tp.importScripts) ? 'auto' : ''), D(output, 'hashFunction', 'xxhash64'), D(output, 'hashDigest', 'hex'), D(output, 'hashDigestLength', 16), D(output, 'strictModuleErrorHandling', !1), F(output, 'chunkFormat', ()=>{
|
|
6277
6757
|
if (tp) {
|
|
6278
6758
|
let helpMessage = isAffectedByBrowserslist ? "Make sure that your 'browserslist' includes only platforms that support these features or select an appropriate 'target' to allow selecting a chunk format by default. Alternatively specify the 'output.chunkFormat' directly." : "Select an appropriate 'target' to allow selecting one by default, or specify the 'output.chunkFormat' directly.";
|
|
6279
6759
|
if (output.module) {
|
|
@@ -6335,16 +6815,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6335
6815
|
return 'self';
|
|
6336
6816
|
}), D(output, 'importFunctionName', 'import'), D(output, 'importMetaName', 'import.meta'), F(output, 'clean', ()=>!!output.clean), D(output, 'crossOriginLoading', !1), D(output, 'workerPublicPath', ''), D(output, 'sourceMapFilename', '[file].map[query]'), F(output, "scriptType", ()=>!!output.module && 'module'), D(output, 'chunkLoadTimeout', 120000);
|
|
6337
6817
|
let { trustedTypes } = output;
|
|
6338
|
-
trustedTypes && (F(trustedTypes, 'policyName', ()=>output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, '_') || 'rspack'), D(trustedTypes, 'onPolicyCreationFailure', 'stop'))
|
|
6339
|
-
let forEachEntry = (fn)=>{
|
|
6340
|
-
if ('function' != typeof entry) for (let name of Object.keys(entry))fn(entry[name]);
|
|
6341
|
-
};
|
|
6342
|
-
A(output, 'enabledLibraryTypes', ()=>{
|
|
6343
|
-
let enabledLibraryTypes = [];
|
|
6344
|
-
return output.library && enabledLibraryTypes.push(output.library.type), forEachEntry((desc)=>{
|
|
6345
|
-
desc.library && enabledLibraryTypes.push(desc.library.type);
|
|
6346
|
-
}), enabledLibraryTypes.includes('modern-module') && applyLimits(options), enabledLibraryTypes;
|
|
6347
|
-
}), A(output, 'enabledChunkLoadingTypes', ()=>{
|
|
6818
|
+
trustedTypes && (F(trustedTypes, 'policyName', ()=>output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, '_') || 'rspack'), D(trustedTypes, 'onPolicyCreationFailure', 'stop')), A(output, 'enabledChunkLoadingTypes', ()=>{
|
|
6348
6819
|
let enabledChunkLoadingTypes = new Set();
|
|
6349
6820
|
return output.chunkLoading && enabledChunkLoadingTypes.add(output.chunkLoading), output.workerChunkLoading && enabledChunkLoadingTypes.add(output.workerChunkLoading), forEachEntry((desc)=>{
|
|
6350
6821
|
desc.chunkLoading && enabledChunkLoadingTypes.add(desc.chunkLoading);
|
|
@@ -6354,7 +6825,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6354
6825
|
return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
|
|
6355
6826
|
desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
|
|
6356
6827
|
}), Array.from(enabledWasmLoadingTypes);
|
|
6357
|
-
}), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-
|
|
6828
|
+
}), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.1"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
|
|
6358
6829
|
}, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
|
|
6359
6830
|
let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
|
|
6360
6831
|
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')));
|
|
@@ -6635,8 +7106,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6635
7106
|
]),
|
|
6636
7107
|
rules: nestedArray(module.rules, (r)=>[
|
|
6637
7108
|
...r
|
|
6638
|
-
])
|
|
6639
|
-
unsafeCache: module.unsafeCache
|
|
7109
|
+
])
|
|
6640
7110
|
})),
|
|
6641
7111
|
target: config.target,
|
|
6642
7112
|
externals: config.externals,
|
|
@@ -6672,7 +7142,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6672
7142
|
storage: {
|
|
6673
7143
|
type: 'filesystem',
|
|
6674
7144
|
directory: node_path.resolve(config.context || process.cwd(), cache.storage?.directory || 'node_modules/.cache/rspack')
|
|
6675
|
-
}
|
|
7145
|
+
},
|
|
7146
|
+
portable: cache.portable,
|
|
7147
|
+
readonly: cache.readonly
|
|
6676
7148
|
};
|
|
6677
7149
|
}),
|
|
6678
7150
|
stats: nestedConfig(config.stats, (stats)=>!1 === stats ? {
|
|
@@ -6772,7 +7244,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6772
7244
|
buildModuleGraph: !0,
|
|
6773
7245
|
finishModules: !1,
|
|
6774
7246
|
optimizeDependencies: !1,
|
|
6775
|
-
buildChunkGraph: !
|
|
7247
|
+
buildChunkGraph: !0,
|
|
6776
7248
|
moduleIds: !1,
|
|
6777
7249
|
chunkIds: !1,
|
|
6778
7250
|
modulesHashes: !1,
|
|
@@ -7606,7 +8078,7 @@ class MultiStats {
|
|
|
7606
8078
|
obj.children = this.stats.map((stat, idx)=>{
|
|
7607
8079
|
let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
|
|
7608
8080
|
return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
|
|
7609
|
-
}), childOptions.version && (obj.rspackVersion = "2.0.0-
|
|
8081
|
+
}), childOptions.version && (obj.rspackVersion = "2.0.0-beta.1", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
|
|
7610
8082
|
let mapError = (j, obj)=>({
|
|
7611
8083
|
...obj,
|
|
7612
8084
|
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
|
@@ -8865,7 +9337,7 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8865
9337
|
object.hash = context.getStatsCompilation(compilation).hash;
|
|
8866
9338
|
},
|
|
8867
9339
|
version: (object)=>{
|
|
8868
|
-
object.version = "5.75.0", object.rspackVersion = "2.0.0-
|
|
9340
|
+
object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.1";
|
|
8869
9341
|
},
|
|
8870
9342
|
env: (object, _compilation, _context, { _env })=>{
|
|
8871
9343
|
object.env = _env;
|
|
@@ -10230,7 +10702,7 @@ function createCompiler(userOptions) {
|
|
|
10230
10702
|
function isMultiRspackOptions(o) {
|
|
10231
10703
|
return Array.isArray(o);
|
|
10232
10704
|
}
|
|
10233
|
-
function
|
|
10705
|
+
function rspack_rspack(options, callback) {
|
|
10234
10706
|
try {
|
|
10235
10707
|
if (isMultiRspackOptions(options)) for (let option of options)validateRspackConfig(option);
|
|
10236
10708
|
else validateRspackConfig(options);
|
|
@@ -10526,7 +10998,7 @@ class TraceHookPlugin {
|
|
|
10526
10998
|
});
|
|
10527
10999
|
}
|
|
10528
11000
|
}
|
|
10529
|
-
let CORE_VERSION = "2.0.0-
|
|
11001
|
+
let CORE_VERSION = "2.0.0-beta.1", VFILES_BY_COMPILER = new WeakMap();
|
|
10530
11002
|
class VirtualModulesPlugin {
|
|
10531
11003
|
#staticModules;
|
|
10532
11004
|
#compiler;
|
|
@@ -10838,8 +11310,19 @@ class Compiler {
|
|
|
10838
11310
|
]),
|
|
10839
11311
|
additionalPass: new AsyncSeriesHook([])
|
|
10840
11312
|
};
|
|
11313
|
+
let availableCompilerHooks = Object.keys(this.hooks);
|
|
11314
|
+
this.hooks = new Proxy(this.hooks, {
|
|
11315
|
+
get (target, prop, receiver) {
|
|
11316
|
+
let value = Reflect.get(target, prop, receiver);
|
|
11317
|
+
if (void 0 === value && 'string' == typeof prop) {
|
|
11318
|
+
let hooksList = availableCompilerHooks.join(', ');
|
|
11319
|
+
throw Error(`Compiler.hooks.${prop} is not supported in rspack. This typically happens when using webpack plugins that rely on webpack-specific hooks. Consider using an rspack-compatible alternative or removing the incompatible plugin.\n\nAvailable compiler hooks: ${hooksList}`);
|
|
11320
|
+
}
|
|
11321
|
+
return value;
|
|
11322
|
+
}
|
|
11323
|
+
});
|
|
10841
11324
|
let compilerRspack = Object.assign(function(...params) {
|
|
10842
|
-
return
|
|
11325
|
+
return rspack_rspack(...params);
|
|
10843
11326
|
}, exports_namespaceObject, {
|
|
10844
11327
|
RuntimeGlobals: createCompilerRuntimeGlobals(options)
|
|
10845
11328
|
});
|
|
@@ -11118,8 +11601,7 @@ Help:
|
|
|
11118
11601
|
k,
|
|
11119
11602
|
getRawGeneratorOptions(v, k)
|
|
11120
11603
|
]).filter(([_, v])=>void 0 !== v)),
|
|
11121
|
-
noParse: module.noParse
|
|
11122
|
-
unsafeCache: module.unsafeCache
|
|
11604
|
+
noParse: module.noParse
|
|
11123
11605
|
};
|
|
11124
11606
|
}(options.module, {
|
|
11125
11607
|
compiler: this,
|
|
@@ -11401,6 +11883,29 @@ Help:
|
|
|
11401
11883
|
return queried.promise(getCompiler().__internal__get_compilation().chunks, getCompiler().__internal__get_compilation().modules);
|
|
11402
11884
|
};
|
|
11403
11885
|
}),
|
|
11886
|
+
registerCompilationBeforeModuleIdsTaps: createTap(binding_default().RegisterJsTapKind.CompilationBeforeModuleIds, function() {
|
|
11887
|
+
return getCompiler().__internal__get_compilation().hooks.beforeModuleIds;
|
|
11888
|
+
}, function(queried) {
|
|
11889
|
+
return function(arg) {
|
|
11890
|
+
let compilation = getCompiler().__internal__get_compilation(), assignments = new Map(), modulesByIdentifier = new Map();
|
|
11891
|
+
for (let module of compilation.modules)modulesByIdentifier.set(module.identifier(), module);
|
|
11892
|
+
let proxiedModules = arg.modules.map((m)=>new Proxy(modulesByIdentifier.get(m.identifier), {
|
|
11893
|
+
get (target, prop) {
|
|
11894
|
+
if ('id' === prop) return assignments.get(m.identifier) ?? null;
|
|
11895
|
+
if ('identifier' === prop) return m.identifier;
|
|
11896
|
+
let value = Reflect.get(target, prop);
|
|
11897
|
+
return 'function' == typeof value ? value.bind(target) : value;
|
|
11898
|
+
},
|
|
11899
|
+
set: (_target, prop, value)=>'id' === prop && null !== value && (assignments.set(m.identifier, value), !0)
|
|
11900
|
+
}));
|
|
11901
|
+
return queried.call(proxiedModules), {
|
|
11902
|
+
assignments: Object.fromEntries(Array.from(assignments.entries()).map(([k, v])=>[
|
|
11903
|
+
k,
|
|
11904
|
+
String(v)
|
|
11905
|
+
]))
|
|
11906
|
+
};
|
|
11907
|
+
};
|
|
11908
|
+
}),
|
|
11404
11909
|
registerCompilationChunkHashTaps: createTap(binding_default().RegisterJsTapKind.CompilationChunkHash, function() {
|
|
11405
11910
|
return getCompiler().__internal__get_compilation().hooks.chunkHash;
|
|
11406
11911
|
}, function(queried) {
|
|
@@ -11943,68 +12448,7 @@ class LoaderTargetPlugin {
|
|
|
11943
12448
|
});
|
|
11944
12449
|
}
|
|
11945
12450
|
}
|
|
11946
|
-
let
|
|
11947
|
-
function isRequiredVersion(str) {
|
|
11948
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
11949
|
-
}
|
|
11950
|
-
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
11951
|
-
function isPlainObject(value) {
|
|
11952
|
-
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
11953
|
-
}
|
|
11954
|
-
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
11955
|
-
name = binding_namespaceObject.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
11956
|
-
opts;
|
|
11957
|
-
constructor(opts){
|
|
11958
|
-
super(), this.opts = opts;
|
|
11959
|
-
}
|
|
11960
|
-
raw(compiler) {
|
|
11961
|
-
var isDev;
|
|
11962
|
-
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
|
|
11963
|
-
if (!manifestOptions) return {
|
|
11964
|
-
statsFileName: STATS_FILE_NAME,
|
|
11965
|
-
manifestFileName: MANIFEST_FILE_NAME
|
|
11966
|
-
};
|
|
11967
|
-
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;
|
|
11968
|
-
return {
|
|
11969
|
-
statsFileName: join(filePath, fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME),
|
|
11970
|
-
manifestFileName: join(filePath, manifestFileName)
|
|
11971
|
-
};
|
|
11972
|
-
}(this.opts), rawOptions = {
|
|
11973
|
-
name: this.opts.name,
|
|
11974
|
-
globalName: this.opts.globalName,
|
|
11975
|
-
fileName,
|
|
11976
|
-
filePath,
|
|
11977
|
-
manifestFileName,
|
|
11978
|
-
statsFileName,
|
|
11979
|
-
disableAssetsAnalyze,
|
|
11980
|
-
remoteAliasMap,
|
|
11981
|
-
exposes,
|
|
11982
|
-
shared,
|
|
11983
|
-
buildInfo: (isDev = 'development' === compiler.options.mode, pkg = function(root) {
|
|
11984
|
-
let pkgPath = join(root ? external_node_path_resolve(root) : process.cwd(), 'package.json');
|
|
11985
|
-
try {
|
|
11986
|
-
let content = readFileSync(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
11987
|
-
try {
|
|
11988
|
-
let parsed = JSON.parse(input);
|
|
11989
|
-
if (guard(parsed)) return parsed;
|
|
11990
|
-
} catch {}
|
|
11991
|
-
}(content, isPlainObject);
|
|
11992
|
-
if (parsed) {
|
|
11993
|
-
let filtered = {};
|
|
11994
|
-
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
11995
|
-
if (Object.keys(filtered).length > 0) return filtered;
|
|
11996
|
-
}
|
|
11997
|
-
} catch {}
|
|
11998
|
-
return {};
|
|
11999
|
-
}(compiler.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, {
|
|
12000
|
-
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
12001
|
-
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
12002
|
-
})
|
|
12003
|
-
};
|
|
12004
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
12005
|
-
}
|
|
12006
|
-
}
|
|
12007
|
-
let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
12451
|
+
let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
12008
12452
|
let items = [];
|
|
12009
12453
|
var fn = (key, value)=>{
|
|
12010
12454
|
items.push([
|
|
@@ -12021,63 +12465,7 @@ let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinP
|
|
|
12021
12465
|
else if ('object' == typeof options) object(options);
|
|
12022
12466
|
else throw Error('Unexpected options format');
|
|
12023
12467
|
return items;
|
|
12024
|
-
},
|
|
12025
|
-
function getRemoteInfos(options) {
|
|
12026
|
-
if (!options.remotes) return {};
|
|
12027
|
-
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
12028
|
-
external: Array.isArray(item) ? item : [
|
|
12029
|
-
item
|
|
12030
|
-
],
|
|
12031
|
-
shareScope: options.shareScope || 'default'
|
|
12032
|
-
}), (item)=>({
|
|
12033
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
12034
|
-
item.external
|
|
12035
|
-
],
|
|
12036
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
12037
|
-
})), remoteInfos = {};
|
|
12038
|
-
for (let [key, config] of remotes)for (let external of config.external){
|
|
12039
|
-
let [externalType, externalRequest] = function(external) {
|
|
12040
|
-
let result = function(external) {
|
|
12041
|
-
if (/^[a-z0-9-]+ /.test(external)) {
|
|
12042
|
-
let idx = external.indexOf(' ');
|
|
12043
|
-
return [
|
|
12044
|
-
external.slice(0, idx),
|
|
12045
|
-
external.slice(idx + 1)
|
|
12046
|
-
];
|
|
12047
|
-
}
|
|
12048
|
-
return null;
|
|
12049
|
-
}(external);
|
|
12050
|
-
return null === result ? [
|
|
12051
|
-
remoteType,
|
|
12052
|
-
external
|
|
12053
|
-
] : result;
|
|
12054
|
-
}(external);
|
|
12055
|
-
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
12056
|
-
let [url, global] = function(urlAndGlobal) {
|
|
12057
|
-
let index = urlAndGlobal.indexOf('@');
|
|
12058
|
-
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
12059
|
-
urlAndGlobal.substring(index + 1),
|
|
12060
|
-
urlAndGlobal.substring(0, index)
|
|
12061
|
-
];
|
|
12062
|
-
}(externalRequest);
|
|
12063
|
-
remoteInfos[key].push({
|
|
12064
|
-
alias: key,
|
|
12065
|
-
name: global,
|
|
12066
|
-
entry: url,
|
|
12067
|
-
externalType,
|
|
12068
|
-
shareScope: config.shareScope
|
|
12069
|
-
});
|
|
12070
|
-
} else remoteInfos[key].push({
|
|
12071
|
-
alias: key,
|
|
12072
|
-
name: void 0,
|
|
12073
|
-
entry: void 0,
|
|
12074
|
-
externalType,
|
|
12075
|
-
shareScope: config.shareScope
|
|
12076
|
-
});
|
|
12077
|
-
}
|
|
12078
|
-
return remoteInfos;
|
|
12079
|
-
}
|
|
12080
|
-
let compilerSet = new WeakSet();
|
|
12468
|
+
}, compilerSet = new WeakSet();
|
|
12081
12469
|
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
12082
12470
|
enhanced;
|
|
12083
12471
|
name = binding_namespaceObject.BuiltinPluginName.ShareRuntimePlugin;
|
|
@@ -12088,42 +12476,55 @@ class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
|
12088
12476
|
if (!compilerSet.has(compiler)) return compilerSet.add(compiler), createBuiltinPlugin(this.name, this.enhanced);
|
|
12089
12477
|
}
|
|
12090
12478
|
}
|
|
12479
|
+
let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
12480
|
+
function isRequiredVersion(str) {
|
|
12481
|
+
return VERSION_PATTERN_REGEXP.test(str);
|
|
12482
|
+
}
|
|
12483
|
+
let encodeName = function(name, prefix = '', withExt = !1) {
|
|
12484
|
+
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${withExt ? '.js' : ''}`;
|
|
12485
|
+
};
|
|
12486
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
12487
|
+
return parseOptions(consumes, (item, key)=>{
|
|
12488
|
+
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
12489
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12490
|
+
import: key,
|
|
12491
|
+
shareScope: shareScope || 'default',
|
|
12492
|
+
shareKey: key,
|
|
12493
|
+
requiredVersion: item,
|
|
12494
|
+
strictVersion: !0,
|
|
12495
|
+
packageName: void 0,
|
|
12496
|
+
singleton: !1,
|
|
12497
|
+
eager: !1,
|
|
12498
|
+
treeShakingMode: void 0
|
|
12499
|
+
} : {
|
|
12500
|
+
import: key,
|
|
12501
|
+
shareScope: shareScope || 'default',
|
|
12502
|
+
shareKey: key,
|
|
12503
|
+
requiredVersion: void 0,
|
|
12504
|
+
packageName: void 0,
|
|
12505
|
+
strictVersion: !1,
|
|
12506
|
+
singleton: !1,
|
|
12507
|
+
eager: !1,
|
|
12508
|
+
treeShakingMode: void 0
|
|
12509
|
+
};
|
|
12510
|
+
}, (item, key)=>({
|
|
12511
|
+
import: !1 === item.import ? void 0 : item.import || key,
|
|
12512
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
12513
|
+
shareKey: item.shareKey || key,
|
|
12514
|
+
requiredVersion: item.requiredVersion,
|
|
12515
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12516
|
+
packageName: item.packageName,
|
|
12517
|
+
singleton: !!item.singleton,
|
|
12518
|
+
eager: !!item.eager,
|
|
12519
|
+
treeShakingMode: item.treeShakingMode
|
|
12520
|
+
}));
|
|
12521
|
+
}
|
|
12091
12522
|
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
12092
12523
|
name = binding_namespaceObject.BuiltinPluginName.ConsumeSharedPlugin;
|
|
12093
12524
|
_options;
|
|
12094
12525
|
constructor(options){
|
|
12095
12526
|
super(), this._options = {
|
|
12096
|
-
consumes:
|
|
12097
|
-
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
12098
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12099
|
-
import: key,
|
|
12100
|
-
shareScope: options.shareScope || 'default',
|
|
12101
|
-
shareKey: key,
|
|
12102
|
-
requiredVersion: item,
|
|
12103
|
-
strictVersion: !0,
|
|
12104
|
-
packageName: void 0,
|
|
12105
|
-
singleton: !1,
|
|
12106
|
-
eager: !1
|
|
12107
|
-
} : {
|
|
12108
|
-
import: key,
|
|
12109
|
-
shareScope: options.shareScope || 'default',
|
|
12110
|
-
shareKey: key,
|
|
12111
|
-
requiredVersion: void 0,
|
|
12112
|
-
packageName: void 0,
|
|
12113
|
-
strictVersion: !1,
|
|
12114
|
-
singleton: !1,
|
|
12115
|
-
eager: !1
|
|
12116
|
-
};
|
|
12117
|
-
}, (item, key)=>({
|
|
12118
|
-
import: !1 === item.import ? void 0 : item.import || key,
|
|
12119
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
12120
|
-
shareKey: item.shareKey || key,
|
|
12121
|
-
requiredVersion: item.requiredVersion,
|
|
12122
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12123
|
-
packageName: item.packageName,
|
|
12124
|
-
singleton: !!item.singleton,
|
|
12125
|
-
eager: !!item.eager
|
|
12126
|
-
})),
|
|
12527
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
12127
12528
|
enhanced: options.enhanced ?? !1
|
|
12128
12529
|
};
|
|
12129
12530
|
}
|
|
@@ -12144,28 +12545,30 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
12144
12545
|
_provides;
|
|
12145
12546
|
_enhanced;
|
|
12146
12547
|
constructor(options){
|
|
12147
|
-
|
|
12548
|
+
var options1, shareScope, enhanced;
|
|
12549
|
+
super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
|
|
12148
12550
|
if (Array.isArray(item)) throw Error('Unexpected array of provides');
|
|
12149
12551
|
return {
|
|
12150
12552
|
shareKey: item,
|
|
12151
12553
|
version: void 0,
|
|
12152
|
-
shareScope:
|
|
12554
|
+
shareScope: shareScope || 'default',
|
|
12153
12555
|
eager: !1
|
|
12154
12556
|
};
|
|
12155
12557
|
}, (item)=>{
|
|
12156
12558
|
let raw = {
|
|
12157
12559
|
shareKey: item.shareKey,
|
|
12158
12560
|
version: item.version,
|
|
12159
|
-
shareScope: item.shareScope ||
|
|
12561
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
12160
12562
|
eager: !!item.eager
|
|
12161
12563
|
};
|
|
12162
|
-
return
|
|
12564
|
+
return enhanced ? {
|
|
12163
12565
|
...raw,
|
|
12164
12566
|
singleton: item.singleton,
|
|
12165
12567
|
requiredVersion: item.requiredVersion,
|
|
12166
|
-
strictVersion: item.strictVersion
|
|
12568
|
+
strictVersion: item.strictVersion,
|
|
12569
|
+
treeShakingMode: item.treeShakingMode
|
|
12167
12570
|
} : raw;
|
|
12168
|
-
}), this._enhanced = options.enhanced;
|
|
12571
|
+
})), this._enhanced = options.enhanced;
|
|
12169
12572
|
}
|
|
12170
12573
|
raw(compiler) {
|
|
12171
12574
|
new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
|
|
@@ -12176,32 +12579,40 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
12176
12579
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
12177
12580
|
}
|
|
12178
12581
|
}
|
|
12582
|
+
function normalizeSharedOptions(shared) {
|
|
12583
|
+
return parseOptions(shared, (item, key)=>{
|
|
12584
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12585
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12586
|
+
import: key,
|
|
12587
|
+
requiredVersion: item
|
|
12588
|
+
} : {
|
|
12589
|
+
import: item
|
|
12590
|
+
};
|
|
12591
|
+
}, (item)=>item);
|
|
12592
|
+
}
|
|
12593
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
12594
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
12595
|
+
[key]: {
|
|
12596
|
+
import: options.import,
|
|
12597
|
+
shareKey: options.shareKey || key,
|
|
12598
|
+
shareScope: options.shareScope,
|
|
12599
|
+
requiredVersion: options.requiredVersion,
|
|
12600
|
+
strictVersion: options.strictVersion,
|
|
12601
|
+
singleton: options.singleton,
|
|
12602
|
+
packageName: options.packageName,
|
|
12603
|
+
eager: options.eager,
|
|
12604
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12605
|
+
}
|
|
12606
|
+
}));
|
|
12607
|
+
}
|
|
12179
12608
|
class SharePlugin {
|
|
12180
12609
|
_shareScope;
|
|
12181
12610
|
_consumes;
|
|
12182
12611
|
_provides;
|
|
12183
12612
|
_enhanced;
|
|
12613
|
+
_sharedOptions;
|
|
12184
12614
|
constructor(options){
|
|
12185
|
-
let sharedOptions =
|
|
12186
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12187
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12188
|
-
import: key,
|
|
12189
|
-
requiredVersion: item
|
|
12190
|
-
} : {
|
|
12191
|
-
import: item
|
|
12192
|
-
};
|
|
12193
|
-
}, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
|
|
12194
|
-
[key]: {
|
|
12195
|
-
import: options.import,
|
|
12196
|
-
shareKey: options.shareKey || key,
|
|
12197
|
-
shareScope: options.shareScope,
|
|
12198
|
-
requiredVersion: options.requiredVersion,
|
|
12199
|
-
strictVersion: options.strictVersion,
|
|
12200
|
-
singleton: options.singleton,
|
|
12201
|
-
packageName: options.packageName,
|
|
12202
|
-
eager: options.eager
|
|
12203
|
-
}
|
|
12204
|
-
})), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12615
|
+
let sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12205
12616
|
[options.import || key]: {
|
|
12206
12617
|
shareKey: options.shareKey || key,
|
|
12207
12618
|
shareScope: options.shareScope,
|
|
@@ -12209,10 +12620,11 @@ class SharePlugin {
|
|
|
12209
12620
|
eager: options.eager,
|
|
12210
12621
|
singleton: options.singleton,
|
|
12211
12622
|
requiredVersion: options.requiredVersion,
|
|
12212
|
-
strictVersion: options.strictVersion
|
|
12623
|
+
strictVersion: options.strictVersion,
|
|
12624
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12213
12625
|
}
|
|
12214
12626
|
}));
|
|
12215
|
-
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
|
|
12627
|
+
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
|
|
12216
12628
|
}
|
|
12217
12629
|
apply(compiler) {
|
|
12218
12630
|
new ConsumeSharedPlugin({
|
|
@@ -12226,6 +12638,555 @@ class SharePlugin {
|
|
|
12226
12638
|
}).apply(compiler);
|
|
12227
12639
|
}
|
|
12228
12640
|
}
|
|
12641
|
+
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
12642
|
+
function isPlainObject(value) {
|
|
12643
|
+
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
12644
|
+
}
|
|
12645
|
+
function getFileName(manifestOptions) {
|
|
12646
|
+
if (!manifestOptions) return {
|
|
12647
|
+
statsFileName: '',
|
|
12648
|
+
manifestFileName: ''
|
|
12649
|
+
};
|
|
12650
|
+
if ('boolean' == typeof manifestOptions) return {
|
|
12651
|
+
statsFileName: STATS_FILE_NAME,
|
|
12652
|
+
manifestFileName: MANIFEST_FILE_NAME
|
|
12653
|
+
};
|
|
12654
|
+
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;
|
|
12655
|
+
return {
|
|
12656
|
+
statsFileName: join(filePath, fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME),
|
|
12657
|
+
manifestFileName: join(filePath, manifestFileName)
|
|
12658
|
+
};
|
|
12659
|
+
}
|
|
12660
|
+
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
12661
|
+
name = binding_namespaceObject.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
12662
|
+
rawOpts;
|
|
12663
|
+
constructor(opts){
|
|
12664
|
+
super(), this.rawOpts = opts;
|
|
12665
|
+
}
|
|
12666
|
+
raw(compiler) {
|
|
12667
|
+
var mfConfig, isDev, mfConfig1;
|
|
12668
|
+
let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared, pkg, buildVersion, statsBuildInfo, opts = (manifestOptions = !0 === (mfConfig = this.rawOpts).manifest ? {} : {
|
|
12669
|
+
...mfConfig.manifest
|
|
12670
|
+
}, containerName = mfConfig.name, globalName = function(library) {
|
|
12671
|
+
if (!library) return;
|
|
12672
|
+
let libName = library.name;
|
|
12673
|
+
if (libName) {
|
|
12674
|
+
if ('string' == typeof libName) return libName;
|
|
12675
|
+
if (Array.isArray(libName)) return libName[0];
|
|
12676
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12677
|
+
}
|
|
12678
|
+
}(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
12679
|
+
if (cur[1].length > 1) return sum;
|
|
12680
|
+
let { entry, alias, name } = cur[1][0];
|
|
12681
|
+
return entry && name && (sum[alias] = {
|
|
12682
|
+
name,
|
|
12683
|
+
entry
|
|
12684
|
+
}), sum;
|
|
12685
|
+
}, {}), manifestExposes = function(exposes) {
|
|
12686
|
+
if (!exposes) return;
|
|
12687
|
+
let result = parseOptions(exposes, (value)=>({
|
|
12688
|
+
import: Array.isArray(value) ? value : [
|
|
12689
|
+
value
|
|
12690
|
+
],
|
|
12691
|
+
name: void 0
|
|
12692
|
+
}), (value)=>({
|
|
12693
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
12694
|
+
value.import
|
|
12695
|
+
],
|
|
12696
|
+
name: value.name ?? void 0
|
|
12697
|
+
})).map(([exposeKey, info])=>{
|
|
12698
|
+
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12699
|
+
return {
|
|
12700
|
+
path: exposeKey,
|
|
12701
|
+
name: exposeName
|
|
12702
|
+
};
|
|
12703
|
+
});
|
|
12704
|
+
return result.length > 0 ? result : void 0;
|
|
12705
|
+
}(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
|
|
12706
|
+
if (!shared) return;
|
|
12707
|
+
let result = parseOptions(shared, (item, key)=>{
|
|
12708
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12709
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12710
|
+
import: key,
|
|
12711
|
+
requiredVersion: item
|
|
12712
|
+
} : {
|
|
12713
|
+
import: item
|
|
12714
|
+
};
|
|
12715
|
+
}, (item)=>item).map(([key, config])=>{
|
|
12716
|
+
let name = config.shareKey || key;
|
|
12717
|
+
return {
|
|
12718
|
+
name,
|
|
12719
|
+
version: 'string' == typeof config.version ? config.version : void 0,
|
|
12720
|
+
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12721
|
+
singleton: config.singleton
|
|
12722
|
+
};
|
|
12723
|
+
});
|
|
12724
|
+
return result.length > 0 ? result : void 0;
|
|
12725
|
+
}(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
|
|
12726
|
+
...manifestOptions,
|
|
12727
|
+
remoteAliasMap,
|
|
12728
|
+
globalName,
|
|
12729
|
+
name: containerName
|
|
12730
|
+
}), { fileName, filePath, disableAssetsAnalyze, remoteAliasMap: remoteAliasMap1, exposes, shared } = opts, { statsFileName, manifestFileName } = getFileName(opts), rawOptions = {
|
|
12731
|
+
name: opts.name,
|
|
12732
|
+
globalName: opts.globalName,
|
|
12733
|
+
fileName,
|
|
12734
|
+
filePath,
|
|
12735
|
+
manifestFileName,
|
|
12736
|
+
statsFileName,
|
|
12737
|
+
disableAssetsAnalyze,
|
|
12738
|
+
remoteAliasMap: remoteAliasMap1,
|
|
12739
|
+
exposes,
|
|
12740
|
+
shared,
|
|
12741
|
+
buildInfo: (isDev = 'development' === compiler.options.mode, mfConfig1 = this.rawOpts, pkg = function(root) {
|
|
12742
|
+
let pkgPath = join(root ? external_node_path_resolve(root) : process.cwd(), 'package.json');
|
|
12743
|
+
try {
|
|
12744
|
+
let content = readFileSync(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
12745
|
+
try {
|
|
12746
|
+
let parsed = JSON.parse(input);
|
|
12747
|
+
if (guard(parsed)) return parsed;
|
|
12748
|
+
} catch {}
|
|
12749
|
+
}(content, isPlainObject);
|
|
12750
|
+
if (parsed) {
|
|
12751
|
+
let filtered = {};
|
|
12752
|
+
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
12753
|
+
if (Object.keys(filtered).length > 0) return filtered;
|
|
12754
|
+
}
|
|
12755
|
+
} catch {}
|
|
12756
|
+
return {};
|
|
12757
|
+
}(compiler.options.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, statsBuildInfo = {
|
|
12758
|
+
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
12759
|
+
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
12760
|
+
}, 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)
|
|
12761
|
+
};
|
|
12762
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12763
|
+
}
|
|
12764
|
+
}
|
|
12765
|
+
let SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
12766
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
12767
|
+
name = binding_namespaceObject.BuiltinPluginName.CollectSharedEntryPlugin;
|
|
12768
|
+
sharedOptions;
|
|
12769
|
+
_collectedEntries;
|
|
12770
|
+
constructor(options){
|
|
12771
|
+
super();
|
|
12772
|
+
let { sharedOptions } = options;
|
|
12773
|
+
this.sharedOptions = sharedOptions, this._collectedEntries = {};
|
|
12774
|
+
}
|
|
12775
|
+
getData() {
|
|
12776
|
+
return this._collectedEntries;
|
|
12777
|
+
}
|
|
12778
|
+
getFilename() {
|
|
12779
|
+
return SHARE_ENTRY_ASSET;
|
|
12780
|
+
}
|
|
12781
|
+
apply(compiler) {
|
|
12782
|
+
super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
12783
|
+
compilation.hooks.processAssets.tap({
|
|
12784
|
+
name: 'CollectSharedEntry',
|
|
12785
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
12786
|
+
}, ()=>{
|
|
12787
|
+
compilation.getAssets().forEach((asset)=>{
|
|
12788
|
+
asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
|
|
12789
|
+
});
|
|
12790
|
+
});
|
|
12791
|
+
});
|
|
12792
|
+
}
|
|
12793
|
+
raw() {
|
|
12794
|
+
let rawOptions = {
|
|
12795
|
+
consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
|
|
12796
|
+
key,
|
|
12797
|
+
...v
|
|
12798
|
+
})),
|
|
12799
|
+
filename: this.getFilename()
|
|
12800
|
+
};
|
|
12801
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12802
|
+
}
|
|
12803
|
+
}
|
|
12804
|
+
function assert(condition, msg) {
|
|
12805
|
+
if (!condition) throw Error(msg);
|
|
12806
|
+
}
|
|
12807
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
12808
|
+
name = binding_namespaceObject.BuiltinPluginName.SharedContainerPlugin;
|
|
12809
|
+
filename = '';
|
|
12810
|
+
_options;
|
|
12811
|
+
_shareName;
|
|
12812
|
+
_globalName;
|
|
12813
|
+
constructor(options){
|
|
12814
|
+
super();
|
|
12815
|
+
let { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || '0.0.0';
|
|
12816
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
12817
|
+
let fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
12818
|
+
this._shareName = shareName, this._options = {
|
|
12819
|
+
name: shareName,
|
|
12820
|
+
request: request,
|
|
12821
|
+
library: (library ? {
|
|
12822
|
+
...library,
|
|
12823
|
+
name: this._globalName
|
|
12824
|
+
} : void 0) || {
|
|
12825
|
+
type: 'global',
|
|
12826
|
+
name: this._globalName
|
|
12827
|
+
},
|
|
12828
|
+
version,
|
|
12829
|
+
fileName
|
|
12830
|
+
};
|
|
12831
|
+
}
|
|
12832
|
+
getData() {
|
|
12833
|
+
return [
|
|
12834
|
+
this._options.fileName,
|
|
12835
|
+
this._globalName,
|
|
12836
|
+
this._options.version
|
|
12837
|
+
];
|
|
12838
|
+
}
|
|
12839
|
+
raw(compiler) {
|
|
12840
|
+
let { library } = this._options;
|
|
12841
|
+
return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
|
|
12842
|
+
}
|
|
12843
|
+
apply(compiler) {
|
|
12844
|
+
super.apply(compiler);
|
|
12845
|
+
let shareName = this._shareName;
|
|
12846
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
12847
|
+
compilation.hooks.processAssets.tap({
|
|
12848
|
+
name: 'getShareContainerFile'
|
|
12849
|
+
}, ()=>{
|
|
12850
|
+
assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
|
|
12851
|
+
let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
12852
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
12853
|
+
let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes('.hot-update') && !f.endsWith('.css'));
|
|
12854
|
+
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];
|
|
12855
|
+
});
|
|
12856
|
+
});
|
|
12857
|
+
}
|
|
12858
|
+
}
|
|
12859
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
12860
|
+
name = binding_namespaceObject.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
|
|
12861
|
+
sharedOptions;
|
|
12862
|
+
injectTreeShakingUsedExports;
|
|
12863
|
+
manifestOptions;
|
|
12864
|
+
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
12865
|
+
super(), this.sharedOptions = sharedOptions, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
|
|
12866
|
+
}
|
|
12867
|
+
buildOptions() {
|
|
12868
|
+
let shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
12869
|
+
shareKey,
|
|
12870
|
+
treeShaking: !!config.treeShaking,
|
|
12871
|
+
usedExports: config.treeShaking?.usedExports
|
|
12872
|
+
})), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
12873
|
+
return {
|
|
12874
|
+
shared,
|
|
12875
|
+
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
12876
|
+
manifestFileName,
|
|
12877
|
+
statsFileName
|
|
12878
|
+
};
|
|
12879
|
+
}
|
|
12880
|
+
raw() {
|
|
12881
|
+
if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
|
|
12882
|
+
}
|
|
12883
|
+
}
|
|
12884
|
+
let VIRTUAL_ENTRY = './virtual-entry.js', VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
12885
|
+
class VirtualEntryPlugin {
|
|
12886
|
+
sharedOptions;
|
|
12887
|
+
collectShared = !1;
|
|
12888
|
+
constructor(sharedOptions, collectShared){
|
|
12889
|
+
this.sharedOptions = sharedOptions, this.collectShared = collectShared;
|
|
12890
|
+
}
|
|
12891
|
+
createEntry() {
|
|
12892
|
+
let { sharedOptions, collectShared } = this;
|
|
12893
|
+
return sharedOptions.reduce((acc, cur, index)=>acc + `import shared_${index} from '${cur[0]}';\n` + (collectShared ? `console.log(shared_${index});\n` : ''), '');
|
|
12894
|
+
}
|
|
12895
|
+
static entry() {
|
|
12896
|
+
return {
|
|
12897
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
12898
|
+
};
|
|
12899
|
+
}
|
|
12900
|
+
apply(compiler) {
|
|
12901
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
12902
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
12903
|
+
}).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
12904
|
+
compilation.hooks.processAssets.tap({
|
|
12905
|
+
name: 'RemoveVirtualEntryAsset',
|
|
12906
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12907
|
+
}, ()=>{
|
|
12908
|
+
try {
|
|
12909
|
+
let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
12910
|
+
chunk?.files.forEach((f)=>{
|
|
12911
|
+
compilation.deleteAsset(f);
|
|
12912
|
+
});
|
|
12913
|
+
} catch (_e) {
|
|
12914
|
+
console.error('Failed to remove virtual entry file!');
|
|
12915
|
+
}
|
|
12916
|
+
});
|
|
12917
|
+
});
|
|
12918
|
+
}
|
|
12919
|
+
}
|
|
12920
|
+
let resolveOutputDir = (outputDir, shareName)=>shareName ? join(outputDir, encodeName(shareName)) : outputDir;
|
|
12921
|
+
class IndependentSharedPlugin {
|
|
12922
|
+
mfName;
|
|
12923
|
+
shared;
|
|
12924
|
+
library;
|
|
12925
|
+
sharedOptions;
|
|
12926
|
+
outputDir;
|
|
12927
|
+
plugins;
|
|
12928
|
+
treeShaking;
|
|
12929
|
+
manifest;
|
|
12930
|
+
buildAssets = {};
|
|
12931
|
+
injectTreeShakingUsedExports;
|
|
12932
|
+
treeShakingSharedExcludePlugins;
|
|
12933
|
+
name = 'IndependentSharedPlugin';
|
|
12934
|
+
constructor(options){
|
|
12935
|
+
let { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
12936
|
+
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)=>{
|
|
12937
|
+
if ('string' != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
12938
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12939
|
+
import: key,
|
|
12940
|
+
requiredVersion: item
|
|
12941
|
+
} : {
|
|
12942
|
+
import: item
|
|
12943
|
+
};
|
|
12944
|
+
}, (item)=>item);
|
|
12945
|
+
}
|
|
12946
|
+
apply(compiler) {
|
|
12947
|
+
let { manifest } = this, runCount = 0;
|
|
12948
|
+
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12949
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12950
|
+
}), compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12951
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12952
|
+
}), manifest && compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
12953
|
+
compilation.hooks.processAssets.tap({
|
|
12954
|
+
name: 'injectBuildAssets',
|
|
12955
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
12956
|
+
}, ()=>{
|
|
12957
|
+
let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
12958
|
+
let stats = compilation.getAsset(filename);
|
|
12959
|
+
if (!stats) return;
|
|
12960
|
+
let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
|
|
12961
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
12962
|
+
let targetShared = shared.find((s)=>s.name === key);
|
|
12963
|
+
targetShared && item.forEach(([entry, version, globalName])=>{
|
|
12964
|
+
version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
|
|
12965
|
+
});
|
|
12966
|
+
}), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
12967
|
+
};
|
|
12968
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
12969
|
+
});
|
|
12970
|
+
});
|
|
12971
|
+
}
|
|
12972
|
+
async createIndependentCompilers(parentCompiler) {
|
|
12973
|
+
let { sharedOptions, buildAssets, outputDir } = this;
|
|
12974
|
+
console.log('Start building shared fallback resources ...');
|
|
12975
|
+
let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
12976
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
12977
|
+
if (!shareConfig.treeShaking || !1 === shareConfig.import) return;
|
|
12978
|
+
let shareRequests = shareRequestsMap[shareName].requests;
|
|
12979
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
12980
|
+
let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
12981
|
+
shareRequestsMap,
|
|
12982
|
+
currentShare: {
|
|
12983
|
+
shareName,
|
|
12984
|
+
version,
|
|
12985
|
+
request,
|
|
12986
|
+
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
12987
|
+
}
|
|
12988
|
+
});
|
|
12989
|
+
'string' == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
|
|
12990
|
+
join(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
12991
|
+
sharedVersion,
|
|
12992
|
+
globalName
|
|
12993
|
+
]));
|
|
12994
|
+
}));
|
|
12995
|
+
})), console.log('All shared fallback have been compiled successfully!');
|
|
12996
|
+
}
|
|
12997
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
12998
|
+
let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ''), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
|
|
12999
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
13000
|
+
mfName: `${mfName}_${treeShaking ? 't' : 'f'}`,
|
|
13001
|
+
library,
|
|
13002
|
+
...extraOptions.currentShare
|
|
13003
|
+
}) : new CollectSharedEntryPlugin({
|
|
13004
|
+
sharedOptions,
|
|
13005
|
+
shareScope: 'default'
|
|
13006
|
+
}), (parentConfig.plugins || []).forEach((plugin)=>{
|
|
13007
|
+
void 0 !== plugin && 'string' != typeof plugin && ((plugin, excludedPlugins = [])=>{
|
|
13008
|
+
if (!plugin) return !0;
|
|
13009
|
+
let pluginName = plugin.name || plugin.constructor?.name;
|
|
13010
|
+
return !pluginName || ![
|
|
13011
|
+
'TreeShakingSharedPlugin',
|
|
13012
|
+
'IndependentSharedPlugin',
|
|
13013
|
+
'ModuleFederationPlugin',
|
|
13014
|
+
'SharedUsedExportsOptimizerPlugin',
|
|
13015
|
+
'HtmlWebpackPlugin',
|
|
13016
|
+
'HtmlRspackPlugin',
|
|
13017
|
+
'RsbuildHtmlPlugin',
|
|
13018
|
+
...excludedPlugins
|
|
13019
|
+
].includes(pluginName);
|
|
13020
|
+
})(plugin, treeShakingSharedExcludePlugins) && finalPlugins.push(plugin);
|
|
13021
|
+
}), plugins.forEach((plugin)=>{
|
|
13022
|
+
finalPlugins.push(plugin);
|
|
13023
|
+
}), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
|
|
13024
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
13025
|
+
[key]: {
|
|
13026
|
+
import: !extraOptions && options.import,
|
|
13027
|
+
shareKey: options.shareKey || key,
|
|
13028
|
+
shareScope: options.shareScope,
|
|
13029
|
+
requiredVersion: options.requiredVersion,
|
|
13030
|
+
strictVersion: options.strictVersion,
|
|
13031
|
+
singleton: options.singleton,
|
|
13032
|
+
packageName: options.packageName,
|
|
13033
|
+
eager: options.eager
|
|
13034
|
+
}
|
|
13035
|
+
})),
|
|
13036
|
+
enhanced: !0
|
|
13037
|
+
})), treeShaking && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
13038
|
+
let fullOutputDir = external_node_path_resolve(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
|
|
13039
|
+
...parentConfig,
|
|
13040
|
+
module: {
|
|
13041
|
+
...parentConfig.module,
|
|
13042
|
+
rules: [
|
|
13043
|
+
{
|
|
13044
|
+
test: /virtual-entry\.js$/,
|
|
13045
|
+
type: "javascript/auto",
|
|
13046
|
+
resolve: {
|
|
13047
|
+
fullySpecified: !1
|
|
13048
|
+
},
|
|
13049
|
+
use: {
|
|
13050
|
+
loader: 'builtin:swc-loader'
|
|
13051
|
+
}
|
|
13052
|
+
},
|
|
13053
|
+
...parentConfig.module?.rules || []
|
|
13054
|
+
]
|
|
13055
|
+
},
|
|
13056
|
+
mode: parentConfig.mode || 'development',
|
|
13057
|
+
entry: VirtualEntryPlugin.entry,
|
|
13058
|
+
output: {
|
|
13059
|
+
path: fullOutputDir,
|
|
13060
|
+
clean: !0,
|
|
13061
|
+
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
13062
|
+
},
|
|
13063
|
+
plugins: finalPlugins,
|
|
13064
|
+
optimization: {
|
|
13065
|
+
...parentConfig.optimization,
|
|
13066
|
+
splitChunks: !1
|
|
13067
|
+
}
|
|
13068
|
+
}, compiler = rspack.rspack(compilerConfig);
|
|
13069
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
13070
|
+
let { currentShare } = extraOptions || {};
|
|
13071
|
+
return new Promise((resolve, reject)=>{
|
|
13072
|
+
compiler.run((err, stats)=>{
|
|
13073
|
+
if (err || stats?.hasErrors()) {
|
|
13074
|
+
let target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
13075
|
+
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n')), reject(err || Error(`${target} Compile failed`));
|
|
13076
|
+
return;
|
|
13077
|
+
}
|
|
13078
|
+
currentShare && console.log(`${currentShare.shareName} Compile success`), resolve(extraPlugin.getData());
|
|
13079
|
+
});
|
|
13080
|
+
});
|
|
13081
|
+
}
|
|
13082
|
+
}
|
|
13083
|
+
let TreeShakingSharedPlugin_require = createRequire(import.meta.url);
|
|
13084
|
+
class TreeShakingSharedPlugin {
|
|
13085
|
+
mfConfig;
|
|
13086
|
+
outputDir;
|
|
13087
|
+
secondary;
|
|
13088
|
+
_independentSharePlugin;
|
|
13089
|
+
name = 'TreeShakingSharedPlugin';
|
|
13090
|
+
constructor(options){
|
|
13091
|
+
let { mfConfig, secondary } = options;
|
|
13092
|
+
this.mfConfig = mfConfig, this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages', this.secondary = !!secondary;
|
|
13093
|
+
}
|
|
13094
|
+
apply(compiler) {
|
|
13095
|
+
let { mfConfig, outputDir, secondary } = this, { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
13096
|
+
if (!shared) return;
|
|
13097
|
+
let sharedOptions = normalizeSharedOptions(shared);
|
|
13098
|
+
sharedOptions.length && sharedOptions.some(([_, config])=>config.treeShaking && !1 !== config.import) && (secondary || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
|
|
13099
|
+
name: name,
|
|
13100
|
+
shared: shared,
|
|
13101
|
+
outputDir,
|
|
13102
|
+
plugins: treeShakingSharedPlugins?.map((p)=>new (TreeShakingSharedPlugin_require(p))()) || [],
|
|
13103
|
+
treeShaking: secondary,
|
|
13104
|
+
library,
|
|
13105
|
+
manifest: mfConfig.manifest,
|
|
13106
|
+
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
13107
|
+
}), this._independentSharePlugin.apply(compiler));
|
|
13108
|
+
}
|
|
13109
|
+
get buildAssets() {
|
|
13110
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
13111
|
+
}
|
|
13112
|
+
}
|
|
13113
|
+
let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), ModuleFederationPlugin_require = createRequire(import.meta.url);
|
|
13114
|
+
function getRemoteInfos(options) {
|
|
13115
|
+
if (!options.remotes) return {};
|
|
13116
|
+
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
13117
|
+
external: Array.isArray(item) ? item : [
|
|
13118
|
+
item
|
|
13119
|
+
],
|
|
13120
|
+
shareScope: options.shareScope || 'default'
|
|
13121
|
+
}), (item)=>({
|
|
13122
|
+
external: Array.isArray(item.external) ? item.external : [
|
|
13123
|
+
item.external
|
|
13124
|
+
],
|
|
13125
|
+
shareScope: item.shareScope || options.shareScope || 'default'
|
|
13126
|
+
})), remoteInfos = {};
|
|
13127
|
+
for (let [key, config] of remotes)for (let external of config.external){
|
|
13128
|
+
let [externalType, externalRequest] = function(external) {
|
|
13129
|
+
let result = function(external) {
|
|
13130
|
+
if (/^[a-z0-9-]+ /.test(external)) {
|
|
13131
|
+
let idx = external.indexOf(' ');
|
|
13132
|
+
return [
|
|
13133
|
+
external.slice(0, idx),
|
|
13134
|
+
external.slice(idx + 1)
|
|
13135
|
+
];
|
|
13136
|
+
}
|
|
13137
|
+
return null;
|
|
13138
|
+
}(external);
|
|
13139
|
+
return null === result ? [
|
|
13140
|
+
remoteType,
|
|
13141
|
+
external
|
|
13142
|
+
] : result;
|
|
13143
|
+
}(external);
|
|
13144
|
+
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
13145
|
+
let [url, global] = function(urlAndGlobal) {
|
|
13146
|
+
let index = urlAndGlobal.indexOf('@');
|
|
13147
|
+
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
13148
|
+
urlAndGlobal.substring(index + 1),
|
|
13149
|
+
urlAndGlobal.substring(0, index)
|
|
13150
|
+
];
|
|
13151
|
+
}(externalRequest);
|
|
13152
|
+
remoteInfos[key].push({
|
|
13153
|
+
alias: key,
|
|
13154
|
+
name: global,
|
|
13155
|
+
entry: url,
|
|
13156
|
+
externalType,
|
|
13157
|
+
shareScope: config.shareScope
|
|
13158
|
+
});
|
|
13159
|
+
} else remoteInfos[key].push({
|
|
13160
|
+
alias: key,
|
|
13161
|
+
name: void 0,
|
|
13162
|
+
entry: void 0,
|
|
13163
|
+
externalType,
|
|
13164
|
+
shareScope: config.shareScope
|
|
13165
|
+
});
|
|
13166
|
+
}
|
|
13167
|
+
return remoteInfos;
|
|
13168
|
+
}
|
|
13169
|
+
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
13170
|
+
let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || 'var';
|
|
13171
|
+
for(let i = 0; i < runtimePlugins.length; i++){
|
|
13172
|
+
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;
|
|
13173
|
+
runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
|
|
13174
|
+
let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
|
|
13175
|
+
runtimePluginVars.push(`{ plugin: ${runtimePluginVar}, params: ${paramsCode} }`);
|
|
13176
|
+
}
|
|
13177
|
+
let content = [
|
|
13178
|
+
`import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
|
|
13179
|
+
...runtimePluginImports,
|
|
13180
|
+
`const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}].filter(({ plugin }) => plugin).map(({ plugin, params }) => plugin(params))`,
|
|
13181
|
+
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
13182
|
+
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
13183
|
+
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
13184
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
13185
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
13186
|
+
compiler.webpack.Template.getFunctionContent(ModuleFederationPlugin_require('./moduleFederationDefaultRuntime.js').default)
|
|
13187
|
+
].join(';');
|
|
13188
|
+
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
13189
|
+
}
|
|
12229
13190
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
12230
13191
|
name = binding_namespaceObject.BuiltinPluginName.ContainerPlugin;
|
|
12231
13192
|
_options;
|
|
@@ -12234,7 +13195,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
12234
13195
|
name: options.name,
|
|
12235
13196
|
shareScope: options.shareScope || 'default',
|
|
12236
13197
|
library: options.library || {
|
|
12237
|
-
type: '
|
|
13198
|
+
type: 'global',
|
|
12238
13199
|
name: options.name
|
|
12239
13200
|
},
|
|
12240
13201
|
runtime: options.runtime,
|
|
@@ -12321,7 +13282,7 @@ async function transform(source, options) {
|
|
|
12321
13282
|
let _options = JSON.stringify(options || {});
|
|
12322
13283
|
return binding_default().transform(source, _options);
|
|
12323
13284
|
}
|
|
12324
|
-
let exports_rspackVersion = "2.0.0-
|
|
13285
|
+
let exports_rspackVersion = "2.0.0-beta.1", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
|
|
12325
13286
|
getNormalizedRspackOptions: getNormalizedRspackOptions,
|
|
12326
13287
|
applyRspackOptionsDefaults: applyRspackOptionsDefaults,
|
|
12327
13288
|
getNormalizedWebpackOptions: getNormalizedRspackOptions,
|
|
@@ -12364,10 +13325,12 @@ let exports_rspackVersion = "2.0.0-alpha.1", exports_version = "5.75.0", exports
|
|
|
12364
13325
|
ContainerReferencePlugin: ContainerReferencePlugin,
|
|
12365
13326
|
ModuleFederationPlugin: class {
|
|
12366
13327
|
_options;
|
|
13328
|
+
_treeShakingSharedPlugin;
|
|
12367
13329
|
constructor(_options){
|
|
12368
13330
|
this._options = _options;
|
|
12369
13331
|
}
|
|
12370
13332
|
apply(compiler) {
|
|
13333
|
+
var options;
|
|
12371
13334
|
let { webpack } = compiler, paths = function(options, compiler) {
|
|
12372
13335
|
let runtimeToolsPath;
|
|
12373
13336
|
if (options.implementation) runtimeToolsPath = options.implementation;
|
|
@@ -12400,32 +13363,38 @@ let exports_rspackVersion = "2.0.0-alpha.1", exports_version = "5.75.0", exports
|
|
|
12400
13363
|
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
12401
13364
|
'@module-federation/runtime': paths.runtime,
|
|
12402
13365
|
...compiler.options.resolve.alias
|
|
12403
|
-
}
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
13366
|
+
}, ((options = this._options).shared ? parseOptions(options.shared, (item, key)=>{
|
|
13367
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
13368
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
13369
|
+
import: key,
|
|
13370
|
+
requiredVersion: item
|
|
13371
|
+
} : {
|
|
13372
|
+
import: item
|
|
13373
|
+
};
|
|
13374
|
+
}, (item)=>item) : []).filter(([, config])=>config.treeShaking).length > 0 && (this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
|
|
13375
|
+
mfConfig: this._options,
|
|
13376
|
+
secondary: !1
|
|
13377
|
+
}), this._treeShakingSharedPlugin.apply(compiler));
|
|
13378
|
+
let runtimeExperiments = {
|
|
13379
|
+
asyncStartup: this._options.experiments?.asyncStartup ?? !1
|
|
13380
|
+
}, runtimePluginApplied = !1;
|
|
13381
|
+
compiler.hooks.beforeRun.tap({
|
|
13382
|
+
name: 'ModuleFederationPlugin',
|
|
13383
|
+
stage: 100
|
|
13384
|
+
}, ()=>{
|
|
13385
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
13386
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets),
|
|
13387
|
+
experiments: runtimeExperiments
|
|
13388
|
+
}).apply(compiler));
|
|
13389
|
+
}), compiler.hooks.watchRun.tap({
|
|
13390
|
+
name: 'ModuleFederationPlugin',
|
|
13391
|
+
stage: 100
|
|
13392
|
+
}, ()=>{
|
|
13393
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
13394
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {}),
|
|
13395
|
+
experiments: runtimeExperiments
|
|
13396
|
+
}).apply(compiler));
|
|
13397
|
+
});
|
|
12429
13398
|
let v1Options = {
|
|
12430
13399
|
name: this._options.name,
|
|
12431
13400
|
exposes: this._options.exposes,
|
|
@@ -12438,74 +13407,7 @@ let exports_rspackVersion = "2.0.0-alpha.1", exports_version = "5.75.0", exports
|
|
|
12438
13407
|
shared: this._options.shared,
|
|
12439
13408
|
enhanced: !0
|
|
12440
13409
|
};
|
|
12441
|
-
|
|
12442
|
-
let manifestOptions = !0 === this._options.manifest ? {} : {
|
|
12443
|
-
...this._options.manifest
|
|
12444
|
-
}, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
|
|
12445
|
-
if (!library) return;
|
|
12446
|
-
let libName = library.name;
|
|
12447
|
-
if (libName) {
|
|
12448
|
-
if ('string' == typeof libName) return libName;
|
|
12449
|
-
if (Array.isArray(libName)) return libName[0];
|
|
12450
|
-
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12451
|
-
}
|
|
12452
|
-
}(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
12453
|
-
if (cur[1].length > 1) return sum;
|
|
12454
|
-
let { entry, alias, name } = cur[1][0];
|
|
12455
|
-
return entry && name && (sum[alias] = {
|
|
12456
|
-
name,
|
|
12457
|
-
entry
|
|
12458
|
-
}), sum;
|
|
12459
|
-
}, {}), manifestExposes = function(exposes) {
|
|
12460
|
-
if (!exposes) return;
|
|
12461
|
-
let result = parseOptions(exposes, (value)=>({
|
|
12462
|
-
import: Array.isArray(value) ? value : [
|
|
12463
|
-
value
|
|
12464
|
-
],
|
|
12465
|
-
name: void 0
|
|
12466
|
-
}), (value)=>({
|
|
12467
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
12468
|
-
value.import
|
|
12469
|
-
],
|
|
12470
|
-
name: value.name ?? void 0
|
|
12471
|
-
})).map(([exposeKey, info])=>{
|
|
12472
|
-
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12473
|
-
return {
|
|
12474
|
-
path: exposeKey,
|
|
12475
|
-
name: exposeName
|
|
12476
|
-
};
|
|
12477
|
-
});
|
|
12478
|
-
return result.length > 0 ? result : void 0;
|
|
12479
|
-
}(this._options.exposes);
|
|
12480
|
-
void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
|
|
12481
|
-
let manifestShared = function(shared) {
|
|
12482
|
-
if (!shared) return;
|
|
12483
|
-
let result = parseOptions(shared, (item, key)=>{
|
|
12484
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12485
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12486
|
-
import: key,
|
|
12487
|
-
requiredVersion: item
|
|
12488
|
-
} : {
|
|
12489
|
-
import: item
|
|
12490
|
-
};
|
|
12491
|
-
}, (item)=>item).map(([key, config])=>{
|
|
12492
|
-
let name = config.shareKey || key;
|
|
12493
|
-
return {
|
|
12494
|
-
name,
|
|
12495
|
-
version: 'string' == typeof config.version ? config.version : void 0,
|
|
12496
|
-
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12497
|
-
singleton: config.singleton
|
|
12498
|
-
};
|
|
12499
|
-
});
|
|
12500
|
-
return result.length > 0 ? result : void 0;
|
|
12501
|
-
}(this._options.shared);
|
|
12502
|
-
void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
|
|
12503
|
-
...manifestOptions,
|
|
12504
|
-
name: containerName,
|
|
12505
|
-
globalName,
|
|
12506
|
-
remoteAliasMap
|
|
12507
|
-
}).apply(compiler);
|
|
12508
|
-
}
|
|
13410
|
+
new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
12509
13411
|
}
|
|
12510
13412
|
},
|
|
12511
13413
|
ModuleFederationPluginV1: class {
|
|
@@ -12542,6 +13444,7 @@ let exports_rspackVersion = "2.0.0-alpha.1", exports_version = "5.75.0", exports
|
|
|
12542
13444
|
}
|
|
12543
13445
|
}, sharing = {
|
|
12544
13446
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
13447
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
12545
13448
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
12546
13449
|
SharePlugin: SharePlugin
|
|
12547
13450
|
}, exports_experiments = {
|
|
@@ -12607,11 +13510,9 @@ let exports_rspackVersion = "2.0.0-alpha.1", exports_version = "5.75.0", exports
|
|
|
12607
13510
|
ssr: 'server-side-rendering'
|
|
12608
13511
|
}
|
|
12609
13512
|
}
|
|
12610
|
-
}, src_fn = Object.assign(
|
|
13513
|
+
}, src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
|
|
12611
13514
|
src_fn.rspack = src_fn, src_fn.webpack = src_fn;
|
|
12612
13515
|
let src_rspack_0 = src_fn;
|
|
12613
13516
|
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;
|
|
12614
13517
|
export default src_rspack_0;
|
|
12615
|
-
export { AsyncDependenciesBlock, BannerPlugin, CaseSensitivePlugin, CircularDependencyRspackPlugin, Compilation, Compiler, ConcatenatedModule, ContextModule, ContextReplacementPlugin, CopyRspackPlugin, CssExtractRspackPlugin, DefaultRuntimeGlobals as RuntimeGlobals, DefinePlugin, Dependency, DllPlugin, DllReferencePlugin, DynamicEntryPlugin, EntryDependency, EntryPlugin, EnvironmentPlugin, EvalDevToolModulePlugin, EvalSourceMapDevToolPlugin, ExternalModule, ExternalsPlugin, HotModuleReplacementPlugin, HtmlRspackPlugin, IgnorePlugin, LightningCssMinimizerRspackPlugin, LoaderOptionsPlugin, LoaderTargetPlugin, Module, ModuleFilenameHelpers_namespaceObject as ModuleFilenameHelpers, MultiCompiler, MultiStats, NoEmitOnErrorsPlugin, NormalModule, NormalModuleReplacementPlugin, ProgressPlugin, ProvidePlugin, RspackOptionsApply, RspackOptionsApply as WebpackOptionsApply, RuntimeModule, RuntimePlugin, SourceMapDevToolPlugin, Stats, SubresourceIntegrityPlugin, SwcJsMinimizerRspackPlugin, Template, ValidationError, container, electron, exports_WebpackError as WebpackError, exports_config as config, exports_experiments as experiments, exports_library as library, exports_node as node, exports_rspackVersion as rspackVersion, exports_version as version, exports_wasm as wasm, index_js_namespaceObject as sources, javascript, lazyCompilationMiddleware, lib_EntryOptionPlugin as EntryOptionPlugin, optimize, sharing, src_rspack_0 as rspack, statsFactoryUtils_StatsErrorCode as StatsErrorCode, util, web, webworker };
|
|
12616
|
-
|
|
12617
|
-
export { src_rspack_0 as 'module.exports' }
|
|
13518
|
+
export { AsyncDependenciesBlock, BannerPlugin, CaseSensitivePlugin, CircularDependencyRspackPlugin, Compilation, Compiler, ConcatenatedModule, ContextModule, ContextReplacementPlugin, CopyRspackPlugin, CssExtractRspackPlugin, DefaultRuntimeGlobals as RuntimeGlobals, DefinePlugin, Dependency, DllPlugin, DllReferencePlugin, DynamicEntryPlugin, EntryDependency, EntryPlugin, EnvironmentPlugin, EvalDevToolModulePlugin, EvalSourceMapDevToolPlugin, ExternalModule, ExternalsPlugin, HotModuleReplacementPlugin, HtmlRspackPlugin, IgnorePlugin, LightningCssMinimizerRspackPlugin, LoaderOptionsPlugin, LoaderTargetPlugin, Module, ModuleFilenameHelpers_namespaceObject as ModuleFilenameHelpers, MultiCompiler, MultiStats, NoEmitOnErrorsPlugin, NormalModule, NormalModuleReplacementPlugin, ProgressPlugin, ProvidePlugin, RspackOptionsApply, RspackOptionsApply as WebpackOptionsApply, RuntimeModule, RuntimePlugin, SourceMapDevToolPlugin, Stats, SubresourceIntegrityPlugin, SwcJsMinimizerRspackPlugin, Template, ValidationError, container, electron, exports_WebpackError as WebpackError, exports_config as config, exports_experiments as experiments, exports_library as library, exports_node as node, exports_rspackVersion as rspackVersion, exports_version as version, exports_wasm as wasm, index_js_namespaceObject as sources, javascript, lazyCompilationMiddleware, lib_EntryOptionPlugin as EntryOptionPlugin, optimize, sharing, src_rspack_0 as "module.exports", src_rspack_0 as rspack, statsFactoryUtils_StatsErrorCode as StatsErrorCode, util, web, webworker };
|