@rspack-debug/core 2.0.0-canary.20260120 → 2.0.0-rc.0
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/README.md +1 -1
- package/compiled/@rspack/lite-tapable/dist/index.d.ts +175 -0
- package/compiled/@rspack/lite-tapable/license +22 -0
- package/compiled/@rspack/lite-tapable/package.json +1 -0
- package/compiled/@swc/types/index.d.ts +15 -9
- package/compiled/@swc/types/package.json +1 -1
- package/compiled/connect-next/index.d.ts +56 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +544 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/open/index.d.ts +161 -0
- package/compiled/open/package.json +1 -0
- package/compiled/watchpack/index.d.ts +2 -0
- package/compiled/webpack-sources/index.js +188 -131
- package/compiled/webpack-sources/package.json +1 -1
- package/compiled/webpack-sources/types.d.ts +6 -3
- package/dist/BuildInfo.d.ts +1 -1
- package/dist/Compilation.d.ts +5 -2
- package/dist/Compiler.d.ts +4 -3
- package/dist/ContextModuleFactory.d.ts +1 -1
- package/dist/FileSystem.d.ts +1 -1
- package/dist/Module.d.ts +1 -1
- package/dist/ModuleGraph.d.ts +1 -0
- package/dist/MultiCompiler.d.ts +1 -1
- package/dist/MultiWatching.d.ts +1 -1
- package/dist/NativeWatchFileSystem.d.ts +1 -1
- package/dist/NormalModule.d.ts +1 -2
- package/dist/NormalModuleFactory.d.ts +1 -1
- package/dist/RuntimeGlobals.d.ts +1 -1
- package/dist/Watching.d.ts +1 -1
- package/dist/builtin-loader/swc/pluginImport.d.ts +1 -1
- package/dist/builtin-loader/swc/types.d.ts +37 -2
- package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +4 -2
- package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +9 -0
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.d.ts +5 -4
- package/dist/builtin-plugin/RsdoctorPlugin.d.ts +3 -3
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -1
- package/dist/builtin-plugin/WorkerPlugin.d.ts +1 -0
- package/dist/builtin-plugin/html-plugin/hooks.d.ts +1 -1
- package/dist/builtin-plugin/index.d.ts +2 -0
- package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +3 -3
- package/dist/builtin-plugin/rsc/Coordinator.d.ts +8 -0
- package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +13 -0
- package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +39 -0
- package/dist/builtin-plugin/rsc/index.d.ts +24 -0
- package/dist/checkNodeVersion.d.ts +1 -0
- package/dist/config/devServer.d.ts +102 -237
- package/dist/config/normalization.d.ts +2 -3
- package/dist/config/types.d.ts +138 -61
- package/dist/container/ContainerPlugin.d.ts +3 -2
- package/dist/container/ContainerReferencePlugin.d.ts +4 -3
- package/dist/container/ModuleFederationManifestPlugin.d.ts +10 -3
- package/dist/container/ModuleFederationPlugin.d.ts +20 -1
- package/dist/container/ModuleFederationPluginV1.d.ts +2 -2
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +4 -0
- package/dist/exports.d.ts +11 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1678 -620
- package/dist/lib/Cache.d.ts +1 -1
- package/dist/lib/HookWebpackError.d.ts +1 -1
- package/dist/moduleFederationDefaultRuntime.js +1 -1
- package/dist/node/NodeWatchFileSystem.d.ts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
- package/dist/sharing/ConsumeSharedPlugin.d.ts +16 -3
- package/dist/sharing/IndependentSharedPlugin.d.ts +35 -0
- package/dist/sharing/ProvideSharedPlugin.d.ts +22 -2
- package/dist/sharing/SharePlugin.d.ts +43 -5
- package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
- package/dist/sharing/TreeShakingSharedPlugin.d.ts +16 -0
- package/dist/sharing/utils.d.ts +1 -0
- package/dist/stats/StatsFactory.d.ts +1 -1
- package/dist/stats/StatsPrinter.d.ts +1 -1
- package/dist/swc.d.ts +2 -2
- package/dist/taps/types.d.ts +1 -1
- package/dist/util/createHash.d.ts +1 -1
- package/dist/util/source.d.ts +1 -1
- package/dist/util/supportsColor.d.ts +6 -0
- package/dist/worker.js +20 -19
- package/hot/dev-server.js +1 -1
- package/hot/emitter.js +0 -2
- package/hot/log.js +0 -2
- package/hot/only-dev-server.js +1 -1
- package/module.d.ts +4 -2
- package/package.json +20 -22
- package/dist/rslib-runtime.js +0 -29
package/dist/index.js
CHANGED
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
let createMd4, createXxhash64, service_pool, loadLoader_url;
|
|
2
|
-
import
|
|
3
|
-
import { createRequire as __rspack_createRequire
|
|
4
|
-
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
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
|
-
import node_util, { format as external_node_util_format, inspect, promisify } from "node:util";
|
|
2
|
+
import node_util, { inspect, promisify } from "node:util";
|
|
3
|
+
import { createRequire, createRequire as __rspack_createRequire } from "node:module";
|
|
8
4
|
import node_path, { isAbsolute, join, relative, resolve as external_node_path_resolve, sep } from "node:path";
|
|
9
5
|
import node_querystring from "node:querystring";
|
|
10
6
|
import node_fs, { readFileSync } from "node:fs";
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
8
|
+
import * as __rspack_external_node_util_1b29d436 from "node:util";
|
|
9
|
+
var RuntimeGlobals, StatsErrorCode, _computedKey, _computedKey1, _computedKey2, ArrayQueue_computedKey, __webpack_modules__ = {}, __webpack_module_cache__ = {};
|
|
10
|
+
function __webpack_require__(moduleId) {
|
|
11
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
12
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
13
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
14
|
+
exports: {}
|
|
15
|
+
};
|
|
16
|
+
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
17
|
+
}
|
|
18
|
+
__webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
19
|
+
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
20
|
+
return __webpack_require__.d(getter, {
|
|
21
|
+
a: getter
|
|
22
|
+
}), getter;
|
|
23
|
+
}, __webpack_require__.d = (exports, definition)=>{
|
|
24
|
+
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
25
|
+
enumerable: !0,
|
|
26
|
+
get: definition[key]
|
|
27
|
+
});
|
|
28
|
+
}, __webpack_require__.add = function(modules) {
|
|
29
|
+
Object.assign(__webpack_require__.m, modules);
|
|
30
|
+
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports)=>{
|
|
31
|
+
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
|
|
32
|
+
value: 'Module'
|
|
33
|
+
}), Object.defineProperty(exports, '__esModule', {
|
|
34
|
+
value: !0
|
|
35
|
+
});
|
|
36
|
+
}, __webpack_require__.add({
|
|
37
|
+
"../../node_modules/.pnpm/enhanced-resolve@5.20.1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
13
38
|
let { nextTick } = __webpack_require__("process"), dirname = (path)=>{
|
|
14
39
|
let idx = path.length - 1;
|
|
15
40
|
for(; idx >= 0;){
|
|
@@ -215,10 +240,10 @@ __webpack_require__.add({
|
|
|
215
240
|
};
|
|
216
241
|
},
|
|
217
242
|
process (module) {
|
|
218
|
-
module.exports =
|
|
243
|
+
module.exports = __rspack_createRequire_require("process");
|
|
219
244
|
}
|
|
220
245
|
});
|
|
221
|
-
var
|
|
246
|
+
var browserslistTargetHandler_namespaceObject = {};
|
|
222
247
|
__webpack_require__.r(browserslistTargetHandler_namespaceObject), __webpack_require__.d(browserslistTargetHandler_namespaceObject, {
|
|
223
248
|
resolve: ()=>browserslistTargetHandler_resolve
|
|
224
249
|
});
|
|
@@ -299,15 +324,493 @@ __webpack_require__.r(ModuleFilenameHelpers_namespaceObject), __webpack_require_
|
|
|
299
324
|
asRegExp: ()=>asRegExp,
|
|
300
325
|
matchObject: ()=>matchObject,
|
|
301
326
|
matchPart: ()=>matchPart
|
|
302
|
-
})
|
|
327
|
+
}), !function() {
|
|
328
|
+
let { node, bun, deno } = process.versions;
|
|
329
|
+
if (!node || bun || deno) return;
|
|
330
|
+
let [majorStr, minorStr] = node.split('.'), major = parseInt(majorStr, 10), minor = parseInt(minorStr || '0', 10);
|
|
331
|
+
20 === major && minor >= 19 || 22 === major && minor >= 12 || major > 22 || console.error(`Unsupported Node.js version "${node}". Rspack requires Node.js 20.19+ or 22.12+. Please upgrade your Node.js version.\n`);
|
|
332
|
+
}();
|
|
303
333
|
let binding_namespaceObject = __rspack_createRequire_require(process.env.RSPACK_BINDING ? process.env.RSPACK_BINDING : "@rspack/binding");
|
|
304
334
|
var binding_default = __webpack_require__.n(binding_namespaceObject);
|
|
335
|
+
function _define_property(obj, key, value) {
|
|
336
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
337
|
+
value: value,
|
|
338
|
+
enumerable: !0,
|
|
339
|
+
configurable: !0,
|
|
340
|
+
writable: !0
|
|
341
|
+
}) : obj[key] = value, obj;
|
|
342
|
+
}
|
|
343
|
+
class HookBase {
|
|
344
|
+
intercept(interceptor) {
|
|
345
|
+
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]);
|
|
346
|
+
}
|
|
347
|
+
_runRegisterInterceptors(options) {
|
|
348
|
+
return this.interceptors.reduce((options, interceptor)=>interceptor.register?.(options) ?? options, options);
|
|
349
|
+
}
|
|
350
|
+
_runCallInterceptors(...args) {
|
|
351
|
+
for (let interceptor of this.interceptors)interceptor.call && interceptor.call(...args);
|
|
352
|
+
}
|
|
353
|
+
_runErrorInterceptors(e) {
|
|
354
|
+
for (let interceptor of this.interceptors)interceptor.error && interceptor.error(e);
|
|
355
|
+
}
|
|
356
|
+
_runTapInterceptors(tap) {
|
|
357
|
+
for (let interceptor of this.interceptors)interceptor.tap && interceptor.tap(tap);
|
|
358
|
+
}
|
|
359
|
+
_runDoneInterceptors() {
|
|
360
|
+
for (let interceptor of this.interceptors)interceptor.done && interceptor.done();
|
|
361
|
+
}
|
|
362
|
+
_runResultInterceptors(r) {
|
|
363
|
+
for (let interceptor of this.interceptors)interceptor.result && interceptor.result(r);
|
|
364
|
+
}
|
|
365
|
+
withOptions(options) {
|
|
366
|
+
let mergeOptions = (opt)=>Object.assign({}, options, 'string' == typeof opt ? {
|
|
367
|
+
name: opt
|
|
368
|
+
} : opt);
|
|
369
|
+
return {
|
|
370
|
+
name: this.name,
|
|
371
|
+
tap: (opt, fn)=>this.tap(mergeOptions(opt), fn),
|
|
372
|
+
tapAsync: (opt, fn)=>this.tapAsync(mergeOptions(opt), fn),
|
|
373
|
+
tapPromise: (opt, fn)=>this.tapPromise(mergeOptions(opt), fn),
|
|
374
|
+
intercept: (interceptor)=>this.intercept(interceptor),
|
|
375
|
+
isUsed: ()=>this.isUsed(),
|
|
376
|
+
withOptions: (opt)=>this.withOptions(mergeOptions(opt)),
|
|
377
|
+
queryStageRange: (stageRange)=>this.queryStageRange(stageRange)
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
isUsed() {
|
|
381
|
+
return this.taps.length > 0 || this.interceptors.length > 0;
|
|
382
|
+
}
|
|
383
|
+
queryStageRange(stageRange) {
|
|
384
|
+
return new QueriedHook(stageRange, this);
|
|
385
|
+
}
|
|
386
|
+
callAsyncStageRange(queried) {
|
|
387
|
+
throw Error('Hook should implement there own _callAsyncStageRange');
|
|
388
|
+
}
|
|
389
|
+
callAsync(...args) {
|
|
390
|
+
return this.callAsyncStageRange(this.queryStageRange(allStageRange), ...args);
|
|
391
|
+
}
|
|
392
|
+
promiseStageRange(queried, ...args) {
|
|
393
|
+
return new Promise((resolve, reject)=>{
|
|
394
|
+
this.callAsyncStageRange(queried, ...args, (e, r)=>e ? reject(e) : resolve(r));
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
promise(...args) {
|
|
398
|
+
return this.promiseStageRange(this.queryStageRange(allStageRange), ...args);
|
|
399
|
+
}
|
|
400
|
+
tap(options, fn) {
|
|
401
|
+
this._tap('sync', options, fn);
|
|
402
|
+
}
|
|
403
|
+
tapAsync(options, fn) {
|
|
404
|
+
this._tap('async', options, fn);
|
|
405
|
+
}
|
|
406
|
+
tapPromise(options, fn) {
|
|
407
|
+
this._tap('promise', options, fn);
|
|
408
|
+
}
|
|
409
|
+
_tap(type, options, fn) {
|
|
410
|
+
let normalizedOptions = options;
|
|
411
|
+
if ('string' == typeof options) normalizedOptions = {
|
|
412
|
+
name: options.trim()
|
|
413
|
+
};
|
|
414
|
+
else if ('object' != typeof options || null === options) throw Error('Invalid tap options');
|
|
415
|
+
if ('string' != typeof normalizedOptions.name || '' === normalizedOptions.name) throw Error('Missing name for tap');
|
|
416
|
+
this._insert(this._runRegisterInterceptors(Object.assign({
|
|
417
|
+
type,
|
|
418
|
+
fn
|
|
419
|
+
}, normalizedOptions)));
|
|
420
|
+
}
|
|
421
|
+
_insert(item) {
|
|
422
|
+
let before;
|
|
423
|
+
'string' == typeof item.before ? before = new Set([
|
|
424
|
+
item.before
|
|
425
|
+
]) : Array.isArray(item.before) && (before = new Set(item.before));
|
|
426
|
+
let stage = 0;
|
|
427
|
+
'number' == typeof item.stage && (stage = item.stage);
|
|
428
|
+
let i = this.taps.length;
|
|
429
|
+
for(; i > 0;){
|
|
430
|
+
i--;
|
|
431
|
+
let x = this.taps[i];
|
|
432
|
+
this.taps[i + 1] = x;
|
|
433
|
+
let xStage = x.stage || 0;
|
|
434
|
+
if (before) {
|
|
435
|
+
if (before.has(x.name)) {
|
|
436
|
+
before.delete(x.name);
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (before.size > 0) continue;
|
|
440
|
+
}
|
|
441
|
+
if (!(xStage > stage)) {
|
|
442
|
+
i++;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
this.taps[i] = item;
|
|
447
|
+
}
|
|
448
|
+
_prepareArgs(args) {
|
|
449
|
+
let len = this.args.length;
|
|
450
|
+
return args.length < len ? (args.length = len, args.fill(void 0, args.length, len)) : (args.length > len && (args.length = len), args);
|
|
451
|
+
}
|
|
452
|
+
constructor(args = [], name){
|
|
453
|
+
_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 = [];
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
let minStage = -1 / 0, maxStage = 1 / 0, allStageRange = [
|
|
457
|
+
minStage,
|
|
458
|
+
1 / 0
|
|
459
|
+
], i32MAX = 2147483648 - 1, safeStage = (stage)=>stage < -2147483648 ? -2147483648 : stage > i32MAX ? i32MAX : stage;
|
|
460
|
+
class QueriedHook {
|
|
461
|
+
isUsed() {
|
|
462
|
+
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));
|
|
463
|
+
}
|
|
464
|
+
call(...args) {
|
|
465
|
+
if ('function' != typeof this.hook.callStageRange) throw Error('hook is not a SyncHook, call methods only exists on SyncHook');
|
|
466
|
+
return this.hook.callStageRange(this, ...args);
|
|
467
|
+
}
|
|
468
|
+
callAsync(...args) {
|
|
469
|
+
return this.hook.callAsyncStageRange(this, ...args);
|
|
470
|
+
}
|
|
471
|
+
promise(...args) {
|
|
472
|
+
return this.hook.promiseStageRange(this, ...args);
|
|
473
|
+
}
|
|
474
|
+
constructor(stageRange, hook){
|
|
475
|
+
_define_property(this, "stageRange", void 0), _define_property(this, "hook", void 0), _define_property(this, "tapsInRange", void 0);
|
|
476
|
+
let tapsInRange = [], [from, to] = stageRange;
|
|
477
|
+
for (let tap of hook.taps){
|
|
478
|
+
let stage = tap.stage ?? 0;
|
|
479
|
+
from <= stage && stage < to ? tapsInRange.push(tap) : to === maxStage && stage === maxStage && tapsInRange.push(tap);
|
|
480
|
+
}
|
|
481
|
+
this.stageRange = stageRange, this.hook = hook, this.tapsInRange = tapsInRange;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
class SyncHook extends HookBase {
|
|
485
|
+
callAsyncStageRange(queried, ...args) {
|
|
486
|
+
let { stageRange: [from, to], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
487
|
+
for (let tap of (from === minStage && this._runCallInterceptors(...args2), tapsInRange)){
|
|
488
|
+
this._runTapInterceptors(tap);
|
|
489
|
+
try {
|
|
490
|
+
tap.fn(...args2);
|
|
491
|
+
} catch (e) {
|
|
492
|
+
return this._runErrorInterceptors(e), cb(e);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
to === maxStage && (this._runDoneInterceptors(), cb(null));
|
|
496
|
+
}
|
|
497
|
+
call(...args) {
|
|
498
|
+
return this.callStageRange(this.queryStageRange(allStageRange), ...args);
|
|
499
|
+
}
|
|
500
|
+
callStageRange(queried, ...args) {
|
|
501
|
+
let result, error;
|
|
502
|
+
if (this.callAsyncStageRange(queried, ...args, (e, r)=>{
|
|
503
|
+
error = e, result = r;
|
|
504
|
+
}), error) throw error;
|
|
505
|
+
return result;
|
|
506
|
+
}
|
|
507
|
+
tapAsync() {
|
|
508
|
+
throw Error('tapAsync is not supported on a SyncHook');
|
|
509
|
+
}
|
|
510
|
+
tapPromise() {
|
|
511
|
+
throw Error('tapPromise is not supported on a SyncHook');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
class SyncBailHook extends HookBase {
|
|
515
|
+
callAsyncStageRange(queried, ...args) {
|
|
516
|
+
let { stageRange: [from, to], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
517
|
+
for (let tap of (from === minStage && this._runCallInterceptors(...args2), tapsInRange)){
|
|
518
|
+
let r;
|
|
519
|
+
this._runTapInterceptors(tap);
|
|
520
|
+
try {
|
|
521
|
+
r = tap.fn(...args2);
|
|
522
|
+
} catch (e) {
|
|
523
|
+
return this._runErrorInterceptors(e), cb(e);
|
|
524
|
+
}
|
|
525
|
+
if (void 0 !== r) return this._runResultInterceptors(r), cb(null, r);
|
|
526
|
+
}
|
|
527
|
+
to === maxStage && (this._runDoneInterceptors(), cb(null));
|
|
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 SyncBailHook');
|
|
541
|
+
}
|
|
542
|
+
tapPromise() {
|
|
543
|
+
throw Error('tapPromise is not supported on a SyncBailHook');
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
class SyncWaterfallHook extends HookBase {
|
|
547
|
+
callAsyncStageRange(queried, ...args) {
|
|
548
|
+
let { stageRange: [from, to], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
549
|
+
for (let tap of (from === minStage && this._runCallInterceptors(...args2), tapsInRange)){
|
|
550
|
+
this._runTapInterceptors(tap);
|
|
551
|
+
try {
|
|
552
|
+
let r = tap.fn(...args2);
|
|
553
|
+
void 0 !== r && (args2[0] = r);
|
|
554
|
+
} catch (e) {
|
|
555
|
+
return this._runErrorInterceptors(e), cb(e);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
to === maxStage && (this._runDoneInterceptors(), cb(null, args2[0]));
|
|
559
|
+
}
|
|
560
|
+
call(...args) {
|
|
561
|
+
return this.callStageRange(this.queryStageRange(allStageRange), ...args);
|
|
562
|
+
}
|
|
563
|
+
callStageRange(queried, ...args) {
|
|
564
|
+
let result, error;
|
|
565
|
+
if (this.callAsyncStageRange(queried, ...args, (e, r)=>{
|
|
566
|
+
error = e, result = r;
|
|
567
|
+
}), error) throw error;
|
|
568
|
+
return result;
|
|
569
|
+
}
|
|
570
|
+
tapAsync() {
|
|
571
|
+
throw Error('tapAsync is not supported on a SyncWaterfallHook');
|
|
572
|
+
}
|
|
573
|
+
tapPromise() {
|
|
574
|
+
throw Error('tapPromise is not supported on a SyncWaterfallHook');
|
|
575
|
+
}
|
|
576
|
+
constructor(args = [], name){
|
|
577
|
+
if (args.length < 1) throw Error('Waterfall hooks must have at least one argument');
|
|
578
|
+
super(args, name);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
class AsyncParallelHook extends HookBase {
|
|
582
|
+
callAsyncStageRange(queried, ...args) {
|
|
583
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
584
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
585
|
+
let done = ()=>{
|
|
586
|
+
this._runDoneInterceptors(), cb(null);
|
|
587
|
+
}, error = (e)=>{
|
|
588
|
+
this._runErrorInterceptors(e), cb(e);
|
|
589
|
+
};
|
|
590
|
+
if (0 === tapsInRange.length) return done();
|
|
591
|
+
let counter = tapsInRange.length;
|
|
592
|
+
for (let tap of tapsInRange){
|
|
593
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
594
|
+
let promise = tap.fn(...args2);
|
|
595
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
596
|
+
promise.then(()=>{
|
|
597
|
+
0 == (counter -= 1) && done();
|
|
598
|
+
}, (e)=>{
|
|
599
|
+
counter = 0, error(e);
|
|
600
|
+
});
|
|
601
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e)=>{
|
|
602
|
+
e ? (counter = 0, error(e)) : 0 == (counter -= 1) && done();
|
|
603
|
+
});
|
|
604
|
+
else {
|
|
605
|
+
let hasError = !1;
|
|
606
|
+
try {
|
|
607
|
+
tap.fn(...args2);
|
|
608
|
+
} catch (e) {
|
|
609
|
+
hasError = !0, counter = 0, error(e);
|
|
610
|
+
}
|
|
611
|
+
hasError || 0 != --counter || done();
|
|
612
|
+
}
|
|
613
|
+
if (counter <= 0) return;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
class AsyncSeriesHook extends HookBase {
|
|
618
|
+
callAsyncStageRange(queried, ...args) {
|
|
619
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
620
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
621
|
+
let done = ()=>{
|
|
622
|
+
this._runDoneInterceptors(), cb(null);
|
|
623
|
+
}, error = (e)=>{
|
|
624
|
+
this._runErrorInterceptors(e), cb(e);
|
|
625
|
+
};
|
|
626
|
+
if (0 === tapsInRange.length) return done();
|
|
627
|
+
let index = 0, next = ()=>{
|
|
628
|
+
let tap = tapsInRange[index];
|
|
629
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
630
|
+
let promise = tap.fn(...args2);
|
|
631
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
632
|
+
promise.then(()=>{
|
|
633
|
+
(index += 1) === tapsInRange.length ? done() : next();
|
|
634
|
+
}, (e)=>{
|
|
635
|
+
index = tapsInRange.length, error(e);
|
|
636
|
+
});
|
|
637
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e)=>{
|
|
638
|
+
e ? (index = tapsInRange.length, error(e)) : (index += 1) === tapsInRange.length ? done() : next();
|
|
639
|
+
});
|
|
640
|
+
else {
|
|
641
|
+
let hasError = !1;
|
|
642
|
+
try {
|
|
643
|
+
tap.fn(...args2);
|
|
644
|
+
} catch (e) {
|
|
645
|
+
hasError = !0, index = tapsInRange.length, error(e);
|
|
646
|
+
}
|
|
647
|
+
hasError || ((index += 1) === tapsInRange.length ? done() : next());
|
|
648
|
+
}
|
|
649
|
+
if (index === tapsInRange.length) return;
|
|
650
|
+
};
|
|
651
|
+
next();
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
class AsyncSeriesBailHook extends HookBase {
|
|
655
|
+
callAsyncStageRange(queried, ...args) {
|
|
656
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
657
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
658
|
+
let done = ()=>{
|
|
659
|
+
this._runDoneInterceptors(), cb(null);
|
|
660
|
+
}, error = (e)=>{
|
|
661
|
+
this._runErrorInterceptors(e), cb(e);
|
|
662
|
+
}, result = (r)=>{
|
|
663
|
+
this._runResultInterceptors(r), cb(null, r);
|
|
664
|
+
};
|
|
665
|
+
if (0 === tapsInRange.length) return done();
|
|
666
|
+
let index = 0, next = ()=>{
|
|
667
|
+
let tap = tapsInRange[index];
|
|
668
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
669
|
+
let promise = tap.fn(...args2);
|
|
670
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
671
|
+
promise.then((r)=>{
|
|
672
|
+
index += 1, void 0 !== r ? result(r) : index === tapsInRange.length ? done() : next();
|
|
673
|
+
}, (e)=>{
|
|
674
|
+
index = tapsInRange.length, error(e);
|
|
675
|
+
});
|
|
676
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e, r)=>{
|
|
677
|
+
e ? (index = tapsInRange.length, error(e)) : (index += 1, void 0 !== r ? result(r) : index === tapsInRange.length ? done() : next());
|
|
678
|
+
});
|
|
679
|
+
else {
|
|
680
|
+
let r, hasError = !1;
|
|
681
|
+
try {
|
|
682
|
+
r = tap.fn(...args2);
|
|
683
|
+
} catch (e) {
|
|
684
|
+
hasError = !0, index = tapsInRange.length, error(e);
|
|
685
|
+
}
|
|
686
|
+
hasError || (index += 1, void 0 !== r ? result(r) : index === tapsInRange.length ? done() : next());
|
|
687
|
+
}
|
|
688
|
+
if (index === tapsInRange.length) return;
|
|
689
|
+
};
|
|
690
|
+
next();
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
class AsyncSeriesWaterfallHook extends HookBase {
|
|
694
|
+
callAsyncStageRange(queried, ...args) {
|
|
695
|
+
let { stageRange: [from], tapsInRange } = queried, argsWithoutCb = args.slice(0, args.length - 1), cb = args[args.length - 1], args2 = this._prepareArgs(argsWithoutCb);
|
|
696
|
+
from === minStage && this._runCallInterceptors(...args2);
|
|
697
|
+
let result = (r)=>{
|
|
698
|
+
this._runResultInterceptors(r), cb(null, r);
|
|
699
|
+
}, error = (e)=>{
|
|
700
|
+
this._runErrorInterceptors(e), cb(e);
|
|
701
|
+
};
|
|
702
|
+
if (0 === tapsInRange.length) return result(args2[0]);
|
|
703
|
+
let index = 0, next = ()=>{
|
|
704
|
+
let tap = tapsInRange[index];
|
|
705
|
+
if (this._runTapInterceptors(tap), 'promise' === tap.type) {
|
|
706
|
+
let promise = tap.fn(...args2);
|
|
707
|
+
if (!promise || !promise.then) throw Error(`Tap function (tapPromise) did not return promise (returned ${promise})`);
|
|
708
|
+
promise.then((r)=>{
|
|
709
|
+
index += 1, void 0 !== r && (args2[0] = r), index === tapsInRange.length ? result(args2[0]) : next();
|
|
710
|
+
}, (e)=>{
|
|
711
|
+
index = tapsInRange.length, error(e);
|
|
712
|
+
});
|
|
713
|
+
} else if ('async' === tap.type) tap.fn(...args2, (e, r)=>{
|
|
714
|
+
e ? (index = tapsInRange.length, error(e)) : (index += 1, void 0 !== r && (args2[0] = r), index === tapsInRange.length ? result(args2[0]) : next());
|
|
715
|
+
});
|
|
716
|
+
else {
|
|
717
|
+
let hasError = !1;
|
|
718
|
+
try {
|
|
719
|
+
let r = tap.fn(...args2);
|
|
720
|
+
void 0 !== r && (args2[0] = r);
|
|
721
|
+
} catch (e) {
|
|
722
|
+
hasError = !0, index = tapsInRange.length, error(e);
|
|
723
|
+
}
|
|
724
|
+
hasError || ((index += 1) === tapsInRange.length ? result(args2[0]) : next());
|
|
725
|
+
}
|
|
726
|
+
if (index === tapsInRange.length) return;
|
|
727
|
+
};
|
|
728
|
+
next();
|
|
729
|
+
}
|
|
730
|
+
constructor(args = [], name){
|
|
731
|
+
if (args.length < 1) throw Error('Waterfall hooks must have at least one argument');
|
|
732
|
+
super(args, name);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
let defaultFactory = (key, hook)=>hook;
|
|
736
|
+
class HookMap {
|
|
737
|
+
get(key) {
|
|
738
|
+
return this._map.get(key);
|
|
739
|
+
}
|
|
740
|
+
for(key) {
|
|
741
|
+
let hook = this.get(key);
|
|
742
|
+
if (void 0 !== hook) return hook;
|
|
743
|
+
let newHook = this._factory(key), interceptors = this._interceptors;
|
|
744
|
+
for(let i = 0; i < interceptors.length; i++){
|
|
745
|
+
let factory = interceptors[i].factory;
|
|
746
|
+
factory && (newHook = factory(key, newHook));
|
|
747
|
+
}
|
|
748
|
+
return this._map.set(key, newHook), newHook;
|
|
749
|
+
}
|
|
750
|
+
intercept(interceptor) {
|
|
751
|
+
this._interceptors.push(Object.assign({
|
|
752
|
+
factory: defaultFactory
|
|
753
|
+
}, interceptor));
|
|
754
|
+
}
|
|
755
|
+
isUsed() {
|
|
756
|
+
for (let key of this._map.keys()){
|
|
757
|
+
let hook = this.get(key);
|
|
758
|
+
if (hook?.isUsed()) return !0;
|
|
759
|
+
}
|
|
760
|
+
return !1;
|
|
761
|
+
}
|
|
762
|
+
queryStageRange(stageRange) {
|
|
763
|
+
return new QueriedHookMap(stageRange, this);
|
|
764
|
+
}
|
|
765
|
+
constructor(factory, name){
|
|
766
|
+
_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 = [];
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
class QueriedHookMap {
|
|
770
|
+
get(key) {
|
|
771
|
+
return this.hookMap.get(key)?.queryStageRange(this.stageRange);
|
|
772
|
+
}
|
|
773
|
+
for(key) {
|
|
774
|
+
return this.hookMap.for(key).queryStageRange(this.stageRange);
|
|
775
|
+
}
|
|
776
|
+
isUsed() {
|
|
777
|
+
for (let key of this.hookMap._map.keys())if (this.get(key)?.isUsed()) return !0;
|
|
778
|
+
return !1;
|
|
779
|
+
}
|
|
780
|
+
constructor(stageRange, hookMap){
|
|
781
|
+
_define_property(this, "stageRange", void 0), _define_property(this, "hookMap", void 0), this.stageRange = stageRange, this.hookMap = hookMap;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
class MultiHook {
|
|
785
|
+
tap(options, fn) {
|
|
786
|
+
for (let hook of this.hooks)hook.tap(options, fn);
|
|
787
|
+
}
|
|
788
|
+
tapAsync(options, fn) {
|
|
789
|
+
for (let hook of this.hooks)hook.tapAsync(options, fn);
|
|
790
|
+
}
|
|
791
|
+
tapPromise(options, fn) {
|
|
792
|
+
for (let hook of this.hooks)hook.tapPromise(options, fn);
|
|
793
|
+
}
|
|
794
|
+
isUsed() {
|
|
795
|
+
for (let hook of this.hooks)if (hook.isUsed()) return !0;
|
|
796
|
+
return !1;
|
|
797
|
+
}
|
|
798
|
+
intercept(interceptor) {
|
|
799
|
+
for (let hook of this.hooks)hook.intercept(interceptor);
|
|
800
|
+
}
|
|
801
|
+
withOptions(options) {
|
|
802
|
+
return new MultiHook(this.hooks.map((h)=>h.withOptions(options)), this.name);
|
|
803
|
+
}
|
|
804
|
+
constructor(hooks, name){
|
|
805
|
+
_define_property(this, "hooks", void 0), _define_property(this, "name", void 0), this.hooks = hooks, this.name = name;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
305
808
|
let cutOffLoaderExecution = (stack)=>((stack, flag)=>{
|
|
306
809
|
let stacks = stack.split('\n');
|
|
307
810
|
for(let i = 0; i < stacks.length; i++)stacks[i].includes(flag) && (stacks.length = i);
|
|
308
811
|
return stacks.join('\n');
|
|
309
812
|
})(stack, 'LOADER_EXECUTION');
|
|
310
|
-
class
|
|
813
|
+
class WebpackError_WebpackError extends Error {
|
|
311
814
|
loc;
|
|
312
815
|
file;
|
|
313
816
|
chunk;
|
|
@@ -315,14 +818,14 @@ class WebpackError extends Error {
|
|
|
315
818
|
details;
|
|
316
819
|
hideStack;
|
|
317
820
|
}
|
|
318
|
-
Object.defineProperty(
|
|
821
|
+
Object.defineProperty(WebpackError_WebpackError.prototype, inspect.custom, {
|
|
319
822
|
value: function() {
|
|
320
823
|
return this.stack + (this.details ? `\n${this.details}` : '');
|
|
321
824
|
},
|
|
322
825
|
enumerable: !1,
|
|
323
826
|
configurable: !0
|
|
324
827
|
});
|
|
325
|
-
let lib_WebpackError =
|
|
828
|
+
let lib_WebpackError = WebpackError_WebpackError, LogType = Object.freeze({
|
|
326
829
|
error: 'error',
|
|
327
830
|
warn: 'warn',
|
|
328
831
|
info: 'info',
|
|
@@ -340,7 +843,7 @@ let lib_WebpackError = WebpackError, LogType = Object.freeze({
|
|
|
340
843
|
cache: 'cache'
|
|
341
844
|
});
|
|
342
845
|
function getLogTypeBitFlag(type) {
|
|
343
|
-
return 1 << Object.values(LogType).
|
|
846
|
+
return 1 << Object.values(LogType).indexOf(type);
|
|
344
847
|
}
|
|
345
848
|
function getLogTypesBitFlag(types) {
|
|
346
849
|
return types.reduce((acc, cur)=>acc | getLogTypeBitFlag(cur), 0);
|
|
@@ -478,6 +981,9 @@ class ModuleGraph {
|
|
|
478
981
|
getResolvedModule(dependency) {
|
|
479
982
|
return this.#inner.getResolvedModule(dependency);
|
|
480
983
|
}
|
|
984
|
+
getUsedExports(module, runtime) {
|
|
985
|
+
return this.#inner.getUsedExports(module, runtime);
|
|
986
|
+
}
|
|
481
987
|
getParentModule(dependency) {
|
|
482
988
|
return this.#inner.getParentModule(dependency);
|
|
483
989
|
}
|
|
@@ -598,6 +1104,17 @@ class Stats {
|
|
|
598
1104
|
compilation: this.compilation,
|
|
599
1105
|
getStatsCompilation: (compilation)=>{
|
|
600
1106
|
if (statsCompilationMap.has(compilation)) return statsCompilationMap.get(compilation);
|
|
1107
|
+
if (this.compilation !== this.compilation.compiler._lastCompilation) return {
|
|
1108
|
+
assets: [],
|
|
1109
|
+
assetsByChunkName: [],
|
|
1110
|
+
chunks: [],
|
|
1111
|
+
entrypoints: [],
|
|
1112
|
+
errors: [],
|
|
1113
|
+
hash: 'XXXX',
|
|
1114
|
+
modules: [],
|
|
1115
|
+
namedChunkGroups: [],
|
|
1116
|
+
warnings: []
|
|
1117
|
+
};
|
|
601
1118
|
let innerStats = this.#getInnerByCompilation(compilation);
|
|
602
1119
|
options.warnings = !1;
|
|
603
1120
|
let innerStatsCompilation = innerStats.toJson(options);
|
|
@@ -613,6 +1130,17 @@ class Stats {
|
|
|
613
1130
|
compilation: this.compilation,
|
|
614
1131
|
getStatsCompilation: (compilation)=>{
|
|
615
1132
|
if (statsCompilationMap.has(compilation)) return statsCompilationMap.get(compilation);
|
|
1133
|
+
if (this.compilation !== this.compilation.compiler._lastCompilation) return {
|
|
1134
|
+
assets: [],
|
|
1135
|
+
assetsByChunkName: [],
|
|
1136
|
+
chunks: [],
|
|
1137
|
+
entrypoints: [],
|
|
1138
|
+
errors: [],
|
|
1139
|
+
hash: 'XXXX',
|
|
1140
|
+
modules: [],
|
|
1141
|
+
namedChunkGroups: [],
|
|
1142
|
+
warnings: []
|
|
1143
|
+
};
|
|
616
1144
|
let innerStatsCompilation = this.#getInnerByCompilation(compilation).toJson(options);
|
|
617
1145
|
return statsCompilationMap.set(compilation, innerStatsCompilation), innerStatsCompilation;
|
|
618
1146
|
},
|
|
@@ -1055,15 +1583,15 @@ class MergeCaller {
|
|
|
1055
1583
|
return this.callArgs;
|
|
1056
1584
|
}
|
|
1057
1585
|
push(...data) {
|
|
1058
|
-
0 === this.callArgs.length && queueMicrotask(this.finalCall)
|
|
1586
|
+
0 === this.callArgs.length && queueMicrotask(this.finalCall);
|
|
1587
|
+
for(let i = 0; i < data.length; i++)this.callArgs.push(data[i]);
|
|
1059
1588
|
}
|
|
1060
1589
|
}
|
|
1061
1590
|
function createFakeCompilationDependencies(getDeps, addDeps) {
|
|
1062
1591
|
let addDepsCaller = new MergeCaller(addDeps), deletedDeps = new Set(), hasDep = (dep)=>!deletedDeps.has(dep) && (addDepsCaller.pendingData().includes(dep) || getDeps().includes(dep)), getAllDeps = ()=>{
|
|
1063
|
-
let deps = new Set(
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
]);
|
|
1592
|
+
let deps = new Set();
|
|
1593
|
+
for (let dep of getDeps())deps.add(dep);
|
|
1594
|
+
for (let dep of addDepsCaller.pendingData())deps.add(dep);
|
|
1067
1595
|
for (let deleted of deletedDeps)deps.delete(deleted);
|
|
1068
1596
|
return deps;
|
|
1069
1597
|
};
|
|
@@ -1076,8 +1604,7 @@ function createFakeCompilationDependencies(getDeps, addDeps) {
|
|
|
1076
1604
|
deletedDeps.delete(dep), addDepsCaller.push(dep);
|
|
1077
1605
|
},
|
|
1078
1606
|
addAll: (deps)=>{
|
|
1079
|
-
for (let dep of deps)deletedDeps.delete(dep);
|
|
1080
|
-
addDepsCaller.push(...deps);
|
|
1607
|
+
for (let dep of deps)deletedDeps.delete(dep), addDepsCaller.push(dep);
|
|
1081
1608
|
},
|
|
1082
1609
|
delete: (dep)=>{
|
|
1083
1610
|
let hadDep = hasDep(dep);
|
|
@@ -1295,10 +1822,10 @@ function createDiagnosticArray(adm) {
|
|
|
1295
1822
|
reduce: (callbackfn, initialValue)=>adm.values().reduce(callbackfn, initialValue),
|
|
1296
1823
|
reduceRight: (callbackfn, initialValue)=>adm.values().reduceRight(callbackfn, initialValue)
|
|
1297
1824
|
}, proxy = new Proxy(array, {
|
|
1298
|
-
get: (target, name)=>'length' === name ? adm.length : 'string' != typeof name || Number.isNaN(Number.parseInt(name)) ? Object.prototype.hasOwnProperty.call(arrayExtensions, name) ? arrayExtensions[name] : target[name] : adm.get(Number.parseInt(name)),
|
|
1825
|
+
get: (target, name)=>'length' === name ? adm.length : 'string' != typeof name || Number.isNaN(Number.parseInt(name, 10)) ? Object.prototype.hasOwnProperty.call(arrayExtensions, name) ? arrayExtensions[name] : target[name] : adm.get(Number.parseInt(name, 10)),
|
|
1299
1826
|
set (target, name, value) {
|
|
1300
1827
|
if ('length' === name) throw Error("The 'length' property is read-only and cannot be assigned a new value.");
|
|
1301
|
-
return 'symbol' == typeof name || Number.isNaN(Number.parseInt(name)) ? target[name] = value : adm.set(Number.parseInt(name), value), !0;
|
|
1828
|
+
return 'symbol' == typeof name || Number.isNaN(Number.parseInt(name, 10)) ? target[name] = value : adm.set(Number.parseInt(name, 10), value), !0;
|
|
1302
1829
|
}
|
|
1303
1830
|
});
|
|
1304
1831
|
return adm[$proxy] = proxy, proxy;
|
|
@@ -1395,6 +1922,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1395
1922
|
'chunks',
|
|
1396
1923
|
'modules'
|
|
1397
1924
|
]),
|
|
1925
|
+
beforeModuleIds: new SyncHook([
|
|
1926
|
+
'modules'
|
|
1927
|
+
]),
|
|
1398
1928
|
finishModules: new AsyncSeriesHook([
|
|
1399
1929
|
'modules'
|
|
1400
1930
|
]),
|
|
@@ -1453,7 +1983,18 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1453
1983
|
seal: new SyncHook([]),
|
|
1454
1984
|
afterSeal: new AsyncSeriesHook([]),
|
|
1455
1985
|
needAdditionalPass: new SyncBailHook([])
|
|
1456
|
-
}
|
|
1986
|
+
};
|
|
1987
|
+
let availableHooks = Object.keys(this.hooks);
|
|
1988
|
+
this.hooks = new Proxy(this.hooks, {
|
|
1989
|
+
get (target, prop, receiver) {
|
|
1990
|
+
let value = Reflect.get(target, prop, receiver);
|
|
1991
|
+
if (void 0 === value && 'string' == typeof prop) {
|
|
1992
|
+
let hooksList = availableHooks.join(', ');
|
|
1993
|
+
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}`);
|
|
1994
|
+
}
|
|
1995
|
+
return value;
|
|
1996
|
+
}
|
|
1997
|
+
}), 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();
|
|
1457
1998
|
}
|
|
1458
1999
|
get hash() {
|
|
1459
2000
|
return this.#inner.hash;
|
|
@@ -1848,6 +2389,12 @@ class Entries {
|
|
|
1848
2389
|
delete(key) {
|
|
1849
2390
|
return this.#data.delete(key);
|
|
1850
2391
|
}
|
|
2392
|
+
getOrInsert(key, defaultValue) {
|
|
2393
|
+
return this.has(key) || this.set(key, defaultValue), this.get(key);
|
|
2394
|
+
}
|
|
2395
|
+
getOrInsertComputed(key, callback) {
|
|
2396
|
+
return this.has(key) || this.set(key, callback(key)), this.get(key);
|
|
2397
|
+
}
|
|
1851
2398
|
get(key) {
|
|
1852
2399
|
let binding = this.#data.get(key);
|
|
1853
2400
|
return binding ? EntryData.__from_binding(binding) : void 0;
|
|
@@ -2141,6 +2688,75 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
|
|
|
2141
2688
|
}
|
|
2142
2689
|
}
|
|
2143
2690
|
}
|
|
2691
|
+
class JsSplitChunkSizes {
|
|
2692
|
+
static __to_binding(sizes) {
|
|
2693
|
+
return 'number' == typeof sizes ? sizes : sizes && 'object' == typeof sizes ? {
|
|
2694
|
+
sizes: sizes
|
|
2695
|
+
} : sizes;
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
class SplitChunksPlugin extends RspackBuiltinPlugin {
|
|
2699
|
+
options;
|
|
2700
|
+
name = binding_namespaceObject.BuiltinPluginName.SplitChunksPlugin;
|
|
2701
|
+
affectedHooks = 'thisCompilation';
|
|
2702
|
+
constructor(options){
|
|
2703
|
+
super(), this.options = options;
|
|
2704
|
+
}
|
|
2705
|
+
raw(compiler) {
|
|
2706
|
+
let rawOptions = SplitChunksPlugin_toRawSplitChunksOptions(this.options, compiler);
|
|
2707
|
+
if (void 0 === rawOptions) throw Error('rawOptions should not be undefined');
|
|
2708
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
function SplitChunksPlugin_toRawSplitChunksOptions(sc, compiler) {
|
|
2712
|
+
if (!sc) return;
|
|
2713
|
+
function getName(name) {
|
|
2714
|
+
return 'function' == typeof name ? (ctx)=>void 0 === ctx.module ? name(void 0) : name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey) : name;
|
|
2715
|
+
}
|
|
2716
|
+
function getChunks(chunks) {
|
|
2717
|
+
return 'function' == typeof chunks ? (chunk)=>chunks(chunk) : chunks;
|
|
2718
|
+
}
|
|
2719
|
+
let { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
|
|
2720
|
+
return {
|
|
2721
|
+
name: getName(name),
|
|
2722
|
+
chunks: getChunks(chunks),
|
|
2723
|
+
defaultSizeTypes: defaultSizeTypes || [
|
|
2724
|
+
"javascript",
|
|
2725
|
+
'unknown'
|
|
2726
|
+
],
|
|
2727
|
+
cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>!1 !== group).map(([key, group])=>{
|
|
2728
|
+
let { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
|
|
2729
|
+
return {
|
|
2730
|
+
key,
|
|
2731
|
+
test: 'function' == typeof test ? (ctx)=>{
|
|
2732
|
+
let info = {
|
|
2733
|
+
moduleGraph: compiler._lastCompilation.moduleGraph,
|
|
2734
|
+
chunkGraph: compiler._lastCompilation.chunkGraph
|
|
2735
|
+
};
|
|
2736
|
+
return test(ctx.module, info);
|
|
2737
|
+
} : test,
|
|
2738
|
+
name: getName(name),
|
|
2739
|
+
chunks: getChunks(chunks),
|
|
2740
|
+
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
2741
|
+
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
2742
|
+
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
2743
|
+
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
2744
|
+
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
2745
|
+
...passThrough
|
|
2746
|
+
};
|
|
2747
|
+
}),
|
|
2748
|
+
fallbackCacheGroup: {
|
|
2749
|
+
chunks: getChunks(chunks),
|
|
2750
|
+
...fallbackCacheGroup
|
|
2751
|
+
},
|
|
2752
|
+
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
2753
|
+
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
2754
|
+
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
2755
|
+
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
2756
|
+
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
2757
|
+
...passThrough
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2144
2760
|
let EnableLibraryPlugin_enabledTypes = new WeakMap(), EnableLibraryPlugin_getEnabledTypes = (compiler)=>{
|
|
2145
2761
|
let set = EnableLibraryPlugin_enabledTypes.get(compiler);
|
|
2146
2762
|
return void 0 === set && (set = new Set(), EnableLibraryPlugin_enabledTypes.set(compiler, set)), set;
|
|
@@ -2159,33 +2775,15 @@ class EnableLibraryPlugin extends RspackBuiltinPlugin {
|
|
|
2159
2775
|
}
|
|
2160
2776
|
raw(compiler) {
|
|
2161
2777
|
let type = this.type, enabled = EnableLibraryPlugin_getEnabledTypes(compiler);
|
|
2162
|
-
if (!enabled.has(type)) return enabled.add(type), createBuiltinPlugin(this.name,
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
function applyLimits(options) {
|
|
2167
|
-
options.optimization.concatenateModules = !1, options.optimization.removeEmptyChunks = !1, options.output.chunkFormat = !1, options.output.module = !0, options.output.chunkLoading && 'import' !== options.output.chunkLoading && (options.output.chunkLoading = 'import'), void 0 === options.output.chunkLoading && (options.output.chunkLoading = 'import');
|
|
2168
|
-
let { splitChunks } = options.optimization;
|
|
2169
|
-
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);
|
|
2170
|
-
}
|
|
2171
|
-
class EsmLibraryPlugin {
|
|
2172
|
-
static PLUGIN_NAME = 'EsmLibraryPlugin';
|
|
2173
|
-
options;
|
|
2174
|
-
constructor(options){
|
|
2175
|
-
this.options = options;
|
|
2176
|
-
}
|
|
2177
|
-
apply(compiler) {
|
|
2178
|
-
var config;
|
|
2179
|
-
let err;
|
|
2180
|
-
if (applyLimits(compiler.options), new RemoveDuplicateModulesPlugin().apply(compiler), err = (config = compiler.options).optimization.concatenateModules ? 'You should disable `config.optimization.concatenateModules`' : !1 !== config.output.chunkFormat ? (console.log(config.output.chunkFormat), 'You should disable default chunkFormat by `config.output.chunkFormat = false`') : void 0) throw new lib_WebpackError(`Conflicted config for ${EsmLibraryPlugin.PLUGIN_NAME}: ${err}`);
|
|
2181
|
-
compiler.__internal__registerBuiltinPlugin({
|
|
2182
|
-
name: binding_namespaceObject.BuiltinPluginName.EsmLibraryPlugin,
|
|
2183
|
-
options: {
|
|
2184
|
-
preserveModules: this.options?.preserveModules
|
|
2185
|
-
}
|
|
2778
|
+
if (!enabled.has(type)) return enabled.add(type), createBuiltinPlugin(this.name, {
|
|
2779
|
+
libraryType: type,
|
|
2780
|
+
preserveModules: compiler.options.output.library?.preserveModules,
|
|
2781
|
+
splitChunks: SplitChunksPlugin_toRawSplitChunksOptions(compiler.options.optimization.splitChunks ?? !1, compiler)
|
|
2186
2782
|
});
|
|
2187
2783
|
}
|
|
2188
2784
|
}
|
|
2785
|
+
let EnableWasmLoadingPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EnableWasmLoadingPlugin, (type)=>type), EnsureChunkConditionsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EnsureChunkConditionsPlugin, ()=>{}), RemoveDuplicateModulesPlugin_RemoveDuplicateModulesPlugin = base_create(binding_namespaceObject.BuiltinPluginName.RemoveDuplicateModulesPlugin, ()=>({}));
|
|
2786
|
+
base_create(binding_namespaceObject.BuiltinPluginName.EsmNodeTargetPlugin, ()=>void 0);
|
|
2189
2787
|
let EvalDevToolModulePlugin = base_create(binding_namespaceObject.BuiltinPluginName.EvalDevToolModulePlugin, (options)=>options, 'compilation'), EvalSourceMapDevToolPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EvalSourceMapDevToolPlugin, (options)=>options, 'compilation');
|
|
2190
2788
|
function isNil(value) {
|
|
2191
2789
|
return null == value;
|
|
@@ -2205,11 +2803,7 @@ function stringifyLoaderObject(o) {
|
|
|
2205
2803
|
let unsupported = (name, issue)=>{
|
|
2206
2804
|
let s = `${name} is not supported by Rspack.`;
|
|
2207
2805
|
throw issue && (s += ` Refer to issue ${issue} for more information.`), Error(s);
|
|
2208
|
-
}, warnedMessages = new Set()
|
|
2209
|
-
function deprecate(message) {
|
|
2210
|
-
warnedMessages.has(message) || (warnedMessages.add(message), console.warn(`[Rspack Deprecation] ${message}`));
|
|
2211
|
-
}
|
|
2212
|
-
let WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, relativePathToRequest = (relativePath)=>'' === relativePath ? './.' : '..' === relativePath ? '../.' : relativePath.startsWith('../') ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
|
|
2806
|
+
}, warnedMessages = new Set(), WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, relativePathToRequest = (relativePath)=>'' === relativePath ? './.' : '..' === relativePath ? '../.' : relativePath.startsWith('../') ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
|
|
2213
2807
|
if ('/' === maybeAbsolutePath[0]) {
|
|
2214
2808
|
if (maybeAbsolutePath.length > 1 && '/' === maybeAbsolutePath[maybeAbsolutePath.length - 1]) return maybeAbsolutePath;
|
|
2215
2809
|
let querySplitPos = maybeAbsolutePath.indexOf('?'), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
|
|
@@ -2290,6 +2884,11 @@ let WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])
|
|
|
2290
2884
|
query: match[2] ? match[2].replace(/\u200b(.)/g, '$1') : ''
|
|
2291
2885
|
};
|
|
2292
2886
|
});
|
|
2887
|
+
function isStatsColorSupported() {
|
|
2888
|
+
if ("u" < typeof process) return !1;
|
|
2889
|
+
let env = process.env ?? {}, argv = process.argv ?? [];
|
|
2890
|
+
return !('NO_COLOR' in env || argv.includes('--no-color')) && ('FORCE_COLOR' in env || argv.includes('--color') || 'win32' === process.platform || process.stdout?.isTTY && 'dumb' !== env.TERM || 'CI' in env);
|
|
2891
|
+
}
|
|
2293
2892
|
function encodeVersion(version) {
|
|
2294
2893
|
let [major, minor = 0, patch = 0] = version.split('-')[0].split('.').map((v)=>parseInt(v, 10));
|
|
2295
2894
|
return Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) ? null : major << 16 | minor << 8 | patch;
|
|
@@ -2398,11 +2997,24 @@ function toFeatures(featureOptions) {
|
|
|
2398
2997
|
}
|
|
2399
2998
|
return feature;
|
|
2400
2999
|
}
|
|
2401
|
-
function
|
|
2402
|
-
return {
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
3000
|
+
function resolvePluginImport(pluginImport) {
|
|
3001
|
+
if (pluginImport) return pluginImport.map((config)=>{
|
|
3002
|
+
let rawConfig = {
|
|
3003
|
+
...config,
|
|
3004
|
+
style: {}
|
|
3005
|
+
};
|
|
3006
|
+
if ('boolean' == typeof config.style) rawConfig.style.bool = config.style;
|
|
3007
|
+
else if ('string' == typeof config.style) {
|
|
3008
|
+
let isTpl = config.style.includes('{{');
|
|
3009
|
+
rawConfig.style[isTpl ? 'custom' : 'css'] = config.style;
|
|
3010
|
+
} else {
|
|
3011
|
+
var val;
|
|
3012
|
+
val = config.style, '[object Object]' === Object.prototype.toString.call(val) && (rawConfig.style = config.style);
|
|
3013
|
+
}
|
|
3014
|
+
return config.styleLibraryDirectory && (rawConfig.style = {
|
|
3015
|
+
styleLibraryDirectory: config.styleLibraryDirectory
|
|
3016
|
+
}), rawConfig;
|
|
3017
|
+
});
|
|
2406
3018
|
}
|
|
2407
3019
|
let $assets = Symbol('assets');
|
|
2408
3020
|
Object.defineProperty(binding_default().KnownBuildInfo.prototype, node_util.inspect.custom, {
|
|
@@ -2487,8 +3099,7 @@ Object.defineProperty(binding_default().NormalModule.prototype, 'identifier', {
|
|
|
2487
3099
|
value (filename, source, assetInfo) {
|
|
2488
3100
|
return this._emitFile(filename, SourceAdapter.toBinding(source), assetInfo);
|
|
2489
3101
|
}
|
|
2490
|
-
})
|
|
2491
|
-
Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
3102
|
+
}), Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
2492
3103
|
enumerable: !0,
|
|
2493
3104
|
configurable: !0,
|
|
2494
3105
|
value (compilation) {
|
|
@@ -2499,40 +3110,6 @@ Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
|
2499
3110
|
'loaderContext',
|
|
2500
3111
|
'module'
|
|
2501
3112
|
]),
|
|
2502
|
-
readResourceForScheme: new HookMap((scheme)=>{
|
|
2503
|
-
let fakeHook, message, code, hook = hooks.readResource.for(scheme);
|
|
2504
|
-
return fakeHook = {
|
|
2505
|
-
tap: (options, fn)=>hook.tap(options, (loaderContext)=>fn(loaderContext.resource)),
|
|
2506
|
-
tapAsync: (options, fn)=>hook.tapAsync(options, (loaderContext, callback)=>fn(loaderContext.resource, callback)),
|
|
2507
|
-
tapPromise: (options, fn)=>hook.tapPromise(options, (loaderContext)=>fn(loaderContext.resource))
|
|
2508
|
-
}, Object.freeze(Object.assign(message && code ? ((obj, message, code)=>{
|
|
2509
|
-
let newObj = {}, descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
2510
|
-
for (let name of Object.keys(descriptors)){
|
|
2511
|
-
let descriptor = descriptors[name];
|
|
2512
|
-
if ('function' == typeof descriptor.value) Object.defineProperty(newObj, name, {
|
|
2513
|
-
...descriptor,
|
|
2514
|
-
value: node_util.deprecate(descriptor.value, message, code)
|
|
2515
|
-
});
|
|
2516
|
-
else if (descriptor.get || descriptor.set) Object.defineProperty(newObj, name, {
|
|
2517
|
-
...descriptor,
|
|
2518
|
-
get: descriptor.get && node_util.deprecate(descriptor.get, message, code),
|
|
2519
|
-
set: descriptor.set && node_util.deprecate(descriptor.set, message, code)
|
|
2520
|
-
});
|
|
2521
|
-
else {
|
|
2522
|
-
let value = descriptor.value;
|
|
2523
|
-
Object.defineProperty(newObj, name, {
|
|
2524
|
-
configurable: descriptor.configurable,
|
|
2525
|
-
enumerable: descriptor.enumerable,
|
|
2526
|
-
get: node_util.deprecate(()=>value, message, code),
|
|
2527
|
-
set: descriptor.writable ? node_util.deprecate((v)=>value = v, message, code) : void 0
|
|
2528
|
-
});
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
return newObj;
|
|
2532
|
-
})(fakeHook, message, code) : fakeHook, {
|
|
2533
|
-
_fakeHook: !0
|
|
2534
|
-
}));
|
|
2535
|
-
}),
|
|
2536
3113
|
readResource: new HookMap(()=>new AsyncSeriesBailHook([
|
|
2537
3114
|
'loaderContext'
|
|
2538
3115
|
]))
|
|
@@ -2787,20 +3364,6 @@ class BulkUpdateDecorator extends Hash {
|
|
|
2787
3364
|
return void 0 !== digestCache && 'string' == typeof result && digestCache.set(buffer, result), result;
|
|
2788
3365
|
}
|
|
2789
3366
|
}
|
|
2790
|
-
class DebugHash extends Hash {
|
|
2791
|
-
string;
|
|
2792
|
-
constructor(){
|
|
2793
|
-
super(), this.string = '';
|
|
2794
|
-
}
|
|
2795
|
-
update(data) {
|
|
2796
|
-
let normalizedData;
|
|
2797
|
-
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;
|
|
2798
|
-
}
|
|
2799
|
-
digest(encoding) {
|
|
2800
|
-
let result = `debug-digest-${Buffer.from(this.string).toString('hex')}`;
|
|
2801
|
-
return encoding ? result : Buffer.from(result);
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
3367
|
class WasmHashAdapter extends Hash {
|
|
2805
3368
|
wasmHash;
|
|
2806
3369
|
constructor(wasmHash){
|
|
@@ -2816,8 +3379,6 @@ class WasmHashAdapter extends Hash {
|
|
|
2816
3379
|
let createHash_createHash = (algorithm)=>{
|
|
2817
3380
|
if ('function' == typeof algorithm) return new BulkUpdateDecorator(()=>new algorithm());
|
|
2818
3381
|
switch(algorithm){
|
|
2819
|
-
case 'debug':
|
|
2820
|
-
return new DebugHash();
|
|
2821
3382
|
case 'xxhash64':
|
|
2822
3383
|
return new WasmHashAdapter((()=>{
|
|
2823
3384
|
if (!createXxhash64) {
|
|
@@ -3623,6 +4184,7 @@ function createRawModuleRuleUses(uses, path, options) {
|
|
|
3623
4184
|
if (identifier.startsWith(`${BUILTIN_LOADER_PREFIX}swc-loader`)) return ((o, composeOptions)=>{
|
|
3624
4185
|
let options = o ?? {};
|
|
3625
4186
|
if ('object' == typeof options) {
|
|
4187
|
+
var options1;
|
|
3626
4188
|
if (options.jsc ??= {}, options.jsc.experimental ??= {}, options.jsc.experimental.disableAllLints ??= !0, options.env?.targets === void 0 && options.jsc?.target === void 0) {
|
|
3627
4189
|
if (composeOptions.compiler.target?.targets) options.env ??= {}, options.env.targets ??= function(targets) {
|
|
3628
4190
|
let REMAP = {
|
|
@@ -3649,27 +4211,12 @@ function createRawModuleRuleUses(uses, path, options) {
|
|
|
3649
4211
|
options.jsc.target ??= esVersion >= 2015 ? `es${esVersion}` : 'es5';
|
|
3650
4212
|
}
|
|
3651
4213
|
}
|
|
3652
|
-
options.collectTypeScriptInfo && (options.collectTypeScriptInfo =
|
|
4214
|
+
options.collectTypeScriptInfo && (options.collectTypeScriptInfo = {
|
|
4215
|
+
typeExports: (options1 = options.collectTypeScriptInfo).typeExports,
|
|
4216
|
+
exportedEnum: !0 === options1.exportedEnum ? 'all' : !1 === options1.exportedEnum || void 0 === options1.exportedEnum ? 'none' : 'const-only'
|
|
4217
|
+
}), options.transformImport && (options.transformImport = resolvePluginImport(options.transformImport));
|
|
3653
4218
|
let { rspackExperiments } = options;
|
|
3654
|
-
rspackExperiments && (
|
|
3655
|
-
if (pluginImport) return pluginImport.map((config)=>{
|
|
3656
|
-
let rawConfig = {
|
|
3657
|
-
...config,
|
|
3658
|
-
style: {}
|
|
3659
|
-
};
|
|
3660
|
-
if ('boolean' == typeof config.style) rawConfig.style.bool = config.style;
|
|
3661
|
-
else if ('string' == typeof config.style) {
|
|
3662
|
-
let isTpl = config.style.includes('{{');
|
|
3663
|
-
rawConfig.style[isTpl ? 'custom' : 'css'] = config.style;
|
|
3664
|
-
} else {
|
|
3665
|
-
var val;
|
|
3666
|
-
val = config.style, '[object Object]' === Object.prototype.toString.call(val) && (rawConfig.style = config.style);
|
|
3667
|
-
}
|
|
3668
|
-
return config.styleLibraryDirectory && (rawConfig.style = {
|
|
3669
|
-
styleLibraryDirectory: config.styleLibraryDirectory
|
|
3670
|
-
}), rawConfig;
|
|
3671
|
-
});
|
|
3672
|
-
}(rspackExperiments.import || rspackExperiments.pluginImport)), rspackExperiments.collectTypeScriptInfo && (deprecate('`rspackExperiments.collectTypeScriptInfo` is deprecated and will be removed in Rspack v2.0. Use top-level `collectTypeScriptInfo` instead.'), options.collectTypeScriptInfo || (options.collectTypeScriptInfo = resolveCollectTypeScriptInfo(rspackExperiments.collectTypeScriptInfo)), delete rspackExperiments.collectTypeScriptInfo));
|
|
4219
|
+
rspackExperiments && (rspackExperiments.import || rspackExperiments.pluginImport) && (rspackExperiments.import = resolvePluginImport(rspackExperiments.import || rspackExperiments.pluginImport));
|
|
3673
4220
|
}
|
|
3674
4221
|
return options;
|
|
3675
4222
|
})(o, options);
|
|
@@ -3897,16 +4444,16 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3897
4444
|
dynamicImportPreload: parser.dynamicImportPreload?.toString(),
|
|
3898
4445
|
dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString(),
|
|
3899
4446
|
dynamicImportFetchPriority: parser.dynamicImportFetchPriority,
|
|
3900
|
-
importMeta: parser.importMeta,
|
|
4447
|
+
importMeta: 'boolean' == typeof parser.importMeta ? String(parser.importMeta) : parser.importMeta,
|
|
3901
4448
|
url: parser.url?.toString(),
|
|
3902
4449
|
exprContextCritical: parser.exprContextCritical,
|
|
3903
4450
|
unknownContextCritical: parser.unknownContextCritical,
|
|
3904
4451
|
wrappedContextCritical: parser.wrappedContextCritical,
|
|
4452
|
+
strictThisContextOnImports: parser.strictThisContextOnImports,
|
|
3905
4453
|
wrappedContextRegExp: parser.wrappedContextRegExp,
|
|
3906
4454
|
exportsPresence: !1 === parser.exportsPresence ? 'false' : parser.exportsPresence,
|
|
3907
4455
|
importExportsPresence: !1 === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
|
|
3908
4456
|
reexportExportsPresence: !1 === parser.reexportExportsPresence ? 'false' : parser.reexportExportsPresence,
|
|
3909
|
-
strictExportPresence: parser.strictExportPresence,
|
|
3910
4457
|
worker: 'boolean' == typeof parser.worker ? parser.worker ? [
|
|
3911
4458
|
'...'
|
|
3912
4459
|
] : [] : parser.worker,
|
|
@@ -3920,13 +4467,15 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3920
4467
|
commonjsMagicComments: parser.commonjsMagicComments,
|
|
3921
4468
|
typeReexportsPresence: parser.typeReexportsPresence,
|
|
3922
4469
|
jsx: parser.jsx,
|
|
3923
|
-
deferImport: parser.deferImport
|
|
4470
|
+
deferImport: parser.deferImport,
|
|
4471
|
+
importMetaResolve: parser.importMetaResolve
|
|
3924
4472
|
};
|
|
3925
4473
|
}
|
|
3926
4474
|
function getRawCssParserOptions(parser) {
|
|
3927
4475
|
return {
|
|
3928
4476
|
namedExports: parser.namedExports,
|
|
3929
|
-
url: parser.url
|
|
4477
|
+
url: parser.url,
|
|
4478
|
+
resolveImport: parser.resolveImport
|
|
3930
4479
|
};
|
|
3931
4480
|
}
|
|
3932
4481
|
function getRawGeneratorOptions(generator, type) {
|
|
@@ -4380,7 +4929,7 @@ let JsLoaderRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName
|
|
|
4380
4929
|
test,
|
|
4381
4930
|
client,
|
|
4382
4931
|
currentActiveModules
|
|
4383
|
-
}), 'thisCompilation'), middleware_require = createRequire(import.meta.url), LAZY_COMPILATION_PREFIX = '/lazy
|
|
4932
|
+
}), 'thisCompilation'), middleware_require = createRequire(import.meta.url), LAZY_COMPILATION_PREFIX = '/_rspack/lazy/trigger', noop = (_req, _res, next)=>{
|
|
4384
4933
|
'function' == typeof next && next();
|
|
4385
4934
|
}, lazyCompilationMiddleware = (compiler)=>{
|
|
4386
4935
|
if (compiler instanceof MultiCompiler) {
|
|
@@ -4450,7 +4999,7 @@ let lazyCompilationMiddlewareInternal = (compiler, activeModules, lazyCompilatio
|
|
|
4450
4999
|
});
|
|
4451
5000
|
}(req);
|
|
4452
5001
|
} catch (err) {
|
|
4453
|
-
logger.error(
|
|
5002
|
+
logger.error(`Failed to parse request body: ${err}`), res.writeHead(400), res.end('Bad Request');
|
|
4454
5003
|
return;
|
|
4455
5004
|
}
|
|
4456
5005
|
let moduleActivated = [];
|
|
@@ -4501,8 +5050,8 @@ let NodeTargetPlugin = base_create(binding_namespaceObject.BuiltinPluginName.Nod
|
|
|
4501
5050
|
})), OccurrenceChunkIdsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.OccurrenceChunkIdsPlugin, (options)=>({
|
|
4502
5051
|
...options
|
|
4503
5052
|
}), 'compilation'), ProgressPlugin = base_create(binding_namespaceObject.BuiltinPluginName.ProgressPlugin, (progress = {})=>'function' == typeof progress ? {
|
|
4504
|
-
handler: (percentage, msg,
|
|
4505
|
-
progress(percentage, msg,
|
|
5053
|
+
handler: (percentage, msg, info)=>{
|
|
5054
|
+
progress(percentage, msg, info);
|
|
4506
5055
|
}
|
|
4507
5056
|
} : progress), ProvidePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ProvidePlugin, (provide)=>Object.fromEntries(Object.entries(provide).map(([key, value])=>('string' == typeof value && (value = [
|
|
4508
5057
|
value
|
|
@@ -4563,82 +5112,77 @@ RuntimePlugin.getCompilationHooks = (compilation)=>{
|
|
|
4563
5112
|
])
|
|
4564
5113
|
}, RuntimePlugin_compilationHooksMap.set(compilation, hooks)), hooks;
|
|
4565
5114
|
};
|
|
5115
|
+
let Coordinator_PLUGIN_NAME = 'RscPlugin', GET_OR_INIT_BINDING = Symbol('GET_OR_INIT_BINDING');
|
|
5116
|
+
class Coordinator {
|
|
5117
|
+
#serverCompiler;
|
|
5118
|
+
#clientCompiler;
|
|
5119
|
+
#clientLastCompilation;
|
|
5120
|
+
#isProxyingClientWatching = !1;
|
|
5121
|
+
#binding;
|
|
5122
|
+
constructor(){
|
|
5123
|
+
Object.defineProperty(this, GET_OR_INIT_BINDING, {
|
|
5124
|
+
enumerable: !1,
|
|
5125
|
+
configurable: !1,
|
|
5126
|
+
writable: !1,
|
|
5127
|
+
value: ()=>(this.#binding || (this.#binding = new binding_namespaceObject.JsCoordinator(()=>{
|
|
5128
|
+
if (!this.#serverCompiler) throw Error("[RscPlugin] Coordinator.getOrInitBinding() called before the server compiler was attached. Call coordinator.applyServerCompiler(serverCompiler) first.");
|
|
5129
|
+
return this.#serverCompiler[GET_COMPILER_ID]();
|
|
5130
|
+
})), this.#binding)
|
|
5131
|
+
});
|
|
5132
|
+
}
|
|
5133
|
+
applyServerCompiler(serverCompiler) {
|
|
5134
|
+
this.#serverCompiler = serverCompiler, serverCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
|
|
5135
|
+
this.#isProxyingClientWatching = !0, this.#clientLastCompilation && (stats.compilation.fileDependencies.addAll(this.#clientLastCompilation.fileDependencies), stats.compilation.contextDependencies.addAll(this.#clientLastCompilation.contextDependencies), stats.compilation.missingDependencies.addAll(this.#clientLastCompilation.missingDependencies));
|
|
5136
|
+
}), serverCompiler.hooks.watchRun.tap(Coordinator_PLUGIN_NAME, ()=>{
|
|
5137
|
+
this.#isProxyingClientWatching && this.#clientCompiler.watching.invalidateWithChangesAndRemovals(new Set(this.#serverCompiler.modifiedFiles), new Set(this.#serverCompiler.removedFiles));
|
|
5138
|
+
});
|
|
5139
|
+
}
|
|
5140
|
+
applyClientCompiler(clientCompiler) {
|
|
5141
|
+
this.#clientCompiler = clientCompiler;
|
|
5142
|
+
let originalWatch = clientCompiler.watch;
|
|
5143
|
+
clientCompiler.watch = function(watchOptions, handler) {
|
|
5144
|
+
return watchOptions.ignored = ()=>!0, originalWatch.call(this, watchOptions, handler);
|
|
5145
|
+
}, clientCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
|
|
5146
|
+
this.#clientLastCompilation = stats.compilation;
|
|
5147
|
+
});
|
|
5148
|
+
}
|
|
5149
|
+
}
|
|
5150
|
+
class RscClientPlugin extends RspackBuiltinPlugin {
|
|
5151
|
+
name = 'RscClientPlugin';
|
|
5152
|
+
#options;
|
|
5153
|
+
constructor(options){
|
|
5154
|
+
super(), this.#options = options;
|
|
5155
|
+
}
|
|
5156
|
+
raw(compiler) {
|
|
5157
|
+
return this.#options.coordinator.applyClientCompiler(compiler), createBuiltinPlugin(this.name, {
|
|
5158
|
+
coordinator: this.#options.coordinator[GET_OR_INIT_BINDING]()
|
|
5159
|
+
});
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
class RscServerPlugin extends RspackBuiltinPlugin {
|
|
5163
|
+
name = 'RscServerPlugin';
|
|
5164
|
+
#options;
|
|
5165
|
+
constructor(options){
|
|
5166
|
+
super(), this.#options = options;
|
|
5167
|
+
}
|
|
5168
|
+
raw(compiler) {
|
|
5169
|
+
let onManifest;
|
|
5170
|
+
this.#options.coordinator.applyServerCompiler(compiler);
|
|
5171
|
+
let { coordinator, onServerComponentChanges } = this.#options;
|
|
5172
|
+
return this.#options.onManifest && (onManifest = (json)=>Promise.resolve(this.#options.onManifest(JSON.parse(json)))), createBuiltinPlugin(this.name, {
|
|
5173
|
+
coordinator: coordinator[GET_OR_INIT_BINDING](),
|
|
5174
|
+
onServerComponentChanges,
|
|
5175
|
+
onManifest
|
|
5176
|
+
});
|
|
5177
|
+
}
|
|
5178
|
+
}
|
|
4566
5179
|
let SideEffectsFlagPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SideEffectsFlagPlugin, ()=>{}, 'compilation'), SizeLimitsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SizeLimitsPlugin, (options)=>{
|
|
4567
5180
|
let hints = !1 === options.hints ? void 0 : options.hints;
|
|
4568
5181
|
return {
|
|
4569
5182
|
...options,
|
|
4570
5183
|
hints
|
|
4571
5184
|
};
|
|
4572
|
-
}), SourceMapDevToolPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SourceMapDevToolPlugin, (options)=>options, 'compilation')
|
|
4573
|
-
class JsSplitChunkSizes {
|
|
4574
|
-
static __to_binding(sizes) {
|
|
4575
|
-
return 'number' == typeof sizes ? sizes : sizes && 'object' == typeof sizes ? {
|
|
4576
|
-
sizes: sizes
|
|
4577
|
-
} : sizes;
|
|
4578
|
-
}
|
|
4579
|
-
}
|
|
4580
|
-
class SplitChunksPlugin extends RspackBuiltinPlugin {
|
|
4581
|
-
options;
|
|
4582
|
-
name = binding_namespaceObject.BuiltinPluginName.SplitChunksPlugin;
|
|
4583
|
-
affectedHooks = 'thisCompilation';
|
|
4584
|
-
constructor(options){
|
|
4585
|
-
super(), this.options = options;
|
|
4586
|
-
}
|
|
4587
|
-
raw(compiler) {
|
|
4588
|
-
let rawOptions = function(sc, compiler) {
|
|
4589
|
-
if (!sc) return;
|
|
4590
|
-
function getName(name) {
|
|
4591
|
-
return 'function' == typeof name ? (ctx)=>void 0 === ctx.module ? name(void 0) : name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey) : name;
|
|
4592
|
-
}
|
|
4593
|
-
function getChunks(chunks) {
|
|
4594
|
-
return 'function' == typeof chunks ? (chunk)=>chunks(chunk) : chunks;
|
|
4595
|
-
}
|
|
4596
|
-
let { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
|
|
4597
|
-
return {
|
|
4598
|
-
name: getName(name),
|
|
4599
|
-
chunks: getChunks(chunks),
|
|
4600
|
-
defaultSizeTypes: defaultSizeTypes || [
|
|
4601
|
-
"javascript",
|
|
4602
|
-
'unknown'
|
|
4603
|
-
],
|
|
4604
|
-
cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>!1 !== group).map(([key, group])=>{
|
|
4605
|
-
let { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
|
|
4606
|
-
return {
|
|
4607
|
-
key,
|
|
4608
|
-
test: 'function' == typeof test ? (ctx)=>{
|
|
4609
|
-
let info = {
|
|
4610
|
-
moduleGraph: compiler._lastCompilation.moduleGraph,
|
|
4611
|
-
chunkGraph: compiler._lastCompilation.chunkGraph
|
|
4612
|
-
};
|
|
4613
|
-
return test(ctx.module, info);
|
|
4614
|
-
} : test,
|
|
4615
|
-
name: getName(name),
|
|
4616
|
-
chunks: getChunks(chunks),
|
|
4617
|
-
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
4618
|
-
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
4619
|
-
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
4620
|
-
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
4621
|
-
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
4622
|
-
...passThrough
|
|
4623
|
-
};
|
|
4624
|
-
}),
|
|
4625
|
-
fallbackCacheGroup: {
|
|
4626
|
-
chunks: getChunks(chunks),
|
|
4627
|
-
...fallbackCacheGroup
|
|
4628
|
-
},
|
|
4629
|
-
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
4630
|
-
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
4631
|
-
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
4632
|
-
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
4633
|
-
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
4634
|
-
...passThrough
|
|
4635
|
-
};
|
|
4636
|
-
}(this.options, compiler);
|
|
4637
|
-
if (void 0 === rawOptions) throw Error('rawOptions should not be undefined');
|
|
4638
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
4639
|
-
}
|
|
4640
|
-
}
|
|
4641
|
-
let SubresourceIntegrityPlugin_require = createRequire(import.meta.url), SubresourceIntegrityPlugin_PLUGIN_NAME = 'SubresourceIntegrityPlugin', NATIVE_HTML_PLUGIN = 'HtmlRspackPlugin', HTTP_PROTOCOL_REGEX = /^https?:/, NativeSubresourceIntegrityPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
|
|
5185
|
+
}), SourceMapDevToolPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SourceMapDevToolPlugin, (options)=>options, 'compilation'), SubresourceIntegrityPlugin_require = createRequire(import.meta.url), SubresourceIntegrityPlugin_PLUGIN_NAME = 'SubresourceIntegrityPlugin', NATIVE_HTML_PLUGIN = 'HtmlRspackPlugin', HTTP_PROTOCOL_REGEX = /^https?:/, NativeSubresourceIntegrityPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
|
|
4642
5186
|
let htmlPlugin = 'Disabled';
|
|
4643
5187
|
return options.htmlPlugin === NATIVE_HTML_PLUGIN ? htmlPlugin = 'Native' : 'string' == typeof options.htmlPlugin && (htmlPlugin = 'JavaScript'), {
|
|
4644
5188
|
hashFuncNames: options.hashFuncNames,
|
|
@@ -4708,13 +5252,11 @@ class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
|
|
|
4708
5252
|
}
|
|
4709
5253
|
let src = '';
|
|
4710
5254
|
if (isUrlSrc) {
|
|
4711
|
-
if (!publicPath) return;
|
|
5255
|
+
if (!publicPath || '/' === publicPath || './' === publicPath) return;
|
|
4712
5256
|
let protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, ''), protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, '');
|
|
4713
5257
|
if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
|
|
4714
|
-
{
|
|
4715
|
-
|
|
4716
|
-
src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
|
|
4717
|
-
}
|
|
5258
|
+
let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
|
|
5259
|
+
src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
|
|
4718
5260
|
} else src = relative(publicPath, decodeURIComponent(tagSrc));
|
|
4719
5261
|
tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || function(hashFuncNames, source) {
|
|
4720
5262
|
let { createHash } = SubresourceIntegrityPlugin_require('node:crypto');
|
|
@@ -4778,23 +5320,37 @@ let SwcJsMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPlug
|
|
|
4778
5320
|
exclude: options?.exclude,
|
|
4779
5321
|
extractComments: function(extractComments) {
|
|
4780
5322
|
let type, conditionStr = (condition)=>{
|
|
4781
|
-
if (void 0 === condition || !0 === condition) return
|
|
5323
|
+
if (void 0 === condition || !0 === condition) return {
|
|
5324
|
+
source: '@preserve|@lic|@cc_on|^\\**!',
|
|
5325
|
+
flags: ''
|
|
5326
|
+
};
|
|
4782
5327
|
if (!1 === condition) throw Error('unreachable');
|
|
4783
|
-
return
|
|
5328
|
+
return {
|
|
5329
|
+
source: condition.source,
|
|
5330
|
+
flags: condition.flags
|
|
5331
|
+
};
|
|
4784
5332
|
};
|
|
4785
5333
|
if ('boolean' == typeof extractComments) {
|
|
4786
5334
|
if (!extractComments) return;
|
|
5335
|
+
let { source, flags } = conditionStr(extractComments);
|
|
4787
5336
|
return {
|
|
4788
|
-
condition:
|
|
5337
|
+
condition: source,
|
|
5338
|
+
conditionFlags: flags
|
|
5339
|
+
};
|
|
5340
|
+
}
|
|
5341
|
+
if (extractComments instanceof RegExp) {
|
|
5342
|
+
let { source, flags } = conditionStr(extractComments);
|
|
5343
|
+
return {
|
|
5344
|
+
condition: source,
|
|
5345
|
+
conditionFlags: flags
|
|
4789
5346
|
};
|
|
4790
5347
|
}
|
|
4791
|
-
if (extractComments instanceof RegExp) return {
|
|
4792
|
-
condition: extractComments.source
|
|
4793
|
-
};
|
|
4794
5348
|
if (type = typeof extractComments, null != extractComments && ('object' === type || 'function' === type)) {
|
|
4795
5349
|
if (!1 === extractComments.condition) return;
|
|
5350
|
+
let { source, flags } = conditionStr(extractComments.condition);
|
|
4796
5351
|
return {
|
|
4797
|
-
condition:
|
|
5352
|
+
condition: source,
|
|
5353
|
+
conditionFlags: flags,
|
|
4798
5354
|
banner: extractComments.banner
|
|
4799
5355
|
};
|
|
4800
5356
|
}
|
|
@@ -4821,6 +5377,7 @@ class WorkerPlugin extends RspackBuiltinPlugin {
|
|
|
4821
5377
|
module;
|
|
4822
5378
|
workerPublicPath;
|
|
4823
5379
|
name = binding_namespaceObject.BuiltinPluginName.WorkerPlugin;
|
|
5380
|
+
affectedHooks = 'compilation';
|
|
4824
5381
|
constructor(chunkLoading, wasmLoading, module, workerPublicPath){
|
|
4825
5382
|
super(), this.chunkLoading = chunkLoading, this.wasmLoading = wasmLoading, this.module = module, this.workerPublicPath = workerPublicPath;
|
|
4826
5383
|
}
|
|
@@ -4841,7 +5398,7 @@ class ContextModuleFactory {
|
|
|
4841
5398
|
};
|
|
4842
5399
|
}
|
|
4843
5400
|
}
|
|
4844
|
-
let FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g, INDENT_MULTILINE_REGEX = /^\t/gm, LINE_SEPARATOR_REGEX = /\r?\n/g, IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/, IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g, COMMENT_END_REGEX = /\*\//g, PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g, MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|
5401
|
+
let FUNCTION_CONTENT_REGEX = /^function(?:\s+[\w$]+)?\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g, INDENT_MULTILINE_REGEX = /^\t/gm, LINE_SEPARATOR_REGEX = /\r?\n/g, IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/, IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g, COMMENT_END_REGEX = /\*\//g, PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g, MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|
4845
5402
|
class Template {
|
|
4846
5403
|
static getFunctionContent(fn) {
|
|
4847
5404
|
return fn.toString().replace(FUNCTION_CONTENT_REGEX, '').replace(INDENT_MULTILINE_REGEX, '').replace(LINE_SEPARATOR_REGEX, '\n');
|
|
@@ -5949,23 +6506,22 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5949
6506
|
if ('function' != typeof options.entry) for (let key of Object.keys(options.entry))F(options.entry[key], 'import', ()=>[
|
|
5950
6507
|
'./src'
|
|
5951
6508
|
]);
|
|
5952
|
-
return F(options, 'devtool', ()=>!!development && '
|
|
6509
|
+
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, {
|
|
5953
6510
|
production,
|
|
5954
6511
|
development
|
|
5955
6512
|
}), applySnapshotDefaults(options.snapshot, {
|
|
5956
6513
|
production
|
|
5957
6514
|
}), applyModuleDefaults(options.module, {
|
|
5958
|
-
cache: !!options.cache,
|
|
5959
6515
|
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
|
5960
6516
|
targetProperties,
|
|
5961
6517
|
mode: options.mode,
|
|
5962
6518
|
uniqueName: options.output.uniqueName,
|
|
5963
|
-
deferImport: options.experiments.deferImport
|
|
6519
|
+
deferImport: options.experiments.deferImport,
|
|
6520
|
+
outputModule: options.output.module
|
|
5964
6521
|
}), applyOutputDefaults(options, {
|
|
5965
6522
|
context: options.context,
|
|
5966
6523
|
targetProperties,
|
|
5967
6524
|
isAffectedByBrowserslist: void 0 === target || 'string' == typeof target && target.startsWith('browserslist') || Array.isArray(target) && target.some((target)=>target.startsWith('browserslist')),
|
|
5968
|
-
outputModule: options.experiments.outputModule,
|
|
5969
6525
|
entry: options.entry
|
|
5970
6526
|
}), applyExternalsPresetsDefaults(options.externalsPresets, {
|
|
5971
6527
|
targetProperties,
|
|
@@ -5980,7 +6536,6 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5980
6536
|
}), F(options, 'performance', ()=>!!production && !!targetProperties && (!!targetProperties.browser || null === targetProperties.browser) && {}), applyPerformanceDefaults(options.performance, {
|
|
5981
6537
|
production
|
|
5982
6538
|
}), options.resolve = cleverMerge(getResolveDefaults({
|
|
5983
|
-
context: options.context,
|
|
5984
6539
|
targetProperties,
|
|
5985
6540
|
mode: options.mode
|
|
5986
6541
|
}), options.resolve), options.resolveLoader = cleverMerge(getResolveLoaderDefaults(), options.resolveLoader), !1 === targetProperties ? targetProperties : {
|
|
@@ -5996,16 +6551,19 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5996
6551
|
targets: targetProperties.targets
|
|
5997
6552
|
};
|
|
5998
6553
|
}, applyExperimentsDefaults = (experiments)=>{
|
|
5999
|
-
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, '
|
|
6554
|
+
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);
|
|
6555
|
+
}, applyIncrementalDefaults = (options)=>{
|
|
6556
|
+
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, 'optimizeChunkModules', !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));
|
|
6000
6557
|
}, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
|
|
6001
6558
|
D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
|
|
6002
|
-
}, applyModuleDefaults = (module, {
|
|
6003
|
-
assertNotNill(module.parser), assertNotNill(module.generator),
|
|
6004
|
-
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, '
|
|
6559
|
+
}, applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport, outputModule })=>{
|
|
6560
|
+
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, outputModule })=>{
|
|
6561
|
+
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, 'strictThisContextOnImports', !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', [
|
|
6005
6562
|
'...'
|
|
6006
|
-
]), D(parserOptions, 'importMeta', !
|
|
6563
|
+
]), D(parserOptions, 'importMeta', !outputModule || 'preserve-unknown'), D(parserOptions, 'typeReexportsPresence', 'no-tolerant'), D(parserOptions, 'jsx', !1), D(parserOptions, 'deferImport', deferImport), D(parserOptions, 'importMetaResolve', !1);
|
|
6007
6564
|
})(module.parser.javascript, {
|
|
6008
|
-
deferImport
|
|
6565
|
+
deferImport,
|
|
6566
|
+
outputModule
|
|
6009
6567
|
}), F(module.parser, "json", ()=>({})), assertNotNill(module.parser.json), D(module.parser.json, 'exportsDepth', 'development' === mode ? 1 : Number.MAX_SAFE_INTEGER), F(module.generator, 'json', ()=>({})), assertNotNill(module.generator.json), D(module.generator.json, 'JSONParse', !0), F(module.parser, 'css', ()=>({})), assertNotNill(module.parser.css), D(module.parser.css, 'namedExports', !0), D(module.parser.css, 'url', !0), F(module.parser, 'css/auto', ()=>({})), assertNotNill(module.parser['css/auto']), D(module.parser['css/auto'], 'namedExports', !0), D(module.parser['css/auto'], 'url', !0), F(module.parser, 'css/module', ()=>({})), assertNotNill(module.parser['css/module']), D(module.parser['css/module'], 'namedExports', !0), D(module.parser['css/module'], 'url', !0), F(module.generator, 'css', ()=>({})), assertNotNill(module.generator.css), applyCssGeneratorOptionsDefaults(module.generator.css, {
|
|
6010
6568
|
targetProperties
|
|
6011
6569
|
}), F(module.generator, 'css/auto', ()=>({})), assertNotNill(module.generator['css/auto']), applyCssGeneratorOptionsDefaults(module.generator['css/auto'], {
|
|
@@ -6032,7 +6590,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6032
6590
|
type: "javascript/auto"
|
|
6033
6591
|
},
|
|
6034
6592
|
{
|
|
6035
|
-
test: /\.json
|
|
6593
|
+
test: /\.json$/,
|
|
6036
6594
|
type: 'json'
|
|
6037
6595
|
},
|
|
6038
6596
|
{
|
|
@@ -6040,22 +6598,22 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6040
6598
|
type: 'json'
|
|
6041
6599
|
},
|
|
6042
6600
|
{
|
|
6043
|
-
test: /\.mjs
|
|
6601
|
+
test: /\.mjs$/,
|
|
6044
6602
|
...esm
|
|
6045
6603
|
},
|
|
6046
6604
|
{
|
|
6047
|
-
test: /\.js
|
|
6605
|
+
test: /\.js$/,
|
|
6048
6606
|
descriptionData: {
|
|
6049
6607
|
type: 'module'
|
|
6050
6608
|
},
|
|
6051
6609
|
...esm
|
|
6052
6610
|
},
|
|
6053
6611
|
{
|
|
6054
|
-
test: /\.cjs
|
|
6612
|
+
test: /\.cjs$/,
|
|
6055
6613
|
...commonjs
|
|
6056
6614
|
},
|
|
6057
6615
|
{
|
|
6058
|
-
test: /\.js
|
|
6616
|
+
test: /\.js$/,
|
|
6059
6617
|
descriptionData: {
|
|
6060
6618
|
type: 'commonjs'
|
|
6061
6619
|
},
|
|
@@ -6086,7 +6644,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6086
6644
|
]
|
|
6087
6645
|
};
|
|
6088
6646
|
rules.push({
|
|
6089
|
-
test: /\.wasm
|
|
6647
|
+
test: /\.wasm$/,
|
|
6090
6648
|
...wasm
|
|
6091
6649
|
}), rules.push({
|
|
6092
6650
|
mimetype: 'application/wasm',
|
|
@@ -6121,7 +6679,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6121
6679
|
type: 'asset/bytes'
|
|
6122
6680
|
}), rules;
|
|
6123
6681
|
});
|
|
6124
|
-
}, applyOutputDefaults = (options, { context,
|
|
6682
|
+
}, applyOutputDefaults = (options, { context, targetProperties: tp, isAffectedByBrowserslist, entry })=>{
|
|
6125
6683
|
let { output } = options, getLibraryName = (library)=>{
|
|
6126
6684
|
let libraryName = 'object' == typeof library && library && !Array.isArray(library) ? library.name : library;
|
|
6127
6685
|
return Array.isArray(libraryName) ? libraryName.join('.') : 'object' == typeof libraryName ? getLibraryName(libraryName.root) : 'string' == typeof libraryName ? libraryName : '';
|
|
@@ -6139,7 +6697,23 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6139
6697
|
if ('ENOENT' !== err.code) throw err.message += `\nwhile determining default 'output.uniqueName' from 'name' in ${pkgPath}`, err;
|
|
6140
6698
|
return '';
|
|
6141
6699
|
}
|
|
6142
|
-
}), F(output, 'devtoolNamespace', ()=>output.uniqueName), F(output, '
|
|
6700
|
+
}), F(output, 'devtoolNamespace', ()=>output.uniqueName), output.library && F(output.library, 'type', ()=>output.module ? 'modern-module' : 'var');
|
|
6701
|
+
let forEachEntry = (fn)=>{
|
|
6702
|
+
if ('function' != typeof entry) for (let name of Object.keys(entry))fn(entry[name]);
|
|
6703
|
+
};
|
|
6704
|
+
A(output, 'enabledLibraryTypes', ()=>{
|
|
6705
|
+
let enabledLibraryTypes = [];
|
|
6706
|
+
return output.library && enabledLibraryTypes.push(output.library.type), forEachEntry((desc)=>{
|
|
6707
|
+
desc.library && enabledLibraryTypes.push(desc.library.type);
|
|
6708
|
+
}), enabledLibraryTypes.includes('modern-module') && function(options) {
|
|
6709
|
+
options.optimization.concatenateModules = !1, options.optimization.removeEmptyChunks = !1, options.output.chunkFormat = !1, options.output.module = !0, options.output.chunkLoading && 'import' !== options.output.chunkLoading && (options.output.chunkLoading = 'import'), void 0 === options.output.chunkLoading && (options.output.chunkLoading = 'import');
|
|
6710
|
+
let { splitChunks } = options.optimization;
|
|
6711
|
+
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);
|
|
6712
|
+
}(options), enabledLibraryTypes;
|
|
6713
|
+
}), D(output, 'module', [
|
|
6714
|
+
'modern-module',
|
|
6715
|
+
'module'
|
|
6716
|
+
].some((ty)=>output.enabledLibraryTypes.includes(ty)));
|
|
6143
6717
|
let environment = output.environment, conditionallyOptimistic = (v, c)=>void 0 === v && c || v;
|
|
6144
6718
|
F(environment, 'globalThis', ()=>tp && tp.globalThis), F(environment, 'bigIntLiteral', ()=>{
|
|
6145
6719
|
let v;
|
|
@@ -6189,7 +6763,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6189
6763
|
return 'function' != typeof chunkFilename ? chunkFilename.replace(/\.[mc]?js(\?|$)/, '.css$1') : '[id].css';
|
|
6190
6764
|
}), D(output, 'hotUpdateChunkFilename', `[id].[fullhash].hot-update.${output.module ? 'mjs' : 'js'}`), F(output, 'hotUpdateMainFilename', ()=>`[runtime].[fullhash].hot-update.${output.module ? 'json.mjs' : 'json'}`);
|
|
6191
6765
|
let uniqueNameId = Template.toIdentifier(output.uniqueName);
|
|
6192
|
-
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),
|
|
6766
|
+
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', ()=>{
|
|
6193
6767
|
if (tp) {
|
|
6194
6768
|
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.";
|
|
6195
6769
|
if (output.module) {
|
|
@@ -6251,16 +6825,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6251
6825
|
return 'self';
|
|
6252
6826
|
}), 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);
|
|
6253
6827
|
let { trustedTypes } = output;
|
|
6254
|
-
trustedTypes && (F(trustedTypes, 'policyName', ()=>output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, '_') || '
|
|
6255
|
-
let forEachEntry = (fn)=>{
|
|
6256
|
-
if ('function' != typeof entry) for (let name of Object.keys(entry))fn(entry[name]);
|
|
6257
|
-
};
|
|
6258
|
-
A(output, 'enabledLibraryTypes', ()=>{
|
|
6259
|
-
let enabledLibraryTypes = [];
|
|
6260
|
-
return output.library && enabledLibraryTypes.push(output.library.type), forEachEntry((desc)=>{
|
|
6261
|
-
desc.library && enabledLibraryTypes.push(desc.library.type);
|
|
6262
|
-
}), enabledLibraryTypes.includes('modern-module') && applyLimits(options), enabledLibraryTypes;
|
|
6263
|
-
}), A(output, 'enabledChunkLoadingTypes', ()=>{
|
|
6828
|
+
trustedTypes && (F(trustedTypes, 'policyName', ()=>output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, '_') || 'rspack'), D(trustedTypes, 'onPolicyCreationFailure', 'stop')), A(output, 'enabledChunkLoadingTypes', ()=>{
|
|
6264
6829
|
let enabledChunkLoadingTypes = new Set();
|
|
6265
6830
|
return output.chunkLoading && enabledChunkLoadingTypes.add(output.chunkLoading), output.workerChunkLoading && enabledChunkLoadingTypes.add(output.workerChunkLoading), forEachEntry((desc)=>{
|
|
6266
6831
|
desc.chunkLoading && enabledChunkLoadingTypes.add(desc.chunkLoading);
|
|
@@ -6270,7 +6835,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6270
6835
|
return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
|
|
6271
6836
|
desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
|
|
6272
6837
|
}), Array.from(enabledWasmLoadingTypes);
|
|
6273
|
-
}), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-
|
|
6838
|
+
}), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-rc.0"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
|
|
6274
6839
|
}, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
|
|
6275
6840
|
let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
|
|
6276
6841
|
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')));
|
|
@@ -6288,7 +6853,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6288
6853
|
}, applyPerformanceDefaults = (performance, { production })=>{
|
|
6289
6854
|
!1 !== performance && (D(performance, 'maxAssetSize', 250000), D(performance, 'maxEntrypointSize', 250000), F(performance, 'hints', ()=>!!production && 'warning'));
|
|
6290
6855
|
}, applyOptimizationDefaults = (optimization, { production, development })=>{
|
|
6291
|
-
D(optimization, '
|
|
6856
|
+
D(optimization, 'removeEmptyChunks', !0), D(optimization, 'mergeDuplicateChunks', !0), F(optimization, 'moduleIds', ()=>production ? 'deterministic' : development ? 'named' : 'natural'), F(optimization, 'chunkIds', ()=>production ? 'deterministic' : development ? 'named' : 'natural'), F(optimization, 'sideEffects', ()=>!!production || 'flag'), D(optimization, 'mangleExports', production), D(optimization, 'inlineExports', production), D(optimization, 'providedExports', !0), D(optimization, 'usedExports', production), D(optimization, 'innerGraph', production), D(optimization, 'emitOnErrors', !production), D(optimization, 'runtimeChunk', !1), D(optimization, 'realContentHash', production), D(optimization, 'avoidEntryIife', !1), D(optimization, 'minimize', production), D(optimization, 'concatenateModules', production), A(optimization, 'minimizer', ()=>[
|
|
6292
6857
|
new SwcJsMinimizerRspackPlugin(),
|
|
6293
6858
|
new LightningCssMinimizerRspackPlugin()
|
|
6294
6859
|
]), F(optimization, 'nodeEnv', ()=>production ? 'production' : !!development && 'development');
|
|
@@ -6308,7 +6873,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6308
6873
|
})), F(cacheGroups, 'defaultVendors', ()=>({
|
|
6309
6874
|
idHint: 'vendors',
|
|
6310
6875
|
reuseExistingChunk: !0,
|
|
6311
|
-
test: /[\\/]node_modules[\\/]
|
|
6876
|
+
test: /[\\/]node_modules[\\/]/,
|
|
6312
6877
|
priority: -10
|
|
6313
6878
|
})));
|
|
6314
6879
|
}
|
|
@@ -6331,15 +6896,14 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6331
6896
|
mainFiles: [
|
|
6332
6897
|
'index'
|
|
6333
6898
|
]
|
|
6334
|
-
}), getResolveDefaults = ({
|
|
6899
|
+
}), getResolveDefaults = ({ targetProperties, mode })=>{
|
|
6335
6900
|
let conditions = [
|
|
6336
6901
|
'webpack'
|
|
6337
6902
|
];
|
|
6338
6903
|
conditions.push('development' === mode ? 'development' : 'production'), targetProperties && (targetProperties.webworker && conditions.push('worker'), targetProperties.node && conditions.push('node'), targetProperties.web && conditions.push('browser'), targetProperties.electron && conditions.push('electron'), targetProperties.nwjs && conditions.push('nwjs'));
|
|
6339
6904
|
let jsExtensions = [
|
|
6340
6905
|
'.js',
|
|
6341
|
-
'.json'
|
|
6342
|
-
'.wasm'
|
|
6906
|
+
'.json'
|
|
6343
6907
|
], browserField = targetProperties && targetProperties.web && (!targetProperties.node || targetProperties.electron && targetProperties.electronRenderer), aliasFields = browserField ? [
|
|
6344
6908
|
'browser'
|
|
6345
6909
|
] : [], mainFields = browserField ? [
|
|
@@ -6385,9 +6949,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6385
6949
|
exportsFields: [
|
|
6386
6950
|
'exports'
|
|
6387
6951
|
],
|
|
6388
|
-
roots: [
|
|
6389
|
-
context
|
|
6390
|
-
],
|
|
6952
|
+
roots: [],
|
|
6391
6953
|
mainFields: [
|
|
6392
6954
|
'main'
|
|
6393
6955
|
],
|
|
@@ -6410,14 +6972,17 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6410
6972
|
loader: cjsDeps(),
|
|
6411
6973
|
unknown: cjsDeps()
|
|
6412
6974
|
}
|
|
6413
|
-
}
|
|
6414
|
-
return
|
|
6975
|
+
};
|
|
6976
|
+
return resolveOptions.byDependency['css-import'] = {
|
|
6415
6977
|
mainFiles: [],
|
|
6416
6978
|
mainFields: [
|
|
6417
6979
|
'style',
|
|
6418
6980
|
'...'
|
|
6419
6981
|
],
|
|
6420
|
-
conditionNames:
|
|
6982
|
+
conditionNames: [
|
|
6983
|
+
'development' === mode ? 'development' : 'production',
|
|
6984
|
+
'style'
|
|
6985
|
+
],
|
|
6421
6986
|
extensions: [
|
|
6422
6987
|
'.css'
|
|
6423
6988
|
],
|
|
@@ -6551,8 +7116,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6551
7116
|
]),
|
|
6552
7117
|
rules: nestedArray(module.rules, (r)=>[
|
|
6553
7118
|
...r
|
|
6554
|
-
])
|
|
6555
|
-
unsafeCache: module.unsafeCache
|
|
7119
|
+
])
|
|
6556
7120
|
})),
|
|
6557
7121
|
target: config.target,
|
|
6558
7122
|
externals: config.externals,
|
|
@@ -6588,7 +7152,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6588
7152
|
storage: {
|
|
6589
7153
|
type: 'filesystem',
|
|
6590
7154
|
directory: node_path.resolve(config.context || process.cwd(), cache.storage?.directory || 'node_modules/.cache/rspack')
|
|
6591
|
-
}
|
|
7155
|
+
},
|
|
7156
|
+
portable: cache.portable,
|
|
7157
|
+
readonly: cache.readonly
|
|
6592
7158
|
};
|
|
6593
7159
|
}),
|
|
6594
7160
|
stats: nestedConfig(config.stats, (stats)=>!1 === stats ? {
|
|
@@ -6619,7 +7185,6 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6619
7185
|
]),
|
|
6620
7186
|
experiments: nestedConfig(config.experiments, (experiments)=>({
|
|
6621
7187
|
...experiments,
|
|
6622
|
-
incremental: optionalNestedConfig(experiments.incremental, (options)=>getNormalizedIncrementalOptions(options)),
|
|
6623
7188
|
buildHttp: experiments.buildHttp,
|
|
6624
7189
|
useInputFileSystem: experiments.useInputFileSystem
|
|
6625
7190
|
})),
|
|
@@ -6628,7 +7193,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6628
7193
|
devServer: config.devServer,
|
|
6629
7194
|
amd: config.amd,
|
|
6630
7195
|
bail: config.bail,
|
|
6631
|
-
lazyCompilation: optionalNestedConfig(config.lazyCompilation, (options)=>!0 === options ? {} : options)
|
|
7196
|
+
lazyCompilation: optionalNestedConfig(config.lazyCompilation, (options)=>!0 === options ? {} : options),
|
|
7197
|
+
incremental: optionalNestedConfig(config.incremental, (options)=>getNormalizedIncrementalOptions(options))
|
|
6632
7198
|
};
|
|
6633
7199
|
}, getNormalizedEntryStatic = (entry)=>{
|
|
6634
7200
|
if ('string' == typeof entry) return {
|
|
@@ -6685,12 +7251,11 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6685
7251
|
}
|
|
6686
7252
|
}, getNormalizedIncrementalOptions = (incremental)=>!1 !== incremental && 'none' !== incremental && ('safe' === incremental ? {
|
|
6687
7253
|
silent: !0,
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
buildChunkGraph: !1,
|
|
7254
|
+
buildModuleGraph: !0,
|
|
7255
|
+
finishModules: !1,
|
|
7256
|
+
optimizeDependencies: !1,
|
|
7257
|
+
buildChunkGraph: !0,
|
|
7258
|
+
optimizeChunkModules: !1,
|
|
6694
7259
|
moduleIds: !1,
|
|
6695
7260
|
chunkIds: !1,
|
|
6696
7261
|
modulesHashes: !1,
|
|
@@ -6698,7 +7263,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6698
7263
|
modulesRuntimeRequirements: !1,
|
|
6699
7264
|
chunksRuntimeRequirements: !1,
|
|
6700
7265
|
chunksHashes: !1,
|
|
6701
|
-
|
|
7266
|
+
chunkAsset: !1,
|
|
6702
7267
|
emitAssets: !0
|
|
6703
7268
|
} : !0 === incremental || 'advance-silent' === incremental ? {} : 'advance' === incremental ? {
|
|
6704
7269
|
silent: !1
|
|
@@ -7524,7 +8089,7 @@ class MultiStats {
|
|
|
7524
8089
|
obj.children = this.stats.map((stat, idx)=>{
|
|
7525
8090
|
let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
|
|
7526
8091
|
return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
|
|
7527
|
-
}), childOptions.version && (obj.rspackVersion = "2.0.0-
|
|
8092
|
+
}), childOptions.version && (obj.rspackVersion = "2.0.0-rc.0", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
|
|
7528
8093
|
let mapError = (j, obj)=>({
|
|
7529
8094
|
...obj,
|
|
7530
8095
|
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
|
@@ -8021,7 +8586,7 @@ let arraySum = (array)=>{
|
|
|
8021
8586
|
let str = `${a}`, length = lengths[i];
|
|
8022
8587
|
return str.length === length ? str : length > 5 ? `...${str.slice(-length + 3)}` : length > 0 ? str.slice(-length) : '';
|
|
8023
8588
|
});
|
|
8024
|
-
}, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.
|
|
8589
|
+
}, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.20.1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js");
|
|
8025
8590
|
var CachedInputFileSystem_default = __webpack_require__.n(CachedInputFileSystem);
|
|
8026
8591
|
class NodeEnvironmentPlugin {
|
|
8027
8592
|
options;
|
|
@@ -8123,7 +8688,7 @@ class NodeEnvironmentPlugin {
|
|
|
8123
8688
|
if ('' === str) return str;
|
|
8124
8689
|
let prefixWithIndent = currentIndent + prefix;
|
|
8125
8690
|
return colors ? prefixWithIndent + colorPrefix + str.replace(/\n/g, `${colorSuffix}\n${prefix}${colorPrefix}`) + colorSuffix : prefixWithIndent + str.replace(/\n/g, `\n${prefix}`);
|
|
8126
|
-
})(
|
|
8691
|
+
})(__rspack_external_node_util_1b29d436.format(...args), prefix, colorPrefix, colorSuffix);
|
|
8127
8692
|
stream.write(`${str}\n`), writeStatusMessage();
|
|
8128
8693
|
}, writeGroupMessage = writeColored('<-> ', '\u001b[1m\u001b[36m', '\u001b[39m\u001b[22m'), writeGroupCollapsedMessage = writeColored('<+> ', '\u001b[1m\u001b[36m', '\u001b[39m\u001b[22m');
|
|
8129
8694
|
return {
|
|
@@ -8680,15 +9245,21 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8680
9245
|
if (context.makePathsRelative || (context.makePathsRelative = makePathsRelative.bindContextCache(compilation.compiler.context, compilation.compiler.root)), !context.cachedGetErrors) {
|
|
8681
9246
|
let map = new WeakMap();
|
|
8682
9247
|
context.cachedGetErrors = (compilation)=>{
|
|
8683
|
-
|
|
8684
|
-
|
|
9248
|
+
if (compilation.compiler._lastCompilation !== compilation) return [];
|
|
9249
|
+
let cache = map.get(compilation);
|
|
9250
|
+
if (cache) return cache;
|
|
9251
|
+
let errors = statsCompilation.errors;
|
|
9252
|
+
return map.set(compilation, errors), errors;
|
|
8685
9253
|
};
|
|
8686
9254
|
}
|
|
8687
9255
|
if (!context.cachedGetWarnings) {
|
|
8688
9256
|
let map = new WeakMap();
|
|
8689
9257
|
context.cachedGetWarnings = (compilation)=>{
|
|
8690
|
-
|
|
8691
|
-
|
|
9258
|
+
if (compilation.compiler._lastCompilation !== compilation) return [];
|
|
9259
|
+
let cache = map.get(compilation);
|
|
9260
|
+
if (cache) return cache;
|
|
9261
|
+
let warnings = compilation.__internal_getInner().createStatsWarnings(compilation.getWarnings(), !!options.colors);
|
|
9262
|
+
return map.set(compilation, warnings), warnings;
|
|
8692
9263
|
};
|
|
8693
9264
|
}
|
|
8694
9265
|
compilation.name && (object.name = compilation.name);
|
|
@@ -8756,7 +9327,7 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8756
9327
|
let [label, first, second] = entry.args;
|
|
8757
9328
|
'number' == typeof first && 'number' == typeof second && (message = `${label}: ${1000 * first + second / 1000000} ms`);
|
|
8758
9329
|
}
|
|
8759
|
-
message || (message = entry.args?.length ?
|
|
9330
|
+
message || (message = entry.args?.length ? __rspack_external_node_util_1b29d436.format(entry.args[0], ...entry.args.slice(1)) : '');
|
|
8760
9331
|
let newEntry = {
|
|
8761
9332
|
type,
|
|
8762
9333
|
message: message || '',
|
|
@@ -8777,7 +9348,7 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8777
9348
|
object.hash = context.getStatsCompilation(compilation).hash;
|
|
8778
9349
|
},
|
|
8779
9350
|
version: (object)=>{
|
|
8780
|
-
object.version = "5.75.0", object.rspackVersion = "2.0.0-
|
|
9351
|
+
object.version = "5.75.0", object.rspackVersion = "2.0.0-rc.0";
|
|
8781
9352
|
},
|
|
8782
9353
|
env: (object, _compilation, _context, { _env })=>{
|
|
8783
9354
|
object.env = _env;
|
|
@@ -9249,7 +9820,7 @@ let applyDefaults = (options, defaults)=>{
|
|
|
9249
9820
|
chunksSort: ()=>!1,
|
|
9250
9821
|
assetsSort: ()=>'!size',
|
|
9251
9822
|
outputPath: OFF_FOR_TO_STRING,
|
|
9252
|
-
colors: ()
|
|
9823
|
+
colors: ()=>isStatsColorSupported()
|
|
9253
9824
|
}, normalizeFilter = (item)=>{
|
|
9254
9825
|
if ('string' == typeof item) {
|
|
9255
9826
|
let regExp = RegExp(`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, '\\$&')}([\\\\/]|$|!|\\?)`);
|
|
@@ -10039,18 +10610,13 @@ class RspackOptionsApply {
|
|
|
10039
10610
|
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
|
|
10040
10611
|
namespace: options.output.devtoolNamespace
|
|
10041
10612
|
}).apply(compiler);
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
if (modernModuleCount !== options.output.enabledLibraryTypes.length) throw Error('`modern-module` cannot used together with other library types');
|
|
10048
|
-
new EsmLibraryPlugin({
|
|
10049
|
-
preserveModules: options.output.library?.preserveModules
|
|
10050
|
-
}).apply(compiler);
|
|
10051
|
-
} else for (let type of options.output.enabledLibraryTypes)new EnableLibraryPlugin(type).apply(compiler);
|
|
10613
|
+
new JavascriptModulesPlugin().apply(compiler), new URLPlugin().apply(compiler), new JsonModulesPlugin().apply(compiler), new AssetModulesPlugin().apply(compiler), options.experiments.asyncWebAssembly && new AsyncWebAssemblyModulesPlugin().apply(compiler), new CssModulesPlugin().apply(compiler), new lib_EntryOptionPlugin().apply(compiler), assertNotNill(options.context), compiler.hooks.entryOption.call(options.context, options.entry), new RuntimePlugin().apply(compiler), options.output.bundlerInfo && new BundlerInfoRspackPlugin(options.output.bundlerInfo).apply(compiler), new InferAsyncModulesPlugin().apply(compiler), new APIPlugin().apply(compiler), new DataUriPlugin().apply(compiler), new FileUriPlugin().apply(compiler), options.experiments.buildHttp && new HttpUriPlugin(options.experiments.buildHttp).apply(compiler), new EnsureChunkConditionsPlugin().apply(compiler), options.optimization.mergeDuplicateChunks && new MergeDuplicateChunksPlugin().apply(compiler), options.optimization.sideEffects && new SideEffectsFlagPlugin().apply(compiler), options.optimization.providedExports && new FlagDependencyExportsPlugin().apply(compiler), options.optimization.usedExports && new FlagDependencyUsagePlugin('global' === options.optimization.usedExports).apply(compiler), options.optimization.concatenateModules && new ModuleConcatenationPlugin().apply(compiler), options.optimization.inlineExports && new InlineExportsPlugin().apply(compiler), options.optimization.mangleExports && new MangleExportsPlugin('size' !== options.optimization.mangleExports).apply(compiler);
|
|
10614
|
+
let enableLibSplitChunks = !1;
|
|
10615
|
+
if (options.output.enabledLibraryTypes && options.output.enabledLibraryTypes.length > 0) {
|
|
10616
|
+
let hasModernModule = options.output.enabledLibraryTypes.includes('modern-module'), hasNonModernModule = options.output.enabledLibraryTypes.some((t)=>'modern-module' !== t);
|
|
10617
|
+
for (let type of (options.output.library?.preserveModules && !hasModernModule && compiler.getInfrastructureLogger('rspack.RspackOptionsApply').warn('`preserveModules` only works for `modern-module` library type and will be ignored for other library types.'), hasModernModule && hasNonModernModule && compiler.getInfrastructureLogger('rspack.RspackOptionsApply').warn('`modern-module` is used together with other library types. ESM format has impact on chunkLoading and chunkFormat, which may not be compatible with other library types.'), options.output.enabledLibraryTypes))'modern-module' === type && (enableLibSplitChunks = !0), new EnableLibraryPlugin(type).apply(compiler);
|
|
10052
10618
|
}
|
|
10053
|
-
options.optimization.splitChunks && new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler), options.optimization.removeEmptyChunks && new RemoveEmptyChunksPlugin().apply(compiler), options.optimization.realContentHash && new RealContentHashPlugin().apply(compiler);
|
|
10619
|
+
!enableLibSplitChunks && options.optimization.splitChunks && new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler), options.optimization.removeEmptyChunks && new RemoveEmptyChunksPlugin().apply(compiler), options.optimization.realContentHash && new RealContentHashPlugin().apply(compiler);
|
|
10054
10620
|
let moduleIds = options.optimization.moduleIds;
|
|
10055
10621
|
if (moduleIds) switch(moduleIds){
|
|
10056
10622
|
case 'named':
|
|
@@ -10142,7 +10708,7 @@ function createCompiler(userOptions) {
|
|
|
10142
10708
|
function isMultiRspackOptions(o) {
|
|
10143
10709
|
return Array.isArray(o);
|
|
10144
10710
|
}
|
|
10145
|
-
function
|
|
10711
|
+
function rspack_rspack(options, callback) {
|
|
10146
10712
|
try {
|
|
10147
10713
|
if (isMultiRspackOptions(options)) for (let option of options)validateRspackConfig(option);
|
|
10148
10714
|
else validateRspackConfig(options);
|
|
@@ -10181,8 +10747,9 @@ function rspack(options, callback) {
|
|
|
10181
10747
|
return process.nextTick(()=>callback(err)), null;
|
|
10182
10748
|
}
|
|
10183
10749
|
{
|
|
10750
|
+
var message;
|
|
10184
10751
|
let { compiler, watch } = create();
|
|
10185
|
-
return watch &&
|
|
10752
|
+
return watch && (message = "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.", warnedMessages.has(message) || (warnedMessages.add(message), console.warn(`[Rspack Deprecation] ${message}`))), compiler;
|
|
10186
10753
|
}
|
|
10187
10754
|
}
|
|
10188
10755
|
class CodeGenerationResult {
|
|
@@ -10438,7 +11005,7 @@ class TraceHookPlugin {
|
|
|
10438
11005
|
});
|
|
10439
11006
|
}
|
|
10440
11007
|
}
|
|
10441
|
-
let CORE_VERSION = "2.0.0-
|
|
11008
|
+
let CORE_VERSION = "2.0.0-rc.0", VFILES_BY_COMPILER = new WeakMap();
|
|
10442
11009
|
class VirtualModulesPlugin {
|
|
10443
11010
|
#staticModules;
|
|
10444
11011
|
#compiler;
|
|
@@ -10583,22 +11150,23 @@ class Watching {
|
|
|
10583
11150
|
let startTime = this.startTime;
|
|
10584
11151
|
this.startTime = void 0, compilation.startTime = startTime, compilation.endTime = Date.now();
|
|
10585
11152
|
let cbs = this.callbacks;
|
|
10586
|
-
this.callbacks = []
|
|
10587
|
-
let fileDependencies = new Set([
|
|
10588
|
-
...compilation.fileDependencies
|
|
10589
|
-
]);
|
|
10590
|
-
fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
|
|
10591
|
-
let contextDependencies = new Set([
|
|
10592
|
-
...compilation.contextDependencies
|
|
10593
|
-
]);
|
|
10594
|
-
contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
|
|
10595
|
-
let missingDependencies = new Set([
|
|
10596
|
-
...compilation.missingDependencies
|
|
10597
|
-
]);
|
|
10598
|
-
missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), this.compiler.hooks.done.callAsync(stats, (err)=>{
|
|
11153
|
+
this.callbacks = [], this.compiler.hooks.done.callAsync(stats, (err)=>{
|
|
10599
11154
|
if (err) return handleError(err, cbs);
|
|
10600
11155
|
for (let cb of (this.handler(null, stats), process.nextTick(()=>{
|
|
10601
|
-
this.#closed
|
|
11156
|
+
if (!this.#closed) {
|
|
11157
|
+
let fileDependencies = new Set([
|
|
11158
|
+
...compilation.fileDependencies
|
|
11159
|
+
]);
|
|
11160
|
+
fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
|
|
11161
|
+
let contextDependencies = new Set([
|
|
11162
|
+
...compilation.contextDependencies
|
|
11163
|
+
]);
|
|
11164
|
+
contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
|
|
11165
|
+
let missingDependencies = new Set([
|
|
11166
|
+
...compilation.missingDependencies
|
|
11167
|
+
]);
|
|
11168
|
+
missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), this.watch(fileDependencies, contextDependencies, missingDependencies);
|
|
11169
|
+
}
|
|
10602
11170
|
}), cbs))cb(null);
|
|
10603
11171
|
this.compiler.hooks.afterDone.call(stats);
|
|
10604
11172
|
});
|
|
@@ -10618,7 +11186,7 @@ class Watching {
|
|
|
10618
11186
|
this.suspended && (this.suspended = !1, this.#invalidate());
|
|
10619
11187
|
}
|
|
10620
11188
|
}
|
|
10621
|
-
let Compiler_require = createRequire(import.meta.url);
|
|
11189
|
+
let Compiler_require = createRequire(import.meta.url), GET_COMPILER_ID = Symbol('getCompilerId');
|
|
10622
11190
|
class Compiler {
|
|
10623
11191
|
#instance;
|
|
10624
11192
|
#initial;
|
|
@@ -10749,8 +11317,19 @@ class Compiler {
|
|
|
10749
11317
|
]),
|
|
10750
11318
|
additionalPass: new AsyncSeriesHook([])
|
|
10751
11319
|
};
|
|
11320
|
+
let availableCompilerHooks = Object.keys(this.hooks);
|
|
11321
|
+
this.hooks = new Proxy(this.hooks, {
|
|
11322
|
+
get (target, prop, receiver) {
|
|
11323
|
+
let value = Reflect.get(target, prop, receiver);
|
|
11324
|
+
if (void 0 === value && 'string' == typeof prop) {
|
|
11325
|
+
let hooksList = availableCompilerHooks.join(', ');
|
|
11326
|
+
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}`);
|
|
11327
|
+
}
|
|
11328
|
+
return value;
|
|
11329
|
+
}
|
|
11330
|
+
});
|
|
10752
11331
|
let compilerRspack = Object.assign(function(...params) {
|
|
10753
|
-
return
|
|
11332
|
+
return rspack_rspack(...params);
|
|
10754
11333
|
}, exports_namespaceObject, {
|
|
10755
11334
|
RuntimeGlobals: createCompilerRuntimeGlobals(options)
|
|
10756
11335
|
});
|
|
@@ -10763,7 +11342,12 @@ class Compiler {
|
|
|
10763
11342
|
electron: null
|
|
10764
11343
|
}, this.#target = {}, this.__internal_browser_require = ()=>{
|
|
10765
11344
|
throw Error('Cannot execute user defined code in browser without `BrowserRequirePlugin`');
|
|
10766
|
-
}, this.resolverFactory = new ResolverFactory(options.resolve.pnp ?? getPnpDefault(), options.resolve, options.resolveLoader), new JsLoaderRspackPlugin(this).apply(this), new ExecuteModulePlugin().apply(this), new TraceHookPlugin().apply(this)
|
|
11345
|
+
}, this.resolverFactory = new ResolverFactory(options.resolve.pnp ?? getPnpDefault(), options.resolve, options.resolveLoader), new JsLoaderRspackPlugin(this).apply(this), new ExecuteModulePlugin().apply(this), new TraceHookPlugin().apply(this), Object.defineProperty(this, GET_COMPILER_ID, {
|
|
11346
|
+
writable: !1,
|
|
11347
|
+
configurable: !1,
|
|
11348
|
+
enumerable: !1,
|
|
11349
|
+
value: ()=>this.#instance.getCompilerId()
|
|
11350
|
+
});
|
|
10767
11351
|
}
|
|
10768
11352
|
get recordsInputPath() {
|
|
10769
11353
|
return unsupported('Compiler.recordsInputPath');
|
|
@@ -10922,7 +11506,8 @@ class Compiler {
|
|
|
10922
11506
|
}) : this.hooks.shutdown.callAsync((err)=>{
|
|
10923
11507
|
if (err) return callback(err);
|
|
10924
11508
|
this.cache.shutdown(()=>{
|
|
10925
|
-
this.#instance?.close()
|
|
11509
|
+
let closePromise = this.#instance?.close();
|
|
11510
|
+
closePromise ? closePromise.then(()=>callback(), callback) : callback();
|
|
10926
11511
|
});
|
|
10927
11512
|
});
|
|
10928
11513
|
}
|
|
@@ -10963,7 +11548,7 @@ class Compiler {
|
|
|
10963
11548
|
}
|
|
10964
11549
|
#getInstance(callback) {
|
|
10965
11550
|
var output;
|
|
10966
|
-
let coreVersion, expectedCoreVersion, mode, experiments, error = CORE_VERSION === binding_default().EXPECTED_RSPACK_CORE_VERSION || CORE_VERSION.includes('canary') ? null : Error((coreVersion = CORE_VERSION, expectedCoreVersion = binding_default().EXPECTED_RSPACK_CORE_VERSION, process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
|
|
11551
|
+
let coreVersion, expectedCoreVersion, statsOptions, mode, experiments, error = CORE_VERSION === binding_default().EXPECTED_RSPACK_CORE_VERSION || CORE_VERSION.includes('canary') ? null : Error((coreVersion = CORE_VERSION, expectedCoreVersion = binding_default().EXPECTED_RSPACK_CORE_VERSION, process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
|
|
10967
11552
|
|
|
10968
11553
|
Help:
|
|
10969
11554
|
Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
|
|
@@ -11024,8 +11609,7 @@ Help:
|
|
|
11024
11609
|
k,
|
|
11025
11610
|
getRawGeneratorOptions(v, k)
|
|
11026
11611
|
]).filter(([_, v])=>void 0 !== v)),
|
|
11027
|
-
noParse: module.noParse
|
|
11028
|
-
unsafeCache: module.unsafeCache
|
|
11612
|
+
noParse: module.noParse
|
|
11029
11613
|
};
|
|
11030
11614
|
}(options.module, {
|
|
11031
11615
|
compiler: this,
|
|
@@ -11035,7 +11619,7 @@ Help:
|
|
|
11035
11619
|
}),
|
|
11036
11620
|
optimization: options.optimization,
|
|
11037
11621
|
stats: {
|
|
11038
|
-
colors:
|
|
11622
|
+
colors: void 0 === (statsOptions = function(options) {
|
|
11039
11623
|
if ('boolean' == typeof options || 'string' == typeof options) return presetToOptions(options);
|
|
11040
11624
|
if (!options) return {};
|
|
11041
11625
|
let obj = {
|
|
@@ -11043,10 +11627,11 @@ Help:
|
|
|
11043
11627
|
...options
|
|
11044
11628
|
};
|
|
11045
11629
|
return delete obj.preset, obj;
|
|
11046
|
-
}(options.stats).colors
|
|
11630
|
+
}(options.stats)).colors ? isStatsColorSupported() : !!statsOptions.colors
|
|
11047
11631
|
},
|
|
11048
11632
|
cache: options.cache || !1,
|
|
11049
11633
|
experiments,
|
|
11634
|
+
incremental: options.incremental,
|
|
11050
11635
|
node: function(node) {
|
|
11051
11636
|
if (!1 !== node) {
|
|
11052
11637
|
if (isNil(node.__dirname) || isNil(node.global) || isNil(node.__filename)) throw Error('node.__dirname, node.global, node.__filename should not be nil');
|
|
@@ -11306,6 +11891,29 @@ Help:
|
|
|
11306
11891
|
return queried.promise(getCompiler().__internal__get_compilation().chunks, getCompiler().__internal__get_compilation().modules);
|
|
11307
11892
|
};
|
|
11308
11893
|
}),
|
|
11894
|
+
registerCompilationBeforeModuleIdsTaps: createTap(binding_default().RegisterJsTapKind.CompilationBeforeModuleIds, function() {
|
|
11895
|
+
return getCompiler().__internal__get_compilation().hooks.beforeModuleIds;
|
|
11896
|
+
}, function(queried) {
|
|
11897
|
+
return function(arg) {
|
|
11898
|
+
let compilation = getCompiler().__internal__get_compilation(), assignments = new Map(), modulesByIdentifier = new Map();
|
|
11899
|
+
for (let module of compilation.modules)modulesByIdentifier.set(module.identifier(), module);
|
|
11900
|
+
let proxiedModules = arg.modules.map((m)=>new Proxy(modulesByIdentifier.get(m.identifier), {
|
|
11901
|
+
get (target, prop) {
|
|
11902
|
+
if ('id' === prop) return assignments.get(m.identifier) ?? null;
|
|
11903
|
+
if ('identifier' === prop) return m.identifier;
|
|
11904
|
+
let value = Reflect.get(target, prop);
|
|
11905
|
+
return 'function' == typeof value ? value.bind(target) : value;
|
|
11906
|
+
},
|
|
11907
|
+
set: (_target, prop, value)=>'id' === prop && null !== value && (assignments.set(m.identifier, value), !0)
|
|
11908
|
+
}));
|
|
11909
|
+
return queried.call(proxiedModules), {
|
|
11910
|
+
assignments: Object.fromEntries(Array.from(assignments.entries()).map(([k, v])=>[
|
|
11911
|
+
k,
|
|
11912
|
+
String(v)
|
|
11913
|
+
]))
|
|
11914
|
+
};
|
|
11915
|
+
};
|
|
11916
|
+
}),
|
|
11309
11917
|
registerCompilationChunkHashTaps: createTap(binding_default().RegisterJsTapKind.CompilationChunkHash, function() {
|
|
11310
11918
|
return getCompiler().__internal__get_compilation().hooks.chunkHash;
|
|
11311
11919
|
}, function(queried) {
|
|
@@ -11848,68 +12456,7 @@ class LoaderTargetPlugin {
|
|
|
11848
12456
|
});
|
|
11849
12457
|
}
|
|
11850
12458
|
}
|
|
11851
|
-
let
|
|
11852
|
-
function isRequiredVersion(str) {
|
|
11853
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
11854
|
-
}
|
|
11855
|
-
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
11856
|
-
function isPlainObject(value) {
|
|
11857
|
-
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
11858
|
-
}
|
|
11859
|
-
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
11860
|
-
name = binding_namespaceObject.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
11861
|
-
opts;
|
|
11862
|
-
constructor(opts){
|
|
11863
|
-
super(), this.opts = opts;
|
|
11864
|
-
}
|
|
11865
|
-
raw(compiler) {
|
|
11866
|
-
var isDev;
|
|
11867
|
-
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
|
|
11868
|
-
if (!manifestOptions) return {
|
|
11869
|
-
statsFileName: STATS_FILE_NAME,
|
|
11870
|
-
manifestFileName: MANIFEST_FILE_NAME
|
|
11871
|
-
};
|
|
11872
|
-
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;
|
|
11873
|
-
return {
|
|
11874
|
-
statsFileName: join(filePath, fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME),
|
|
11875
|
-
manifestFileName: join(filePath, manifestFileName)
|
|
11876
|
-
};
|
|
11877
|
-
}(this.opts), rawOptions = {
|
|
11878
|
-
name: this.opts.name,
|
|
11879
|
-
globalName: this.opts.globalName,
|
|
11880
|
-
fileName,
|
|
11881
|
-
filePath,
|
|
11882
|
-
manifestFileName,
|
|
11883
|
-
statsFileName,
|
|
11884
|
-
disableAssetsAnalyze,
|
|
11885
|
-
remoteAliasMap,
|
|
11886
|
-
exposes,
|
|
11887
|
-
shared,
|
|
11888
|
-
buildInfo: (isDev = 'development' === compiler.options.mode, pkg = function(root) {
|
|
11889
|
-
let pkgPath = join(root ? external_node_path_resolve(root) : process.cwd(), 'package.json');
|
|
11890
|
-
try {
|
|
11891
|
-
let content = readFileSync(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
11892
|
-
try {
|
|
11893
|
-
let parsed = JSON.parse(input);
|
|
11894
|
-
if (guard(parsed)) return parsed;
|
|
11895
|
-
} catch {}
|
|
11896
|
-
}(content, isPlainObject);
|
|
11897
|
-
if (parsed) {
|
|
11898
|
-
let filtered = {};
|
|
11899
|
-
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
11900
|
-
if (Object.keys(filtered).length > 0) return filtered;
|
|
11901
|
-
}
|
|
11902
|
-
} catch {}
|
|
11903
|
-
return {};
|
|
11904
|
-
}(compiler.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, {
|
|
11905
|
-
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
11906
|
-
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
11907
|
-
})
|
|
11908
|
-
};
|
|
11909
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
11910
|
-
}
|
|
11911
|
-
}
|
|
11912
|
-
let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
12459
|
+
let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
11913
12460
|
let items = [];
|
|
11914
12461
|
var fn = (key, value)=>{
|
|
11915
12462
|
items.push([
|
|
@@ -11926,63 +12473,7 @@ let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinP
|
|
|
11926
12473
|
else if ('object' == typeof options) object(options);
|
|
11927
12474
|
else throw Error('Unexpected options format');
|
|
11928
12475
|
return items;
|
|
11929
|
-
},
|
|
11930
|
-
function getRemoteInfos(options) {
|
|
11931
|
-
if (!options.remotes) return {};
|
|
11932
|
-
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
11933
|
-
external: Array.isArray(item) ? item : [
|
|
11934
|
-
item
|
|
11935
|
-
],
|
|
11936
|
-
shareScope: options.shareScope || 'default'
|
|
11937
|
-
}), (item)=>({
|
|
11938
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
11939
|
-
item.external
|
|
11940
|
-
],
|
|
11941
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
11942
|
-
})), remoteInfos = {};
|
|
11943
|
-
for (let [key, config] of remotes)for (let external of config.external){
|
|
11944
|
-
let [externalType, externalRequest] = function(external) {
|
|
11945
|
-
let result = function(external) {
|
|
11946
|
-
if (/^[a-z0-9-]+ /.test(external)) {
|
|
11947
|
-
let idx = external.indexOf(' ');
|
|
11948
|
-
return [
|
|
11949
|
-
external.slice(0, idx),
|
|
11950
|
-
external.slice(idx + 1)
|
|
11951
|
-
];
|
|
11952
|
-
}
|
|
11953
|
-
return null;
|
|
11954
|
-
}(external);
|
|
11955
|
-
return null === result ? [
|
|
11956
|
-
remoteType,
|
|
11957
|
-
external
|
|
11958
|
-
] : result;
|
|
11959
|
-
}(external);
|
|
11960
|
-
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
11961
|
-
let [url, global] = function(urlAndGlobal) {
|
|
11962
|
-
let index = urlAndGlobal.indexOf('@');
|
|
11963
|
-
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
11964
|
-
urlAndGlobal.substring(index + 1),
|
|
11965
|
-
urlAndGlobal.substring(0, index)
|
|
11966
|
-
];
|
|
11967
|
-
}(externalRequest);
|
|
11968
|
-
remoteInfos[key].push({
|
|
11969
|
-
alias: key,
|
|
11970
|
-
name: global,
|
|
11971
|
-
entry: url,
|
|
11972
|
-
externalType,
|
|
11973
|
-
shareScope: config.shareScope
|
|
11974
|
-
});
|
|
11975
|
-
} else remoteInfos[key].push({
|
|
11976
|
-
alias: key,
|
|
11977
|
-
name: void 0,
|
|
11978
|
-
entry: void 0,
|
|
11979
|
-
externalType,
|
|
11980
|
-
shareScope: config.shareScope
|
|
11981
|
-
});
|
|
11982
|
-
}
|
|
11983
|
-
return remoteInfos;
|
|
11984
|
-
}
|
|
11985
|
-
let compilerSet = new WeakSet();
|
|
12476
|
+
}, compilerSet = new WeakSet();
|
|
11986
12477
|
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
11987
12478
|
enhanced;
|
|
11988
12479
|
name = binding_namespaceObject.BuiltinPluginName.ShareRuntimePlugin;
|
|
@@ -11993,42 +12484,55 @@ class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
|
11993
12484
|
if (!compilerSet.has(compiler)) return compilerSet.add(compiler), createBuiltinPlugin(this.name, this.enhanced);
|
|
11994
12485
|
}
|
|
11995
12486
|
}
|
|
12487
|
+
let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
12488
|
+
function isRequiredVersion(str) {
|
|
12489
|
+
return VERSION_PATTERN_REGEXP.test(str);
|
|
12490
|
+
}
|
|
12491
|
+
let encodeName = function(name, prefix = '', withExt = !1) {
|
|
12492
|
+
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${withExt ? '.js' : ''}`;
|
|
12493
|
+
};
|
|
12494
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
12495
|
+
return parseOptions(consumes, (item, key)=>{
|
|
12496
|
+
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
12497
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12498
|
+
import: key,
|
|
12499
|
+
shareScope: shareScope || 'default',
|
|
12500
|
+
shareKey: key,
|
|
12501
|
+
requiredVersion: item,
|
|
12502
|
+
strictVersion: !0,
|
|
12503
|
+
packageName: void 0,
|
|
12504
|
+
singleton: !1,
|
|
12505
|
+
eager: !1,
|
|
12506
|
+
treeShakingMode: void 0
|
|
12507
|
+
} : {
|
|
12508
|
+
import: key,
|
|
12509
|
+
shareScope: shareScope || 'default',
|
|
12510
|
+
shareKey: key,
|
|
12511
|
+
requiredVersion: void 0,
|
|
12512
|
+
packageName: void 0,
|
|
12513
|
+
strictVersion: !1,
|
|
12514
|
+
singleton: !1,
|
|
12515
|
+
eager: !1,
|
|
12516
|
+
treeShakingMode: void 0
|
|
12517
|
+
};
|
|
12518
|
+
}, (item, key)=>({
|
|
12519
|
+
import: !1 === item.import ? void 0 : item.import || key,
|
|
12520
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
12521
|
+
shareKey: item.shareKey || key,
|
|
12522
|
+
requiredVersion: item.requiredVersion,
|
|
12523
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12524
|
+
packageName: item.packageName,
|
|
12525
|
+
singleton: !!item.singleton,
|
|
12526
|
+
eager: !!item.eager,
|
|
12527
|
+
treeShakingMode: item.treeShakingMode
|
|
12528
|
+
}));
|
|
12529
|
+
}
|
|
11996
12530
|
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
11997
12531
|
name = binding_namespaceObject.BuiltinPluginName.ConsumeSharedPlugin;
|
|
11998
12532
|
_options;
|
|
11999
12533
|
constructor(options){
|
|
12000
12534
|
super(), this._options = {
|
|
12001
|
-
consumes:
|
|
12002
|
-
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
12003
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12004
|
-
import: key,
|
|
12005
|
-
shareScope: options.shareScope || 'default',
|
|
12006
|
-
shareKey: key,
|
|
12007
|
-
requiredVersion: item,
|
|
12008
|
-
strictVersion: !0,
|
|
12009
|
-
packageName: void 0,
|
|
12010
|
-
singleton: !1,
|
|
12011
|
-
eager: !1
|
|
12012
|
-
} : {
|
|
12013
|
-
import: key,
|
|
12014
|
-
shareScope: options.shareScope || 'default',
|
|
12015
|
-
shareKey: key,
|
|
12016
|
-
requiredVersion: void 0,
|
|
12017
|
-
packageName: void 0,
|
|
12018
|
-
strictVersion: !1,
|
|
12019
|
-
singleton: !1,
|
|
12020
|
-
eager: !1
|
|
12021
|
-
};
|
|
12022
|
-
}, (item, key)=>({
|
|
12023
|
-
import: !1 === item.import ? void 0 : item.import || key,
|
|
12024
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
12025
|
-
shareKey: item.shareKey || key,
|
|
12026
|
-
requiredVersion: item.requiredVersion,
|
|
12027
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12028
|
-
packageName: item.packageName,
|
|
12029
|
-
singleton: !!item.singleton,
|
|
12030
|
-
eager: !!item.eager
|
|
12031
|
-
})),
|
|
12535
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
12032
12536
|
enhanced: options.enhanced ?? !1
|
|
12033
12537
|
};
|
|
12034
12538
|
}
|
|
@@ -12049,28 +12553,30 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
12049
12553
|
_provides;
|
|
12050
12554
|
_enhanced;
|
|
12051
12555
|
constructor(options){
|
|
12052
|
-
|
|
12556
|
+
var options1, shareScope, enhanced;
|
|
12557
|
+
super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
|
|
12053
12558
|
if (Array.isArray(item)) throw Error('Unexpected array of provides');
|
|
12054
12559
|
return {
|
|
12055
12560
|
shareKey: item,
|
|
12056
12561
|
version: void 0,
|
|
12057
|
-
shareScope:
|
|
12562
|
+
shareScope: shareScope || 'default',
|
|
12058
12563
|
eager: !1
|
|
12059
12564
|
};
|
|
12060
12565
|
}, (item)=>{
|
|
12061
12566
|
let raw = {
|
|
12062
12567
|
shareKey: item.shareKey,
|
|
12063
12568
|
version: item.version,
|
|
12064
|
-
shareScope: item.shareScope ||
|
|
12569
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
12065
12570
|
eager: !!item.eager
|
|
12066
12571
|
};
|
|
12067
|
-
return
|
|
12572
|
+
return enhanced ? {
|
|
12068
12573
|
...raw,
|
|
12069
12574
|
singleton: item.singleton,
|
|
12070
12575
|
requiredVersion: item.requiredVersion,
|
|
12071
|
-
strictVersion: item.strictVersion
|
|
12576
|
+
strictVersion: item.strictVersion,
|
|
12577
|
+
treeShakingMode: item.treeShakingMode
|
|
12072
12578
|
} : raw;
|
|
12073
|
-
}), this._enhanced = options.enhanced;
|
|
12579
|
+
})), this._enhanced = options.enhanced;
|
|
12074
12580
|
}
|
|
12075
12581
|
raw(compiler) {
|
|
12076
12582
|
new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
|
|
@@ -12081,32 +12587,43 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
12081
12587
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
12082
12588
|
}
|
|
12083
12589
|
}
|
|
12590
|
+
function validateShareScope(shareScope, enhanced, pluginName) {
|
|
12591
|
+
if (Array.isArray(shareScope) && shareScope.length > 1 && !enhanced) throw Error(`[${pluginName}] shareScope as an array with multiple entries requires enhanced=true, got: ${JSON.stringify(shareScope)}`);
|
|
12592
|
+
}
|
|
12593
|
+
function normalizeSharedOptions(shared) {
|
|
12594
|
+
return parseOptions(shared, (item, key)=>{
|
|
12595
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12596
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12597
|
+
import: key,
|
|
12598
|
+
requiredVersion: item
|
|
12599
|
+
} : {
|
|
12600
|
+
import: item
|
|
12601
|
+
};
|
|
12602
|
+
}, (item)=>item);
|
|
12603
|
+
}
|
|
12604
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
12605
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
12606
|
+
[key]: {
|
|
12607
|
+
import: options.import,
|
|
12608
|
+
shareKey: options.shareKey || key,
|
|
12609
|
+
shareScope: options.shareScope,
|
|
12610
|
+
requiredVersion: options.requiredVersion,
|
|
12611
|
+
strictVersion: options.strictVersion,
|
|
12612
|
+
singleton: options.singleton,
|
|
12613
|
+
packageName: options.packageName,
|
|
12614
|
+
eager: options.eager,
|
|
12615
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12616
|
+
}
|
|
12617
|
+
}));
|
|
12618
|
+
}
|
|
12084
12619
|
class SharePlugin {
|
|
12085
12620
|
_shareScope;
|
|
12086
12621
|
_consumes;
|
|
12087
12622
|
_provides;
|
|
12088
12623
|
_enhanced;
|
|
12624
|
+
_sharedOptions;
|
|
12089
12625
|
constructor(options){
|
|
12090
|
-
let sharedOptions =
|
|
12091
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12092
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12093
|
-
import: key,
|
|
12094
|
-
requiredVersion: item
|
|
12095
|
-
} : {
|
|
12096
|
-
import: item
|
|
12097
|
-
};
|
|
12098
|
-
}, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
|
|
12099
|
-
[key]: {
|
|
12100
|
-
import: options.import,
|
|
12101
|
-
shareKey: options.shareKey || key,
|
|
12102
|
-
shareScope: options.shareScope,
|
|
12103
|
-
requiredVersion: options.requiredVersion,
|
|
12104
|
-
strictVersion: options.strictVersion,
|
|
12105
|
-
singleton: options.singleton,
|
|
12106
|
-
packageName: options.packageName,
|
|
12107
|
-
eager: options.eager
|
|
12108
|
-
}
|
|
12109
|
-
})), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12626
|
+
let sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12110
12627
|
[options.import || key]: {
|
|
12111
12628
|
shareKey: options.shareKey || key,
|
|
12112
12629
|
shareScope: options.shareScope,
|
|
@@ -12114,10 +12631,11 @@ class SharePlugin {
|
|
|
12114
12631
|
eager: options.eager,
|
|
12115
12632
|
singleton: options.singleton,
|
|
12116
12633
|
requiredVersion: options.requiredVersion,
|
|
12117
|
-
strictVersion: options.strictVersion
|
|
12634
|
+
strictVersion: options.strictVersion,
|
|
12635
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12118
12636
|
}
|
|
12119
12637
|
}));
|
|
12120
|
-
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
|
|
12638
|
+
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
|
|
12121
12639
|
}
|
|
12122
12640
|
apply(compiler) {
|
|
12123
12641
|
new ConsumeSharedPlugin({
|
|
@@ -12131,15 +12649,566 @@ class SharePlugin {
|
|
|
12131
12649
|
}).apply(compiler);
|
|
12132
12650
|
}
|
|
12133
12651
|
}
|
|
12652
|
+
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
12653
|
+
function isPlainObject(value) {
|
|
12654
|
+
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
12655
|
+
}
|
|
12656
|
+
function getFileName(manifestOptions) {
|
|
12657
|
+
if (!manifestOptions) return {
|
|
12658
|
+
statsFileName: '',
|
|
12659
|
+
manifestFileName: ''
|
|
12660
|
+
};
|
|
12661
|
+
if ('boolean' == typeof manifestOptions) return {
|
|
12662
|
+
statsFileName: STATS_FILE_NAME,
|
|
12663
|
+
manifestFileName: MANIFEST_FILE_NAME
|
|
12664
|
+
};
|
|
12665
|
+
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;
|
|
12666
|
+
return {
|
|
12667
|
+
statsFileName: join(filePath, fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME),
|
|
12668
|
+
manifestFileName: join(filePath, manifestFileName)
|
|
12669
|
+
};
|
|
12670
|
+
}
|
|
12671
|
+
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
12672
|
+
name = binding_namespaceObject.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
12673
|
+
rawOpts;
|
|
12674
|
+
constructor(opts){
|
|
12675
|
+
super(), this.rawOpts = opts;
|
|
12676
|
+
}
|
|
12677
|
+
raw(compiler) {
|
|
12678
|
+
var mfConfig, isDev, mfConfig1;
|
|
12679
|
+
let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared, pkg, buildVersion, statsBuildInfo, opts = (manifestOptions = !0 === (mfConfig = this.rawOpts).manifest ? {} : {
|
|
12680
|
+
...mfConfig.manifest
|
|
12681
|
+
}, containerName = mfConfig.name, globalName = function(library) {
|
|
12682
|
+
if (!library) return;
|
|
12683
|
+
let libName = library.name;
|
|
12684
|
+
if (libName) {
|
|
12685
|
+
if ('string' == typeof libName) return libName;
|
|
12686
|
+
if (Array.isArray(libName)) return libName[0];
|
|
12687
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12688
|
+
}
|
|
12689
|
+
}(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
12690
|
+
if (cur[1].length > 1) return sum;
|
|
12691
|
+
let { entry, alias, name } = cur[1][0];
|
|
12692
|
+
return entry && name && (sum[alias] = {
|
|
12693
|
+
name,
|
|
12694
|
+
entry
|
|
12695
|
+
}), sum;
|
|
12696
|
+
}, {}), manifestExposes = function(exposes) {
|
|
12697
|
+
if (!exposes) return;
|
|
12698
|
+
let result = parseOptions(exposes, (value)=>({
|
|
12699
|
+
import: Array.isArray(value) ? value : [
|
|
12700
|
+
value
|
|
12701
|
+
],
|
|
12702
|
+
name: void 0
|
|
12703
|
+
}), (value)=>({
|
|
12704
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
12705
|
+
value.import
|
|
12706
|
+
],
|
|
12707
|
+
name: value.name ?? void 0
|
|
12708
|
+
})).map(([exposeKey, info])=>{
|
|
12709
|
+
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12710
|
+
return {
|
|
12711
|
+
path: exposeKey,
|
|
12712
|
+
name: exposeName
|
|
12713
|
+
};
|
|
12714
|
+
});
|
|
12715
|
+
return result.length > 0 ? result : void 0;
|
|
12716
|
+
}(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
|
|
12717
|
+
if (!shared) return;
|
|
12718
|
+
let result = parseOptions(shared, (item, key)=>{
|
|
12719
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12720
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12721
|
+
import: key,
|
|
12722
|
+
requiredVersion: item
|
|
12723
|
+
} : {
|
|
12724
|
+
import: item
|
|
12725
|
+
};
|
|
12726
|
+
}, (item)=>item).map(([key, config])=>{
|
|
12727
|
+
let name = config.shareKey || key;
|
|
12728
|
+
return {
|
|
12729
|
+
name,
|
|
12730
|
+
version: 'string' == typeof config.version ? config.version : void 0,
|
|
12731
|
+
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12732
|
+
singleton: config.singleton
|
|
12733
|
+
};
|
|
12734
|
+
});
|
|
12735
|
+
return result.length > 0 ? result : void 0;
|
|
12736
|
+
}(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
|
|
12737
|
+
...manifestOptions,
|
|
12738
|
+
remoteAliasMap,
|
|
12739
|
+
globalName,
|
|
12740
|
+
name: containerName
|
|
12741
|
+
}), { fileName, filePath, disableAssetsAnalyze, remoteAliasMap: remoteAliasMap1, exposes, shared } = opts, { statsFileName, manifestFileName } = getFileName(opts), rawOptions = {
|
|
12742
|
+
name: opts.name,
|
|
12743
|
+
globalName: opts.globalName,
|
|
12744
|
+
fileName,
|
|
12745
|
+
filePath,
|
|
12746
|
+
manifestFileName,
|
|
12747
|
+
statsFileName,
|
|
12748
|
+
disableAssetsAnalyze,
|
|
12749
|
+
remoteAliasMap: remoteAliasMap1,
|
|
12750
|
+
exposes,
|
|
12751
|
+
shared,
|
|
12752
|
+
buildInfo: (isDev = 'development' === compiler.options.mode, mfConfig1 = this.rawOpts, pkg = function(root) {
|
|
12753
|
+
let pkgPath = join(root ? external_node_path_resolve(root) : process.cwd(), 'package.json');
|
|
12754
|
+
try {
|
|
12755
|
+
let content = readFileSync(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
12756
|
+
try {
|
|
12757
|
+
let parsed = JSON.parse(input);
|
|
12758
|
+
if (guard(parsed)) return parsed;
|
|
12759
|
+
} catch {}
|
|
12760
|
+
}(content, isPlainObject);
|
|
12761
|
+
if (parsed) {
|
|
12762
|
+
let filtered = {};
|
|
12763
|
+
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
12764
|
+
if (Object.keys(filtered).length > 0) return filtered;
|
|
12765
|
+
}
|
|
12766
|
+
} catch {}
|
|
12767
|
+
return {};
|
|
12768
|
+
}(compiler.options.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, statsBuildInfo = {
|
|
12769
|
+
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
12770
|
+
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
12771
|
+
}, 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)
|
|
12772
|
+
};
|
|
12773
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12774
|
+
}
|
|
12775
|
+
}
|
|
12776
|
+
let SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
12777
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
12778
|
+
name = binding_namespaceObject.BuiltinPluginName.CollectSharedEntryPlugin;
|
|
12779
|
+
sharedOptions;
|
|
12780
|
+
_collectedEntries;
|
|
12781
|
+
constructor(options){
|
|
12782
|
+
super();
|
|
12783
|
+
let { sharedOptions } = options;
|
|
12784
|
+
this.sharedOptions = sharedOptions, this._collectedEntries = {};
|
|
12785
|
+
}
|
|
12786
|
+
getData() {
|
|
12787
|
+
return this._collectedEntries;
|
|
12788
|
+
}
|
|
12789
|
+
getFilename() {
|
|
12790
|
+
return SHARE_ENTRY_ASSET;
|
|
12791
|
+
}
|
|
12792
|
+
apply(compiler) {
|
|
12793
|
+
super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
12794
|
+
compilation.hooks.processAssets.tap({
|
|
12795
|
+
name: 'CollectSharedEntry',
|
|
12796
|
+
stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
12797
|
+
}, ()=>{
|
|
12798
|
+
compilation.getAssets().forEach((asset)=>{
|
|
12799
|
+
asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
|
|
12800
|
+
});
|
|
12801
|
+
});
|
|
12802
|
+
});
|
|
12803
|
+
}
|
|
12804
|
+
raw() {
|
|
12805
|
+
let rawOptions = {
|
|
12806
|
+
consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
|
|
12807
|
+
key,
|
|
12808
|
+
...v
|
|
12809
|
+
})),
|
|
12810
|
+
filename: this.getFilename()
|
|
12811
|
+
};
|
|
12812
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12813
|
+
}
|
|
12814
|
+
}
|
|
12815
|
+
function assert(condition, msg) {
|
|
12816
|
+
if (!condition) throw Error(msg);
|
|
12817
|
+
}
|
|
12818
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
12819
|
+
name = binding_namespaceObject.BuiltinPluginName.SharedContainerPlugin;
|
|
12820
|
+
filename = '';
|
|
12821
|
+
_options;
|
|
12822
|
+
_shareName;
|
|
12823
|
+
_globalName;
|
|
12824
|
+
constructor(options){
|
|
12825
|
+
super();
|
|
12826
|
+
let { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || '0.0.0';
|
|
12827
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
12828
|
+
let fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
12829
|
+
this._shareName = shareName, this._options = {
|
|
12830
|
+
name: shareName,
|
|
12831
|
+
request: request,
|
|
12832
|
+
library: (library ? {
|
|
12833
|
+
...library,
|
|
12834
|
+
name: this._globalName
|
|
12835
|
+
} : void 0) || {
|
|
12836
|
+
type: 'global',
|
|
12837
|
+
name: this._globalName
|
|
12838
|
+
},
|
|
12839
|
+
version,
|
|
12840
|
+
fileName
|
|
12841
|
+
};
|
|
12842
|
+
}
|
|
12843
|
+
getData() {
|
|
12844
|
+
return [
|
|
12845
|
+
this._options.fileName,
|
|
12846
|
+
this._globalName,
|
|
12847
|
+
this._options.version
|
|
12848
|
+
];
|
|
12849
|
+
}
|
|
12850
|
+
raw(compiler) {
|
|
12851
|
+
let { library } = this._options;
|
|
12852
|
+
return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
|
|
12853
|
+
}
|
|
12854
|
+
apply(compiler) {
|
|
12855
|
+
super.apply(compiler);
|
|
12856
|
+
let shareName = this._shareName;
|
|
12857
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
12858
|
+
compilation.hooks.processAssets.tap({
|
|
12859
|
+
name: 'getShareContainerFile'
|
|
12860
|
+
}, ()=>{
|
|
12861
|
+
assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
|
|
12862
|
+
let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
12863
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
12864
|
+
let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes('.hot-update') && !f.endsWith('.css'));
|
|
12865
|
+
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];
|
|
12866
|
+
});
|
|
12867
|
+
});
|
|
12868
|
+
}
|
|
12869
|
+
}
|
|
12870
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
12871
|
+
name = binding_namespaceObject.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
|
|
12872
|
+
sharedOptions;
|
|
12873
|
+
injectTreeShakingUsedExports;
|
|
12874
|
+
manifestOptions;
|
|
12875
|
+
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
12876
|
+
super(), this.sharedOptions = sharedOptions, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
|
|
12877
|
+
}
|
|
12878
|
+
buildOptions() {
|
|
12879
|
+
let shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
12880
|
+
shareKey,
|
|
12881
|
+
treeShaking: !!config.treeShaking,
|
|
12882
|
+
usedExports: config.treeShaking?.usedExports
|
|
12883
|
+
})), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
12884
|
+
return {
|
|
12885
|
+
shared,
|
|
12886
|
+
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
12887
|
+
manifestFileName,
|
|
12888
|
+
statsFileName
|
|
12889
|
+
};
|
|
12890
|
+
}
|
|
12891
|
+
raw() {
|
|
12892
|
+
if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
|
|
12893
|
+
}
|
|
12894
|
+
}
|
|
12895
|
+
let VIRTUAL_ENTRY = './virtual-entry.js', VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
12896
|
+
class VirtualEntryPlugin {
|
|
12897
|
+
sharedOptions;
|
|
12898
|
+
collectShared = !1;
|
|
12899
|
+
constructor(sharedOptions, collectShared){
|
|
12900
|
+
this.sharedOptions = sharedOptions, this.collectShared = collectShared;
|
|
12901
|
+
}
|
|
12902
|
+
createEntry() {
|
|
12903
|
+
let { sharedOptions, collectShared } = this;
|
|
12904
|
+
return sharedOptions.reduce((acc, cur, index)=>acc + `import shared_${index} from '${cur[0]}';\n` + (collectShared ? `console.log(shared_${index});\n` : ''), '');
|
|
12905
|
+
}
|
|
12906
|
+
static entry() {
|
|
12907
|
+
return {
|
|
12908
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
12909
|
+
};
|
|
12910
|
+
}
|
|
12911
|
+
apply(compiler) {
|
|
12912
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
12913
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
12914
|
+
}).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
12915
|
+
compilation.hooks.processAssets.tap({
|
|
12916
|
+
name: 'RemoveVirtualEntryAsset',
|
|
12917
|
+
stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12918
|
+
}, ()=>{
|
|
12919
|
+
try {
|
|
12920
|
+
let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
12921
|
+
chunk?.files.forEach((f)=>{
|
|
12922
|
+
compilation.deleteAsset(f);
|
|
12923
|
+
});
|
|
12924
|
+
} catch (_e) {
|
|
12925
|
+
console.error('Failed to remove virtual entry file!');
|
|
12926
|
+
}
|
|
12927
|
+
});
|
|
12928
|
+
});
|
|
12929
|
+
}
|
|
12930
|
+
}
|
|
12931
|
+
let resolveOutputDir = (outputDir, shareName)=>shareName ? join(outputDir, encodeName(shareName)) : outputDir;
|
|
12932
|
+
class IndependentSharedPlugin {
|
|
12933
|
+
mfName;
|
|
12934
|
+
shared;
|
|
12935
|
+
library;
|
|
12936
|
+
sharedOptions;
|
|
12937
|
+
outputDir;
|
|
12938
|
+
plugins;
|
|
12939
|
+
treeShaking;
|
|
12940
|
+
manifest;
|
|
12941
|
+
buildAssets = {};
|
|
12942
|
+
injectTreeShakingUsedExports;
|
|
12943
|
+
treeShakingSharedExcludePlugins;
|
|
12944
|
+
name = 'IndependentSharedPlugin';
|
|
12945
|
+
constructor(options){
|
|
12946
|
+
let { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
12947
|
+
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)=>{
|
|
12948
|
+
if ('string' != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
12949
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12950
|
+
import: key,
|
|
12951
|
+
requiredVersion: item
|
|
12952
|
+
} : {
|
|
12953
|
+
import: item
|
|
12954
|
+
};
|
|
12955
|
+
}, (item)=>item);
|
|
12956
|
+
}
|
|
12957
|
+
apply(compiler) {
|
|
12958
|
+
let { manifest } = this, runCount = 0;
|
|
12959
|
+
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12960
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12961
|
+
}), compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12962
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12963
|
+
}), manifest && compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
12964
|
+
compilation.hooks.processAssets.tap({
|
|
12965
|
+
name: 'injectBuildAssets',
|
|
12966
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
12967
|
+
}, ()=>{
|
|
12968
|
+
let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
12969
|
+
let stats = compilation.getAsset(filename);
|
|
12970
|
+
if (!stats) return;
|
|
12971
|
+
let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
|
|
12972
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
12973
|
+
let targetShared = shared.find((s)=>s.name === key);
|
|
12974
|
+
targetShared && item.forEach(([entry, version, globalName])=>{
|
|
12975
|
+
version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
|
|
12976
|
+
});
|
|
12977
|
+
}), compilation.updateAsset(filename, new compiler.rspack.sources.RawSource(JSON.stringify(statsContent)));
|
|
12978
|
+
};
|
|
12979
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
12980
|
+
});
|
|
12981
|
+
});
|
|
12982
|
+
}
|
|
12983
|
+
async createIndependentCompilers(parentCompiler) {
|
|
12984
|
+
let { sharedOptions, buildAssets, outputDir } = this;
|
|
12985
|
+
console.log('Start building shared fallback resources ...');
|
|
12986
|
+
let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
12987
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
12988
|
+
if (!shareConfig.treeShaking || !1 === shareConfig.import) return;
|
|
12989
|
+
let shareRequests = shareRequestsMap[shareName].requests;
|
|
12990
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
12991
|
+
let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
12992
|
+
shareRequestsMap,
|
|
12993
|
+
currentShare: {
|
|
12994
|
+
shareName,
|
|
12995
|
+
version,
|
|
12996
|
+
request,
|
|
12997
|
+
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
12998
|
+
}
|
|
12999
|
+
});
|
|
13000
|
+
'string' == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
|
|
13001
|
+
join(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
13002
|
+
sharedVersion,
|
|
13003
|
+
globalName
|
|
13004
|
+
]));
|
|
13005
|
+
}));
|
|
13006
|
+
})), console.log('All shared fallback have been compiled successfully!');
|
|
13007
|
+
}
|
|
13008
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
13009
|
+
let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ''), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
|
|
13010
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
13011
|
+
mfName: `${mfName}_${treeShaking ? 't' : 'f'}`,
|
|
13012
|
+
library,
|
|
13013
|
+
...extraOptions.currentShare
|
|
13014
|
+
}) : new CollectSharedEntryPlugin({
|
|
13015
|
+
sharedOptions,
|
|
13016
|
+
shareScope: 'default'
|
|
13017
|
+
}), (parentConfig.plugins || []).forEach((plugin)=>{
|
|
13018
|
+
void 0 !== plugin && 'string' != typeof plugin && ((plugin, excludedPlugins = [])=>{
|
|
13019
|
+
if (!plugin) return !0;
|
|
13020
|
+
let pluginName = plugin.name || plugin.constructor?.name;
|
|
13021
|
+
return !pluginName || ![
|
|
13022
|
+
'TreeShakingSharedPlugin',
|
|
13023
|
+
'IndependentSharedPlugin',
|
|
13024
|
+
'ModuleFederationPlugin',
|
|
13025
|
+
'SharedUsedExportsOptimizerPlugin',
|
|
13026
|
+
'HtmlWebpackPlugin',
|
|
13027
|
+
'HtmlRspackPlugin',
|
|
13028
|
+
'RsbuildHtmlPlugin',
|
|
13029
|
+
...excludedPlugins
|
|
13030
|
+
].includes(pluginName);
|
|
13031
|
+
})(plugin, treeShakingSharedExcludePlugins) && finalPlugins.push(plugin);
|
|
13032
|
+
}), plugins.forEach((plugin)=>{
|
|
13033
|
+
finalPlugins.push(plugin);
|
|
13034
|
+
}), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
|
|
13035
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
13036
|
+
[key]: {
|
|
13037
|
+
import: !extraOptions && options.import,
|
|
13038
|
+
shareKey: options.shareKey || key,
|
|
13039
|
+
shareScope: options.shareScope,
|
|
13040
|
+
requiredVersion: options.requiredVersion,
|
|
13041
|
+
strictVersion: options.strictVersion,
|
|
13042
|
+
singleton: options.singleton,
|
|
13043
|
+
packageName: options.packageName,
|
|
13044
|
+
eager: options.eager
|
|
13045
|
+
}
|
|
13046
|
+
})),
|
|
13047
|
+
enhanced: !0
|
|
13048
|
+
})), treeShaking && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
13049
|
+
let fullOutputDir = external_node_path_resolve(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
|
|
13050
|
+
...parentConfig,
|
|
13051
|
+
module: {
|
|
13052
|
+
...parentConfig.module,
|
|
13053
|
+
rules: [
|
|
13054
|
+
{
|
|
13055
|
+
test: /virtual-entry\.js$/,
|
|
13056
|
+
type: "javascript/auto",
|
|
13057
|
+
resolve: {
|
|
13058
|
+
fullySpecified: !1
|
|
13059
|
+
},
|
|
13060
|
+
use: {
|
|
13061
|
+
loader: 'builtin:swc-loader'
|
|
13062
|
+
}
|
|
13063
|
+
},
|
|
13064
|
+
...parentConfig.module?.rules || []
|
|
13065
|
+
]
|
|
13066
|
+
},
|
|
13067
|
+
mode: parentConfig.mode || 'development',
|
|
13068
|
+
entry: VirtualEntryPlugin.entry,
|
|
13069
|
+
output: {
|
|
13070
|
+
path: fullOutputDir,
|
|
13071
|
+
clean: !0,
|
|
13072
|
+
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
13073
|
+
},
|
|
13074
|
+
plugins: finalPlugins,
|
|
13075
|
+
optimization: {
|
|
13076
|
+
...parentConfig.optimization,
|
|
13077
|
+
splitChunks: !1
|
|
13078
|
+
}
|
|
13079
|
+
}, compiler = rspack.rspack(compilerConfig);
|
|
13080
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
13081
|
+
let { currentShare } = extraOptions || {};
|
|
13082
|
+
return new Promise((resolve, reject)=>{
|
|
13083
|
+
compiler.run((err, stats)=>{
|
|
13084
|
+
if (err || stats?.hasErrors()) {
|
|
13085
|
+
let target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
13086
|
+
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n')), reject(err || Error(`${target} Compile failed`));
|
|
13087
|
+
return;
|
|
13088
|
+
}
|
|
13089
|
+
currentShare && console.log(`${currentShare.shareName} Compile success`), resolve(extraPlugin.getData());
|
|
13090
|
+
});
|
|
13091
|
+
});
|
|
13092
|
+
}
|
|
13093
|
+
}
|
|
13094
|
+
let TreeShakingSharedPlugin_require = createRequire(import.meta.url);
|
|
13095
|
+
class TreeShakingSharedPlugin {
|
|
13096
|
+
mfConfig;
|
|
13097
|
+
outputDir;
|
|
13098
|
+
secondary;
|
|
13099
|
+
_independentSharePlugin;
|
|
13100
|
+
name = 'TreeShakingSharedPlugin';
|
|
13101
|
+
constructor(options){
|
|
13102
|
+
let { mfConfig, secondary } = options;
|
|
13103
|
+
this.mfConfig = mfConfig, this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages', this.secondary = !!secondary;
|
|
13104
|
+
}
|
|
13105
|
+
apply(compiler) {
|
|
13106
|
+
let { mfConfig, outputDir, secondary } = this, { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
13107
|
+
if (!shared) return;
|
|
13108
|
+
let sharedOptions = normalizeSharedOptions(shared);
|
|
13109
|
+
sharedOptions.length && sharedOptions.some(([_, config])=>config.treeShaking && !1 !== config.import) && (secondary || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
|
|
13110
|
+
name: name,
|
|
13111
|
+
shared: shared,
|
|
13112
|
+
outputDir,
|
|
13113
|
+
plugins: treeShakingSharedPlugins?.map((p)=>new (TreeShakingSharedPlugin_require(p))()) || [],
|
|
13114
|
+
treeShaking: secondary,
|
|
13115
|
+
library,
|
|
13116
|
+
manifest: mfConfig.manifest,
|
|
13117
|
+
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
13118
|
+
}), this._independentSharePlugin.apply(compiler));
|
|
13119
|
+
}
|
|
13120
|
+
get buildAssets() {
|
|
13121
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
13122
|
+
}
|
|
13123
|
+
}
|
|
13124
|
+
let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), ModuleFederationPlugin_require = createRequire(import.meta.url);
|
|
13125
|
+
function getRemoteInfos(options) {
|
|
13126
|
+
if (!options.remotes) return {};
|
|
13127
|
+
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
13128
|
+
external: Array.isArray(item) ? item : [
|
|
13129
|
+
item
|
|
13130
|
+
],
|
|
13131
|
+
shareScope: options.shareScope ?? 'default'
|
|
13132
|
+
}), (item)=>({
|
|
13133
|
+
external: Array.isArray(item.external) ? item.external : [
|
|
13134
|
+
item.external
|
|
13135
|
+
],
|
|
13136
|
+
shareScope: item.shareScope || options.shareScope || 'default'
|
|
13137
|
+
})), remoteInfos = {};
|
|
13138
|
+
for (let [key, config] of remotes)for (let external of config.external){
|
|
13139
|
+
let [externalType, externalRequest] = function(external) {
|
|
13140
|
+
let result = function(external) {
|
|
13141
|
+
if (/^[a-z0-9-]+ /.test(external)) {
|
|
13142
|
+
let idx = external.indexOf(' ');
|
|
13143
|
+
return [
|
|
13144
|
+
external.slice(0, idx),
|
|
13145
|
+
external.slice(idx + 1)
|
|
13146
|
+
];
|
|
13147
|
+
}
|
|
13148
|
+
return null;
|
|
13149
|
+
}(external);
|
|
13150
|
+
return null === result ? [
|
|
13151
|
+
remoteType,
|
|
13152
|
+
external
|
|
13153
|
+
] : result;
|
|
13154
|
+
}(external);
|
|
13155
|
+
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
13156
|
+
let [url, global] = function(urlAndGlobal) {
|
|
13157
|
+
let index = urlAndGlobal.indexOf('@');
|
|
13158
|
+
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
13159
|
+
urlAndGlobal.substring(index + 1),
|
|
13160
|
+
urlAndGlobal.substring(0, index)
|
|
13161
|
+
];
|
|
13162
|
+
}(externalRequest);
|
|
13163
|
+
remoteInfos[key].push({
|
|
13164
|
+
alias: key,
|
|
13165
|
+
name: global,
|
|
13166
|
+
entry: url,
|
|
13167
|
+
externalType,
|
|
13168
|
+
shareScope: config.shareScope
|
|
13169
|
+
});
|
|
13170
|
+
} else remoteInfos[key].push({
|
|
13171
|
+
alias: key,
|
|
13172
|
+
name: void 0,
|
|
13173
|
+
entry: void 0,
|
|
13174
|
+
externalType,
|
|
13175
|
+
shareScope: config.shareScope
|
|
13176
|
+
});
|
|
13177
|
+
}
|
|
13178
|
+
return remoteInfos;
|
|
13179
|
+
}
|
|
13180
|
+
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
13181
|
+
let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || 'var';
|
|
13182
|
+
for(let i = 0; i < runtimePlugins.length; i++){
|
|
13183
|
+
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;
|
|
13184
|
+
runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
|
|
13185
|
+
let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
|
|
13186
|
+
runtimePluginVars.push(`{ plugin: ${runtimePluginVar}, params: ${paramsCode} }`);
|
|
13187
|
+
}
|
|
13188
|
+
let content = [
|
|
13189
|
+
`import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
|
|
13190
|
+
...runtimePluginImports,
|
|
13191
|
+
`const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}].filter(({ plugin }) => plugin).map(({ plugin, params }) => plugin(params))`,
|
|
13192
|
+
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
13193
|
+
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
13194
|
+
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
13195
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
13196
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
13197
|
+
compiler.rspack.Template.getFunctionContent(ModuleFederationPlugin_require('./moduleFederationDefaultRuntime.js').default)
|
|
13198
|
+
].join(';');
|
|
13199
|
+
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${encodeURIComponent(content)}`;
|
|
13200
|
+
}
|
|
12134
13201
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
12135
13202
|
name = binding_namespaceObject.BuiltinPluginName.ContainerPlugin;
|
|
12136
13203
|
_options;
|
|
12137
13204
|
constructor(options){
|
|
12138
|
-
super()
|
|
13205
|
+
super();
|
|
13206
|
+
let shareScope = options.shareScope || 'default', enhanced = options.enhanced ?? !1;
|
|
13207
|
+
validateShareScope(shareScope, enhanced, 'ContainerPlugin'), this._options = {
|
|
12139
13208
|
name: options.name,
|
|
12140
|
-
shareScope
|
|
13209
|
+
shareScope,
|
|
12141
13210
|
library: options.library || {
|
|
12142
|
-
type: '
|
|
13211
|
+
type: 'global',
|
|
12143
13212
|
name: options.name
|
|
12144
13213
|
},
|
|
12145
13214
|
runtime: options.runtime,
|
|
@@ -12155,7 +13224,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
12155
13224
|
],
|
|
12156
13225
|
name: item.name || void 0
|
|
12157
13226
|
})),
|
|
12158
|
-
enhanced
|
|
13227
|
+
enhanced
|
|
12159
13228
|
};
|
|
12160
13229
|
}
|
|
12161
13230
|
raw(compiler) {
|
|
@@ -12180,29 +13249,38 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
|
|
|
12180
13249
|
name = binding_namespaceObject.BuiltinPluginName.ContainerReferencePlugin;
|
|
12181
13250
|
_options;
|
|
12182
13251
|
constructor(options){
|
|
12183
|
-
super()
|
|
13252
|
+
super();
|
|
13253
|
+
let enhanced = options.enhanced ?? !1;
|
|
13254
|
+
options.shareScope && validateShareScope(options.shareScope, enhanced, 'ContainerReferencePlugin');
|
|
13255
|
+
let remotes = parseOptions(options.remotes, (item)=>({
|
|
13256
|
+
external: Array.isArray(item) ? item : [
|
|
13257
|
+
item
|
|
13258
|
+
],
|
|
13259
|
+
shareScope: options.shareScope || 'default'
|
|
13260
|
+
}), (item)=>({
|
|
13261
|
+
external: Array.isArray(item.external) ? item.external : [
|
|
13262
|
+
item.external
|
|
13263
|
+
],
|
|
13264
|
+
shareScope: item.shareScope || options.shareScope || 'default'
|
|
13265
|
+
}));
|
|
13266
|
+
for (let [, config] of remotes)validateShareScope(config.shareScope, enhanced, 'ContainerReferencePlugin');
|
|
13267
|
+
this._options = {
|
|
12184
13268
|
remoteType: options.remoteType,
|
|
12185
|
-
remotes
|
|
12186
|
-
|
|
12187
|
-
item
|
|
12188
|
-
],
|
|
12189
|
-
shareScope: options.shareScope || 'default'
|
|
12190
|
-
}), (item)=>({
|
|
12191
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
12192
|
-
item.external
|
|
12193
|
-
],
|
|
12194
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
12195
|
-
})),
|
|
12196
|
-
enhanced: options.enhanced ?? !1
|
|
13269
|
+
remotes,
|
|
13270
|
+
enhanced
|
|
12197
13271
|
};
|
|
12198
13272
|
}
|
|
12199
13273
|
raw(compiler) {
|
|
12200
|
-
let { remoteType, remotes } = this._options, remoteExternals = {};
|
|
13274
|
+
let { remoteType, remotes } = this._options, remoteExternals = {}, importExternals = {};
|
|
12201
13275
|
for (let [key, config] of remotes){
|
|
12202
13276
|
let i = 0;
|
|
12203
|
-
for (let external of config.external)
|
|
13277
|
+
for (let external of config.external){
|
|
13278
|
+
if (external.startsWith('internal ')) continue;
|
|
13279
|
+
let request = `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`;
|
|
13280
|
+
('module' === remoteType || 'module-import' === remoteType) && external.startsWith('.') ? importExternals[request] = external : remoteExternals[request] = external, i++;
|
|
13281
|
+
}
|
|
12204
13282
|
}
|
|
12205
|
-
new ExternalsPlugin(remoteType, remoteExternals, !0).apply(compiler), new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
13283
|
+
new ExternalsPlugin(remoteType, remoteExternals, !0).apply(compiler), Object.keys(importExternals).length > 0 && new ExternalsPlugin('import', importExternals, !0).apply(compiler), new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
12206
13284
|
let rawOptions = {
|
|
12207
13285
|
remoteType: this._options.remoteType,
|
|
12208
13286
|
remotes: this._options.remotes.map(([key, r])=>({
|
|
@@ -12222,7 +13300,7 @@ async function transform(source, options) {
|
|
|
12222
13300
|
let _options = JSON.stringify(options || {});
|
|
12223
13301
|
return binding_default().transform(source, _options);
|
|
12224
13302
|
}
|
|
12225
|
-
let exports_rspackVersion = "2.0.0-
|
|
13303
|
+
let exports_rspackVersion = "2.0.0-rc.0", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
|
|
12226
13304
|
getNormalizedRspackOptions: getNormalizedRspackOptions,
|
|
12227
13305
|
applyRspackOptionsDefaults: applyRspackOptionsDefaults,
|
|
12228
13306
|
getNormalizedWebpackOptions: getNormalizedRspackOptions,
|
|
@@ -12265,10 +13343,12 @@ let exports_rspackVersion = "2.0.0-canary.20260120", exports_version = "5.75.0",
|
|
|
12265
13343
|
ContainerReferencePlugin: ContainerReferencePlugin,
|
|
12266
13344
|
ModuleFederationPlugin: class {
|
|
12267
13345
|
_options;
|
|
13346
|
+
_treeShakingSharedPlugin;
|
|
12268
13347
|
constructor(_options){
|
|
12269
13348
|
this._options = _options;
|
|
12270
13349
|
}
|
|
12271
13350
|
apply(compiler) {
|
|
13351
|
+
var options;
|
|
12272
13352
|
let { webpack } = compiler, paths = function(options, compiler) {
|
|
12273
13353
|
let runtimeToolsPath;
|
|
12274
13354
|
if (options.implementation) runtimeToolsPath = options.implementation;
|
|
@@ -12297,101 +13377,55 @@ let exports_rspackVersion = "2.0.0-canary.20260120", exports_version = "5.75.0",
|
|
|
12297
13377
|
runtime: runtimePath
|
|
12298
13378
|
};
|
|
12299
13379
|
}(this._options, compiler);
|
|
12300
|
-
|
|
13380
|
+
compiler.options.resolve.alias = {
|
|
12301
13381
|
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
12302
13382
|
'@module-federation/runtime': paths.runtime,
|
|
12303
13383
|
...compiler.options.resolve.alias
|
|
12304
|
-
},
|
|
12305
|
-
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
13384
|
+
}, ((options = this._options).shared ? parseOptions(options.shared, (item, key)=>{
|
|
13385
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
13386
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
13387
|
+
import: key,
|
|
13388
|
+
requiredVersion: item
|
|
13389
|
+
} : {
|
|
13390
|
+
import: item
|
|
13391
|
+
};
|
|
13392
|
+
}, (item)=>item) : []).filter(([, config])=>config.treeShaking).length > 0 && (this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
|
|
13393
|
+
mfConfig: this._options,
|
|
13394
|
+
secondary: !1
|
|
13395
|
+
}), this._treeShakingSharedPlugin.apply(compiler));
|
|
13396
|
+
let runtimeExperiments = {
|
|
13397
|
+
asyncStartup: this._options.experiments?.asyncStartup ?? !1
|
|
13398
|
+
}, runtimePluginApplied = !1;
|
|
13399
|
+
compiler.hooks.beforeRun.tap({
|
|
13400
|
+
name: 'ModuleFederationPlugin',
|
|
13401
|
+
stage: 100
|
|
13402
|
+
}, ()=>{
|
|
13403
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
13404
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets),
|
|
13405
|
+
experiments: runtimeExperiments
|
|
13406
|
+
}).apply(compiler));
|
|
13407
|
+
}), compiler.hooks.watchRun.tap({
|
|
13408
|
+
name: 'ModuleFederationPlugin',
|
|
13409
|
+
stage: 100
|
|
13410
|
+
}, ()=>{
|
|
13411
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
13412
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {}),
|
|
13413
|
+
experiments: runtimeExperiments
|
|
13414
|
+
}).apply(compiler));
|
|
13415
|
+
});
|
|
13416
|
+
let v1Options = {
|
|
13417
|
+
name: this._options.name,
|
|
13418
|
+
exposes: this._options.exposes,
|
|
13419
|
+
filename: this._options.filename,
|
|
13420
|
+
library: this._options.library,
|
|
13421
|
+
remoteType: this._options.remoteType,
|
|
13422
|
+
remotes: this._options.remotes,
|
|
13423
|
+
runtime: this._options.runtime,
|
|
13424
|
+
shareScope: this._options.shareScope,
|
|
13425
|
+
shared: this._options.shared,
|
|
12326
13426
|
enhanced: !0
|
|
12327
|
-
}
|
|
12328
|
-
|
|
12329
|
-
...this._options.manifest
|
|
12330
|
-
}, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
|
|
12331
|
-
if (!library) return;
|
|
12332
|
-
let libName = library.name;
|
|
12333
|
-
if (libName) {
|
|
12334
|
-
if ('string' == typeof libName) return libName;
|
|
12335
|
-
if (Array.isArray(libName)) return libName[0];
|
|
12336
|
-
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12337
|
-
}
|
|
12338
|
-
}(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
12339
|
-
if (cur[1].length > 1) return sum;
|
|
12340
|
-
let { entry, alias, name } = cur[1][0];
|
|
12341
|
-
return entry && name && (sum[alias] = {
|
|
12342
|
-
name,
|
|
12343
|
-
entry
|
|
12344
|
-
}), sum;
|
|
12345
|
-
}, {}), manifestExposes = function(exposes) {
|
|
12346
|
-
if (!exposes) return;
|
|
12347
|
-
let result = parseOptions(exposes, (value)=>({
|
|
12348
|
-
import: Array.isArray(value) ? value : [
|
|
12349
|
-
value
|
|
12350
|
-
],
|
|
12351
|
-
name: void 0
|
|
12352
|
-
}), (value)=>({
|
|
12353
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
12354
|
-
value.import
|
|
12355
|
-
],
|
|
12356
|
-
name: value.name ?? void 0
|
|
12357
|
-
})).map(([exposeKey, info])=>{
|
|
12358
|
-
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12359
|
-
return {
|
|
12360
|
-
path: exposeKey,
|
|
12361
|
-
name: exposeName
|
|
12362
|
-
};
|
|
12363
|
-
});
|
|
12364
|
-
return result.length > 0 ? result : void 0;
|
|
12365
|
-
}(this._options.exposes);
|
|
12366
|
-
void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
|
|
12367
|
-
let manifestShared = function(shared) {
|
|
12368
|
-
if (!shared) return;
|
|
12369
|
-
let result = parseOptions(shared, (item, key)=>{
|
|
12370
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12371
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12372
|
-
import: key,
|
|
12373
|
-
requiredVersion: item
|
|
12374
|
-
} : {
|
|
12375
|
-
import: item
|
|
12376
|
-
};
|
|
12377
|
-
}, (item)=>item).map(([key, config])=>{
|
|
12378
|
-
let name = config.shareKey || key;
|
|
12379
|
-
return {
|
|
12380
|
-
name,
|
|
12381
|
-
version: 'string' == typeof config.version ? config.version : void 0,
|
|
12382
|
-
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12383
|
-
singleton: config.singleton
|
|
12384
|
-
};
|
|
12385
|
-
});
|
|
12386
|
-
return result.length > 0 ? result : void 0;
|
|
12387
|
-
}(this._options.shared);
|
|
12388
|
-
void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
|
|
12389
|
-
...manifestOptions,
|
|
12390
|
-
name: containerName,
|
|
12391
|
-
globalName,
|
|
12392
|
-
remoteAliasMap
|
|
12393
|
-
}).apply(compiler);
|
|
12394
|
-
}
|
|
13427
|
+
};
|
|
13428
|
+
new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
12395
13429
|
}
|
|
12396
13430
|
},
|
|
12397
13431
|
ModuleFederationPluginV1: class {
|
|
@@ -12428,6 +13462,7 @@ let exports_rspackVersion = "2.0.0-canary.20260120", exports_version = "5.75.0",
|
|
|
12428
13462
|
}
|
|
12429
13463
|
}, sharing = {
|
|
12430
13464
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
13465
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
12431
13466
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
12432
13467
|
SharePlugin: SharePlugin
|
|
12433
13468
|
}, exports_experiments = {
|
|
@@ -12439,8 +13474,7 @@ let exports_rspackVersion = "2.0.0-canary.20260120", exports_version = "5.75.0",
|
|
|
12439
13474
|
await JavaScriptTracer.cleanupJavaScriptTrace(), (0, binding_namespaceObject.syncTraceEvent)(JavaScriptTracer.events), (0, binding_namespaceObject.cleanupGlobalTrace)();
|
|
12440
13475
|
}
|
|
12441
13476
|
},
|
|
12442
|
-
RemoveDuplicateModulesPlugin:
|
|
12443
|
-
EsmLibraryPlugin: EsmLibraryPlugin,
|
|
13477
|
+
RemoveDuplicateModulesPlugin: RemoveDuplicateModulesPlugin_RemoveDuplicateModulesPlugin,
|
|
12444
13478
|
RsdoctorPlugin: RsdoctorPluginImpl,
|
|
12445
13479
|
RstestPlugin: RstestPlugin,
|
|
12446
13480
|
RslibPlugin: RslibPlugin,
|
|
@@ -12467,12 +13501,36 @@ let exports_rspackVersion = "2.0.0-canary.20260120", exports_version = "5.75.0",
|
|
|
12467
13501
|
if (INTERNAL_PLUGIN_NAMES.includes(name)) throw Error(`Cannot register native plugin with name '${name}', it conflicts with internal plugin names.`);
|
|
12468
13502
|
return base_create(name, resolve, affectedHooks);
|
|
12469
13503
|
},
|
|
12470
|
-
VirtualModulesPlugin: VirtualModulesPlugin
|
|
12471
|
-
|
|
13504
|
+
VirtualModulesPlugin: VirtualModulesPlugin,
|
|
13505
|
+
rsc: {
|
|
13506
|
+
createPlugins: ()=>{
|
|
13507
|
+
let coordinator = new Coordinator();
|
|
13508
|
+
return {
|
|
13509
|
+
ServerPlugin: class extends RscServerPlugin {
|
|
13510
|
+
constructor(options = {}){
|
|
13511
|
+
super({
|
|
13512
|
+
coordinator,
|
|
13513
|
+
...options
|
|
13514
|
+
});
|
|
13515
|
+
}
|
|
13516
|
+
},
|
|
13517
|
+
ClientPlugin: class extends RscClientPlugin {
|
|
13518
|
+
constructor(){
|
|
13519
|
+
super({
|
|
13520
|
+
coordinator
|
|
13521
|
+
});
|
|
13522
|
+
}
|
|
13523
|
+
}
|
|
13524
|
+
};
|
|
13525
|
+
},
|
|
13526
|
+
Layers: {
|
|
13527
|
+
rsc: 'react-server-components',
|
|
13528
|
+
ssr: 'server-side-rendering'
|
|
13529
|
+
}
|
|
13530
|
+
}
|
|
13531
|
+
}, src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
|
|
12472
13532
|
src_fn.rspack = src_fn, src_fn.webpack = src_fn;
|
|
12473
13533
|
let src_rspack_0 = src_fn;
|
|
12474
13534
|
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;
|
|
12475
13535
|
export default src_rspack_0;
|
|
12476
|
-
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 };
|
|
12477
|
-
|
|
12478
|
-
export { src_rspack_0 as 'module.exports' }
|
|
13536
|
+
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 };
|