@rspack-debug/core 2.0.0-canary-20260116 → 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/{browserslist-load-config → http-proxy-middleware}/license +3 -2
- 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 +7 -4
- 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/lightningcss/index.d.ts +11 -9
- package/dist/builtin-loader/lightningcss/target.d.ts +4 -0
- package/dist/builtin-loader/swc/index.d.ts +2 -2
- 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 +5 -1
- package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +9 -0
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +5 -4
- 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/SwcJsMinimizerPlugin.d.ts +3 -2
- 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/adapterRuleUse.d.ts +2 -1
- package/dist/config/defaults.d.ts +4 -2
- package/dist/config/devServer.d.ts +102 -237
- package/dist/config/normalization.d.ts +2 -3
- package/dist/config/target.d.ts +14 -11
- package/dist/config/types.d.ts +151 -62
- 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/cssExtractLoader.js +3 -3
- package/dist/exports.d.ts +11 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2074 -707
- 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/util/targetsVersion.d.ts +2 -0
- package/dist/worker.js +20 -19
- package/hot/dev-server.js +1 -1
- package/hot/emitter.js +0 -2
- package/hot/lazy-compilation-node.js +91 -34
- package/hot/lazy-compilation-web.js +61 -35
- package/hot/log.js +0 -2
- package/hot/only-dev-server.js +1 -1
- package/module.d.ts +4 -2
- package/package.json +23 -24
- package/compiled/browserslist-load-config/index.d.ts +0 -21
- package/compiled/browserslist-load-config/index.js +0 -252
- package/compiled/browserslist-load-config/package.json +0 -1
- package/dist/builtin-loader/index.d.ts +0 -1
- 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,32 +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
|
-
class EsmLibraryPlugin {
|
|
2167
|
-
static PLUGIN_NAME = 'EsmLibraryPlugin';
|
|
2168
|
-
options;
|
|
2169
|
-
constructor(options){
|
|
2170
|
-
this.options = options;
|
|
2171
|
-
}
|
|
2172
|
-
apply(compiler) {
|
|
2173
|
-
var config;
|
|
2174
|
-
let err, logger = compiler.getInfrastructureLogger(EsmLibraryPlugin.PLUGIN_NAME);
|
|
2175
|
-
if (!function(options, logger) {
|
|
2176
|
-
options.optimization.concatenateModules = !1, options.optimization.removeEmptyChunks = !1, options.output.chunkFormat = !1, options.output.module = !0, options.output.chunkLoading && 'import' !== options.output.chunkLoading && (logger.warn(`\`output.chunkLoading\` should be \`"import"\` or \`false\`, but got ${options.output.chunkLoading}, changed it to \`"import"\``), options.output.chunkLoading = 'import'), void 0 === options.output.chunkLoading && (options.output.chunkLoading = 'import'), options.output.library && (options.output.library = void 0);
|
|
2177
|
-
let { splitChunks } = options.optimization;
|
|
2178
|
-
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);
|
|
2179
|
-
}(compiler.options, logger), new RemoveDuplicateModulesPlugin().apply(compiler), err = (config = compiler.options).optimization.concatenateModules ? 'You should disable `config.optimization.concatenateModules`' : !1 !== 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}`);
|
|
2180
|
-
compiler.__internal__registerBuiltinPlugin({
|
|
2181
|
-
name: binding_namespaceObject.BuiltinPluginName.EsmLibraryPlugin,
|
|
2182
|
-
options: {
|
|
2183
|
-
preserveModules: this.options?.preserveModules
|
|
2184
|
-
}
|
|
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)
|
|
2185
2782
|
});
|
|
2186
2783
|
}
|
|
2187
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);
|
|
2188
2787
|
let EvalDevToolModulePlugin = base_create(binding_namespaceObject.BuiltinPluginName.EvalDevToolModulePlugin, (options)=>options, 'compilation'), EvalSourceMapDevToolPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EvalSourceMapDevToolPlugin, (options)=>options, 'compilation');
|
|
2189
2788
|
function isNil(value) {
|
|
2190
2789
|
return null == value;
|
|
@@ -2285,6 +2884,45 @@ let unsupported = (name, issue)=>{
|
|
|
2285
2884
|
query: match[2] ? match[2].replace(/\u200b(.)/g, '$1') : ''
|
|
2286
2885
|
};
|
|
2287
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
|
+
}
|
|
2892
|
+
function encodeVersion(version) {
|
|
2893
|
+
let [major, minor = 0, patch = 0] = version.split('-')[0].split('.').map((v)=>parseInt(v, 10));
|
|
2894
|
+
return Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) ? null : major << 16 | minor << 8 | patch;
|
|
2895
|
+
}
|
|
2896
|
+
function decodeVersion(n) {
|
|
2897
|
+
return `${n >> 16 & 0xff}.${n >> 8 & 0xff}.${0xff & n}`;
|
|
2898
|
+
}
|
|
2899
|
+
function encodeTargets(targets) {
|
|
2900
|
+
return Object.fromEntries(Object.entries(targets).map(([k, v])=>[
|
|
2901
|
+
k,
|
|
2902
|
+
encodeVersion(v)
|
|
2903
|
+
]));
|
|
2904
|
+
}
|
|
2905
|
+
function defaultTargetsFromRspackTargets(targets) {
|
|
2906
|
+
let REMAP = {
|
|
2907
|
+
and_chr: 'chrome',
|
|
2908
|
+
and_ff: 'firefox',
|
|
2909
|
+
ie_mob: 'ie',
|
|
2910
|
+
op_mob: 'opera',
|
|
2911
|
+
and_qq: null,
|
|
2912
|
+
and_uc: null,
|
|
2913
|
+
baidu: null,
|
|
2914
|
+
bb: null,
|
|
2915
|
+
kaios: null,
|
|
2916
|
+
op_mini: null
|
|
2917
|
+
}, result = {};
|
|
2918
|
+
for (let [k, v] of Object.entries(targets)){
|
|
2919
|
+
let remap = REMAP[k];
|
|
2920
|
+
if (null === remap) continue;
|
|
2921
|
+
let name = remap || k, version = encodeVersion(v);
|
|
2922
|
+
null !== version && (result[name] = version);
|
|
2923
|
+
}
|
|
2924
|
+
return result;
|
|
2925
|
+
}
|
|
2288
2926
|
function toFeatures(featureOptions) {
|
|
2289
2927
|
let feature = 0;
|
|
2290
2928
|
for (let key of Reflect.ownKeys(featureOptions))if (!0 === featureOptions[key]) switch(key){
|
|
@@ -2359,6 +2997,25 @@ function toFeatures(featureOptions) {
|
|
|
2359
2997
|
}
|
|
2360
2998
|
return feature;
|
|
2361
2999
|
}
|
|
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
|
+
});
|
|
3018
|
+
}
|
|
2362
3019
|
let $assets = Symbol('assets');
|
|
2363
3020
|
Object.defineProperty(binding_default().KnownBuildInfo.prototype, node_util.inspect.custom, {
|
|
2364
3021
|
enumerable: !0,
|
|
@@ -2442,8 +3099,7 @@ Object.defineProperty(binding_default().NormalModule.prototype, 'identifier', {
|
|
|
2442
3099
|
value (filename, source, assetInfo) {
|
|
2443
3100
|
return this._emitFile(filename, SourceAdapter.toBinding(source), assetInfo);
|
|
2444
3101
|
}
|
|
2445
|
-
})
|
|
2446
|
-
Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
3102
|
+
}), Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
2447
3103
|
enumerable: !0,
|
|
2448
3104
|
configurable: !0,
|
|
2449
3105
|
value (compilation) {
|
|
@@ -2454,40 +3110,6 @@ Object.defineProperty(binding_default().NormalModule, 'getCompilationHooks', {
|
|
|
2454
3110
|
'loaderContext',
|
|
2455
3111
|
'module'
|
|
2456
3112
|
]),
|
|
2457
|
-
readResourceForScheme: new HookMap((scheme)=>{
|
|
2458
|
-
let fakeHook, message, code, hook = hooks.readResource.for(scheme);
|
|
2459
|
-
return fakeHook = {
|
|
2460
|
-
tap: (options, fn)=>hook.tap(options, (loaderContext)=>fn(loaderContext.resource)),
|
|
2461
|
-
tapAsync: (options, fn)=>hook.tapAsync(options, (loaderContext, callback)=>fn(loaderContext.resource, callback)),
|
|
2462
|
-
tapPromise: (options, fn)=>hook.tapPromise(options, (loaderContext)=>fn(loaderContext.resource))
|
|
2463
|
-
}, Object.freeze(Object.assign(message && code ? ((obj, message, code)=>{
|
|
2464
|
-
let newObj = {}, descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
2465
|
-
for (let name of Object.keys(descriptors)){
|
|
2466
|
-
let descriptor = descriptors[name];
|
|
2467
|
-
if ('function' == typeof descriptor.value) Object.defineProperty(newObj, name, {
|
|
2468
|
-
...descriptor,
|
|
2469
|
-
value: node_util.deprecate(descriptor.value, message, code)
|
|
2470
|
-
});
|
|
2471
|
-
else if (descriptor.get || descriptor.set) Object.defineProperty(newObj, name, {
|
|
2472
|
-
...descriptor,
|
|
2473
|
-
get: descriptor.get && node_util.deprecate(descriptor.get, message, code),
|
|
2474
|
-
set: descriptor.set && node_util.deprecate(descriptor.set, message, code)
|
|
2475
|
-
});
|
|
2476
|
-
else {
|
|
2477
|
-
let value = descriptor.value;
|
|
2478
|
-
Object.defineProperty(newObj, name, {
|
|
2479
|
-
configurable: descriptor.configurable,
|
|
2480
|
-
enumerable: descriptor.enumerable,
|
|
2481
|
-
get: node_util.deprecate(()=>value, message, code),
|
|
2482
|
-
set: descriptor.writable ? node_util.deprecate((v)=>value = v, message, code) : void 0
|
|
2483
|
-
});
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2486
|
-
return newObj;
|
|
2487
|
-
})(fakeHook, message, code) : fakeHook, {
|
|
2488
|
-
_fakeHook: !0
|
|
2489
|
-
}));
|
|
2490
|
-
}),
|
|
2491
3113
|
readResource: new HookMap(()=>new AsyncSeriesBailHook([
|
|
2492
3114
|
'loaderContext'
|
|
2493
3115
|
]))
|
|
@@ -2742,20 +3364,6 @@ class BulkUpdateDecorator extends Hash {
|
|
|
2742
3364
|
return void 0 !== digestCache && 'string' == typeof result && digestCache.set(buffer, result), result;
|
|
2743
3365
|
}
|
|
2744
3366
|
}
|
|
2745
|
-
class DebugHash extends Hash {
|
|
2746
|
-
string;
|
|
2747
|
-
constructor(){
|
|
2748
|
-
super(), this.string = '';
|
|
2749
|
-
}
|
|
2750
|
-
update(data) {
|
|
2751
|
-
let normalizedData;
|
|
2752
|
-
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;
|
|
2753
|
-
}
|
|
2754
|
-
digest(encoding) {
|
|
2755
|
-
let result = `debug-digest-${Buffer.from(this.string).toString('hex')}`;
|
|
2756
|
-
return encoding ? result : Buffer.from(result);
|
|
2757
|
-
}
|
|
2758
|
-
}
|
|
2759
3367
|
class WasmHashAdapter extends Hash {
|
|
2760
3368
|
wasmHash;
|
|
2761
3369
|
constructor(wasmHash){
|
|
@@ -2771,8 +3379,6 @@ class WasmHashAdapter extends Hash {
|
|
|
2771
3379
|
let createHash_createHash = (algorithm)=>{
|
|
2772
3380
|
if ('function' == typeof algorithm) return new BulkUpdateDecorator(()=>new algorithm());
|
|
2773
3381
|
switch(algorithm){
|
|
2774
|
-
case 'debug':
|
|
2775
|
-
return new DebugHash();
|
|
2776
3382
|
case 'xxhash64':
|
|
2777
3383
|
return new WasmHashAdapter((()=>{
|
|
2778
3384
|
if (!createXxhash64) {
|
|
@@ -3332,7 +3938,7 @@ async function runLoaders(compiler, context) {
|
|
|
3332
3938
|
_compiler: {
|
|
3333
3939
|
options: {
|
|
3334
3940
|
experiments: {
|
|
3335
|
-
css:
|
|
3941
|
+
css: !0
|
|
3336
3942
|
}
|
|
3337
3943
|
}
|
|
3338
3944
|
},
|
|
@@ -3575,41 +4181,53 @@ function createRawModuleRuleUses(uses, path, options) {
|
|
|
3575
4181
|
let o, isBuiltin = !1;
|
|
3576
4182
|
if (use.loader.startsWith(BUILTIN_LOADER_PREFIX)) {
|
|
3577
4183
|
let temp = function(identifier, o, options) {
|
|
3578
|
-
if (identifier.startsWith(`${BUILTIN_LOADER_PREFIX}swc-loader`)) return ((
|
|
3579
|
-
|
|
4184
|
+
if (identifier.startsWith(`${BUILTIN_LOADER_PREFIX}swc-loader`)) return ((o, composeOptions)=>{
|
|
4185
|
+
let options = o ?? {};
|
|
4186
|
+
if ('object' == typeof options) {
|
|
3580
4187
|
var options1;
|
|
3581
|
-
options.jsc ??= {}, options.jsc.experimental ??= {}, options.jsc.experimental.disableAllLints ??= !0, options.
|
|
4188
|
+
if (options.jsc ??= {}, options.jsc.experimental ??= {}, options.jsc.experimental.disableAllLints ??= !0, options.env?.targets === void 0 && options.jsc?.target === void 0) {
|
|
4189
|
+
if (composeOptions.compiler.target?.targets) options.env ??= {}, options.env.targets ??= function(targets) {
|
|
4190
|
+
let REMAP = {
|
|
4191
|
+
and_chr: 'chrome',
|
|
4192
|
+
and_ff: 'firefox',
|
|
4193
|
+
ie_mob: 'ie',
|
|
4194
|
+
ios_saf: 'ios',
|
|
4195
|
+
op_mob: 'opera',
|
|
4196
|
+
and_qq: null,
|
|
4197
|
+
and_uc: null,
|
|
4198
|
+
baidu: null,
|
|
4199
|
+
bb: null,
|
|
4200
|
+
kaios: null,
|
|
4201
|
+
op_mini: null
|
|
4202
|
+
}, result = {};
|
|
4203
|
+
for (let [k, version] of Object.entries(targets)){
|
|
4204
|
+
let remap = REMAP[k];
|
|
4205
|
+
null !== remap && (result[remap || k] = version);
|
|
4206
|
+
}
|
|
4207
|
+
return result;
|
|
4208
|
+
}(composeOptions.compiler.target.targets);
|
|
4209
|
+
else if (composeOptions.compiler.target?.esVersion) {
|
|
4210
|
+
let { esVersion } = composeOptions.compiler.target;
|
|
4211
|
+
options.jsc.target ??= esVersion >= 2015 ? `es${esVersion}` : 'es5';
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
options.collectTypeScriptInfo && (options.collectTypeScriptInfo = {
|
|
3582
4215
|
typeExports: (options1 = options.collectTypeScriptInfo).typeExports,
|
|
3583
4216
|
exportedEnum: !0 === options1.exportedEnum ? 'all' : !1 === options1.exportedEnum || void 0 === options1.exportedEnum ? 'none' : 'const-only'
|
|
3584
|
-
});
|
|
4217
|
+
}), options.transformImport && (options.transformImport = resolvePluginImport(options.transformImport));
|
|
3585
4218
|
let { rspackExperiments } = options;
|
|
3586
|
-
rspackExperiments && (rspackExperiments.import || rspackExperiments.pluginImport) && (rspackExperiments.import =
|
|
3587
|
-
if (pluginImport) return pluginImport.map((config)=>{
|
|
3588
|
-
let rawConfig = {
|
|
3589
|
-
...config,
|
|
3590
|
-
style: {}
|
|
3591
|
-
};
|
|
3592
|
-
if ('boolean' == typeof config.style) rawConfig.style.bool = config.style;
|
|
3593
|
-
else if ('string' == typeof config.style) {
|
|
3594
|
-
let isTpl = config.style.includes('{{');
|
|
3595
|
-
rawConfig.style[isTpl ? 'custom' : 'css'] = config.style;
|
|
3596
|
-
} else {
|
|
3597
|
-
var val;
|
|
3598
|
-
val = config.style, '[object Object]' === Object.prototype.toString.call(val) && (rawConfig.style = config.style);
|
|
3599
|
-
}
|
|
3600
|
-
return config.styleLibraryDirectory && (rawConfig.style = {
|
|
3601
|
-
styleLibraryDirectory: config.styleLibraryDirectory
|
|
3602
|
-
}), rawConfig;
|
|
3603
|
-
});
|
|
3604
|
-
}(rspackExperiments.import || rspackExperiments.pluginImport));
|
|
4219
|
+
rspackExperiments && (rspackExperiments.import || rspackExperiments.pluginImport) && (rspackExperiments.import = resolvePluginImport(rspackExperiments.import || rspackExperiments.pluginImport));
|
|
3605
4220
|
}
|
|
3606
4221
|
return options;
|
|
3607
|
-
})(o,
|
|
3608
|
-
if (identifier.startsWith(`${BUILTIN_LOADER_PREFIX}lightningcss-loader`))
|
|
3609
|
-
|
|
3610
|
-
|
|
4222
|
+
})(o, options);
|
|
4223
|
+
if (identifier.startsWith(`${BUILTIN_LOADER_PREFIX}lightningcss-loader`)) {
|
|
4224
|
+
let options1;
|
|
4225
|
+
return 'object' == typeof (options1 = o ?? {}) && ('string' == typeof options1.targets ? options1.targets = [
|
|
4226
|
+
options1.targets
|
|
4227
|
+
] : 'object' != typeof options1.targets || Array.isArray(options1.targets) ? void 0 === options1.targets && options.compiler.target?.targets && (options1.targets = defaultTargetsFromRspackTargets(options.compiler.target.targets)) : options1.targets = encodeTargets(options1.targets), options1.include && 'object' == typeof options1.include && (options1.include = toFeatures(options1.include)), options1.exclude && 'object' == typeof options1.exclude && (options1.exclude = toFeatures(options1.exclude))), options1;
|
|
4228
|
+
}
|
|
3611
4229
|
return o;
|
|
3612
|
-
}(use.loader, use.options,
|
|
4230
|
+
}(use.loader, use.options, options1);
|
|
3613
4231
|
o = isNil(temp) ? void 0 : 'string' == typeof temp ? temp : JSON.stringify(temp, null, 2), isBuiltin = !0;
|
|
3614
4232
|
}
|
|
3615
4233
|
return {
|
|
@@ -3826,16 +4444,16 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3826
4444
|
dynamicImportPreload: parser.dynamicImportPreload?.toString(),
|
|
3827
4445
|
dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString(),
|
|
3828
4446
|
dynamicImportFetchPriority: parser.dynamicImportFetchPriority,
|
|
3829
|
-
importMeta: parser.importMeta,
|
|
4447
|
+
importMeta: 'boolean' == typeof parser.importMeta ? String(parser.importMeta) : parser.importMeta,
|
|
3830
4448
|
url: parser.url?.toString(),
|
|
3831
4449
|
exprContextCritical: parser.exprContextCritical,
|
|
3832
4450
|
unknownContextCritical: parser.unknownContextCritical,
|
|
3833
4451
|
wrappedContextCritical: parser.wrappedContextCritical,
|
|
4452
|
+
strictThisContextOnImports: parser.strictThisContextOnImports,
|
|
3834
4453
|
wrappedContextRegExp: parser.wrappedContextRegExp,
|
|
3835
4454
|
exportsPresence: !1 === parser.exportsPresence ? 'false' : parser.exportsPresence,
|
|
3836
4455
|
importExportsPresence: !1 === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
|
|
3837
4456
|
reexportExportsPresence: !1 === parser.reexportExportsPresence ? 'false' : parser.reexportExportsPresence,
|
|
3838
|
-
strictExportPresence: parser.strictExportPresence,
|
|
3839
4457
|
worker: 'boolean' == typeof parser.worker ? parser.worker ? [
|
|
3840
4458
|
'...'
|
|
3841
4459
|
] : [] : parser.worker,
|
|
@@ -3849,13 +4467,15 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
3849
4467
|
commonjsMagicComments: parser.commonjsMagicComments,
|
|
3850
4468
|
typeReexportsPresence: parser.typeReexportsPresence,
|
|
3851
4469
|
jsx: parser.jsx,
|
|
3852
|
-
deferImport: parser.deferImport
|
|
4470
|
+
deferImport: parser.deferImport,
|
|
4471
|
+
importMetaResolve: parser.importMetaResolve
|
|
3853
4472
|
};
|
|
3854
4473
|
}
|
|
3855
4474
|
function getRawCssParserOptions(parser) {
|
|
3856
4475
|
return {
|
|
3857
4476
|
namedExports: parser.namedExports,
|
|
3858
|
-
url: parser.url
|
|
4477
|
+
url: parser.url,
|
|
4478
|
+
resolveImport: parser.resolveImport
|
|
3859
4479
|
};
|
|
3860
4480
|
}
|
|
3861
4481
|
function getRawGeneratorOptions(generator, type) {
|
|
@@ -4277,9 +4897,13 @@ let JsLoaderRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName
|
|
|
4277
4897
|
path,
|
|
4278
4898
|
type
|
|
4279
4899
|
};
|
|
4280
|
-
}), LightningCssMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName.LightningCssMinimizerRspackPlugin, (options)
|
|
4281
|
-
let { include, exclude, nonStandard, pseudoClasses, drafts } = options?.minimizerOptions ?? {}, targets =
|
|
4282
|
-
|
|
4900
|
+
}), LightningCssMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName.LightningCssMinimizerRspackPlugin, function(options) {
|
|
4901
|
+
let { include, exclude, nonStandard, pseudoClasses, drafts } = options?.minimizerOptions ?? {}, targets = [
|
|
4902
|
+
'fully supports es6'
|
|
4903
|
+
];
|
|
4904
|
+
return options?.minimizerOptions?.targets ? 'string' == typeof options.minimizerOptions.targets ? targets = [
|
|
4905
|
+
options.minimizerOptions.targets
|
|
4906
|
+
] : Array.isArray(options.minimizerOptions.targets) ? targets = options.minimizerOptions.targets : 'object' == typeof options.minimizerOptions.targets && (targets = encodeTargets(options.minimizerOptions.targets)) : this.target.targets && (targets = defaultTargetsFromRspackTargets(this.target.targets)), {
|
|
4283
4907
|
test: options?.test,
|
|
4284
4908
|
include: options?.include,
|
|
4285
4909
|
exclude: options?.exclude,
|
|
@@ -4289,9 +4913,7 @@ let JsLoaderRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName
|
|
|
4289
4913
|
unusedSymbols: options?.minimizerOptions?.unusedSymbols ?? [],
|
|
4290
4914
|
include: include ? toFeatures(include) : void 0,
|
|
4291
4915
|
exclude: exclude ? toFeatures(exclude) : void 0,
|
|
4292
|
-
targets
|
|
4293
|
-
targets
|
|
4294
|
-
] : targets,
|
|
4916
|
+
targets,
|
|
4295
4917
|
drafts: drafts ? {
|
|
4296
4918
|
customMedia: drafts.customMedia ?? !1
|
|
4297
4919
|
} : void 0,
|
|
@@ -4307,7 +4929,7 @@ let JsLoaderRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName
|
|
|
4307
4929
|
test,
|
|
4308
4930
|
client,
|
|
4309
4931
|
currentActiveModules
|
|
4310
|
-
}), '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)=>{
|
|
4311
4933
|
'function' == typeof next && next();
|
|
4312
4934
|
}, lazyCompilationMiddleware = (compiler)=>{
|
|
4313
4935
|
if (compiler instanceof MultiCompiler) {
|
|
@@ -4348,16 +4970,44 @@ function applyPlugin(compiler, options, activeModules) {
|
|
|
4348
4970
|
}
|
|
4349
4971
|
let lazyCompilationMiddlewareInternal = (compiler, activeModules, lazyCompilationPrefix)=>{
|
|
4350
4972
|
let logger = compiler.getInfrastructureLogger('LazyCompilation');
|
|
4351
|
-
return (req, res, next)=>{
|
|
4352
|
-
if (!req.url?.startsWith(lazyCompilationPrefix)) return next?.();
|
|
4353
|
-
let modules =
|
|
4354
|
-
|
|
4973
|
+
return async (req, res, next)=>{
|
|
4974
|
+
if (!req.url?.startsWith(lazyCompilationPrefix) || 'POST' !== req.method) return next?.();
|
|
4975
|
+
let modules = [];
|
|
4976
|
+
try {
|
|
4977
|
+
modules = await function(req) {
|
|
4978
|
+
if (void 0 !== req.body) {
|
|
4979
|
+
if (Array.isArray(req.body)) return Promise.resolve(req.body);
|
|
4980
|
+
if ('string' == typeof req.body) return Promise.resolve(req.body.split('\n').filter(Boolean));
|
|
4981
|
+
throw Error('Invalid body type');
|
|
4982
|
+
}
|
|
4983
|
+
return new Promise((resolve, reject)=>{
|
|
4984
|
+
if (req.aborted || req.destroyed) return void reject(Error('Request was aborted before body could be read'));
|
|
4985
|
+
let cleanup = ()=>{
|
|
4986
|
+
req.removeListener('data', onData), req.removeListener('end', onEnd), req.removeListener('error', onError), req.removeListener('close', onClose), req.removeListener('aborted', onAborted);
|
|
4987
|
+
}, chunks = [], onData = (chunk)=>{
|
|
4988
|
+
chunks.push(chunk);
|
|
4989
|
+
}, onEnd = ()=>{
|
|
4990
|
+
cleanup(), resolve(Buffer.concat(chunks).toString('utf8').split('\n').filter(Boolean));
|
|
4991
|
+
}, onError = (err)=>{
|
|
4992
|
+
cleanup(), reject(err);
|
|
4993
|
+
}, onClose = ()=>{
|
|
4994
|
+
cleanup(), reject(Error('Request was closed before body could be read'));
|
|
4995
|
+
}, onAborted = ()=>{
|
|
4996
|
+
cleanup(), reject(Error('Request was aborted before body could be read'));
|
|
4997
|
+
};
|
|
4998
|
+
req.on('data', onData), req.on('end', onEnd), req.on('error', onError), req.on('close', onClose), req.on('aborted', onAborted);
|
|
4999
|
+
});
|
|
5000
|
+
}(req);
|
|
5001
|
+
} catch (err) {
|
|
5002
|
+
logger.error(`Failed to parse request body: ${err}`), res.writeHead(400), res.end('Bad Request');
|
|
5003
|
+
return;
|
|
5004
|
+
}
|
|
4355
5005
|
let moduleActivated = [];
|
|
4356
5006
|
for (let key of modules){
|
|
4357
5007
|
let activated = activeModules.has(key);
|
|
4358
5008
|
activeModules.add(key), activated || (logger.log(`${key} is now in use and will be compiled.`), moduleActivated.push(key));
|
|
4359
5009
|
}
|
|
4360
|
-
moduleActivated.length && compiler.watching && compiler.watching.invalidate();
|
|
5010
|
+
moduleActivated.length && compiler.watching && compiler.watching.invalidate(), res.writeHead(200), res.write('\n'), res.end();
|
|
4361
5011
|
};
|
|
4362
5012
|
};
|
|
4363
5013
|
class MangleExportsPlugin extends RspackBuiltinPlugin {
|
|
@@ -4400,8 +5050,8 @@ let NodeTargetPlugin = base_create(binding_namespaceObject.BuiltinPluginName.Nod
|
|
|
4400
5050
|
})), OccurrenceChunkIdsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.OccurrenceChunkIdsPlugin, (options)=>({
|
|
4401
5051
|
...options
|
|
4402
5052
|
}), 'compilation'), ProgressPlugin = base_create(binding_namespaceObject.BuiltinPluginName.ProgressPlugin, (progress = {})=>'function' == typeof progress ? {
|
|
4403
|
-
handler: (percentage, msg,
|
|
4404
|
-
progress(percentage, msg,
|
|
5053
|
+
handler: (percentage, msg, info)=>{
|
|
5054
|
+
progress(percentage, msg, info);
|
|
4405
5055
|
}
|
|
4406
5056
|
} : progress), ProvidePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ProvidePlugin, (provide)=>Object.fromEntries(Object.entries(provide).map(([key, value])=>('string' == typeof value && (value = [
|
|
4407
5057
|
value
|
|
@@ -4462,82 +5112,77 @@ RuntimePlugin.getCompilationHooks = (compilation)=>{
|
|
|
4462
5112
|
])
|
|
4463
5113
|
}, RuntimePlugin_compilationHooksMap.set(compilation, hooks)), hooks;
|
|
4464
5114
|
};
|
|
4465
|
-
let
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
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
|
+
});
|
|
4477
5148
|
}
|
|
4478
5149
|
}
|
|
4479
|
-
class
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
affectedHooks = 'thisCompilation';
|
|
5150
|
+
class RscClientPlugin extends RspackBuiltinPlugin {
|
|
5151
|
+
name = 'RscClientPlugin';
|
|
5152
|
+
#options;
|
|
4483
5153
|
constructor(options){
|
|
4484
|
-
super(), this
|
|
5154
|
+
super(), this.#options = options;
|
|
4485
5155
|
}
|
|
4486
5156
|
raw(compiler) {
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
test: 'function' == typeof test ? (ctx)=>{
|
|
4508
|
-
let info = {
|
|
4509
|
-
moduleGraph: compiler._lastCompilation.moduleGraph,
|
|
4510
|
-
chunkGraph: compiler._lastCompilation.chunkGraph
|
|
4511
|
-
};
|
|
4512
|
-
return test(ctx.module, info);
|
|
4513
|
-
} : test,
|
|
4514
|
-
name: getName(name),
|
|
4515
|
-
chunks: getChunks(chunks),
|
|
4516
|
-
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
4517
|
-
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
4518
|
-
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
4519
|
-
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
4520
|
-
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
4521
|
-
...passThrough
|
|
4522
|
-
};
|
|
4523
|
-
}),
|
|
4524
|
-
fallbackCacheGroup: {
|
|
4525
|
-
chunks: getChunks(chunks),
|
|
4526
|
-
...fallbackCacheGroup
|
|
4527
|
-
},
|
|
4528
|
-
minSize: JsSplitChunkSizes.__to_binding(minSize),
|
|
4529
|
-
minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
|
|
4530
|
-
maxSize: JsSplitChunkSizes.__to_binding(maxSize),
|
|
4531
|
-
maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
4532
|
-
maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
4533
|
-
...passThrough
|
|
4534
|
-
};
|
|
4535
|
-
}(this.options, compiler);
|
|
4536
|
-
if (void 0 === rawOptions) throw Error('rawOptions should not be undefined');
|
|
4537
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
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
|
+
});
|
|
4538
5177
|
}
|
|
4539
5178
|
}
|
|
4540
|
-
let
|
|
5179
|
+
let SideEffectsFlagPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SideEffectsFlagPlugin, ()=>{}, 'compilation'), SizeLimitsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SizeLimitsPlugin, (options)=>{
|
|
5180
|
+
let hints = !1 === options.hints ? void 0 : options.hints;
|
|
5181
|
+
return {
|
|
5182
|
+
...options,
|
|
5183
|
+
hints
|
|
5184
|
+
};
|
|
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) {
|
|
4541
5186
|
let htmlPlugin = 'Disabled';
|
|
4542
5187
|
return options.htmlPlugin === NATIVE_HTML_PLUGIN ? htmlPlugin = 'Native' : 'string' == typeof options.htmlPlugin && (htmlPlugin = 'JavaScript'), {
|
|
4543
5188
|
hashFuncNames: options.hashFuncNames,
|
|
@@ -4607,13 +5252,11 @@ class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
|
|
|
4607
5252
|
}
|
|
4608
5253
|
let src = '';
|
|
4609
5254
|
if (isUrlSrc) {
|
|
4610
|
-
if (!publicPath) return;
|
|
5255
|
+
if (!publicPath || '/' === publicPath || './' === publicPath) return;
|
|
4611
5256
|
let protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, ''), protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, '');
|
|
4612
5257
|
if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
|
|
4613
|
-
{
|
|
4614
|
-
|
|
4615
|
-
src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
|
|
4616
|
-
}
|
|
5258
|
+
let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
|
|
5259
|
+
src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
|
|
4617
5260
|
} else src = relative(publicPath, decodeURIComponent(tagSrc));
|
|
4618
5261
|
tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || function(hashFuncNames, source) {
|
|
4619
5262
|
let { createHash } = SubresourceIntegrityPlugin_require('node:crypto');
|
|
@@ -4661,8 +5304,8 @@ class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
|
|
|
4661
5304
|
function normalizePath(path) {
|
|
4662
5305
|
return path.replace(/\?.*$/, '').split(sep).join('/');
|
|
4663
5306
|
}
|
|
4664
|
-
let SwcJsMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SwcJsMinimizerRspackPlugin, (options)
|
|
4665
|
-
let compress = options?.minimizerOptions?.compress ?? !0, mangle = options?.minimizerOptions?.mangle ?? !0, ecma = options?.minimizerOptions?.ecma ?? 5, format = {
|
|
5307
|
+
let SwcJsMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SwcJsMinimizerRspackPlugin, function(options) {
|
|
5308
|
+
let compress = options?.minimizerOptions?.compress ?? !0, mangle = options?.minimizerOptions?.mangle ?? !0, ecma = options?.minimizerOptions?.ecma ?? (this.target?.esVersion && this.target.esVersion > 2022 ? 2022 : this.target.esVersion) ?? 5, format = {
|
|
4666
5309
|
comments: !1,
|
|
4667
5310
|
...options?.minimizerOptions?.format
|
|
4668
5311
|
};
|
|
@@ -4677,23 +5320,37 @@ let SwcJsMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPlug
|
|
|
4677
5320
|
exclude: options?.exclude,
|
|
4678
5321
|
extractComments: function(extractComments) {
|
|
4679
5322
|
let type, conditionStr = (condition)=>{
|
|
4680
|
-
if (void 0 === condition || !0 === condition) return
|
|
5323
|
+
if (void 0 === condition || !0 === condition) return {
|
|
5324
|
+
source: '@preserve|@lic|@cc_on|^\\**!',
|
|
5325
|
+
flags: ''
|
|
5326
|
+
};
|
|
4681
5327
|
if (!1 === condition) throw Error('unreachable');
|
|
4682
|
-
return
|
|
5328
|
+
return {
|
|
5329
|
+
source: condition.source,
|
|
5330
|
+
flags: condition.flags
|
|
5331
|
+
};
|
|
4683
5332
|
};
|
|
4684
5333
|
if ('boolean' == typeof extractComments) {
|
|
4685
5334
|
if (!extractComments) return;
|
|
5335
|
+
let { source, flags } = conditionStr(extractComments);
|
|
4686
5336
|
return {
|
|
4687
|
-
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
|
|
4688
5346
|
};
|
|
4689
5347
|
}
|
|
4690
|
-
if (extractComments instanceof RegExp) return {
|
|
4691
|
-
condition: extractComments.source
|
|
4692
|
-
};
|
|
4693
5348
|
if (type = typeof extractComments, null != extractComments && ('object' === type || 'function' === type)) {
|
|
4694
5349
|
if (!1 === extractComments.condition) return;
|
|
5350
|
+
let { source, flags } = conditionStr(extractComments.condition);
|
|
4695
5351
|
return {
|
|
4696
|
-
condition:
|
|
5352
|
+
condition: source,
|
|
5353
|
+
conditionFlags: flags,
|
|
4697
5354
|
banner: extractComments.banner
|
|
4698
5355
|
};
|
|
4699
5356
|
}
|
|
@@ -4720,6 +5377,7 @@ class WorkerPlugin extends RspackBuiltinPlugin {
|
|
|
4720
5377
|
module;
|
|
4721
5378
|
workerPublicPath;
|
|
4722
5379
|
name = binding_namespaceObject.BuiltinPluginName.WorkerPlugin;
|
|
5380
|
+
affectedHooks = 'compilation';
|
|
4723
5381
|
constructor(chunkLoading, wasmLoading, module, workerPublicPath){
|
|
4724
5382
|
super(), this.chunkLoading = chunkLoading, this.wasmLoading = wasmLoading, this.module = module, this.workerPublicPath = workerPublicPath;
|
|
4725
5383
|
}
|
|
@@ -4740,7 +5398,7 @@ class ContextModuleFactory {
|
|
|
4740
5398
|
};
|
|
4741
5399
|
}
|
|
4742
5400
|
}
|
|
4743
|
-
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;
|
|
4744
5402
|
class Template {
|
|
4745
5403
|
static getFunctionContent(fn) {
|
|
4746
5404
|
return fn.toString().replace(FUNCTION_CONTENT_REGEX, '').replace(INDENT_MULTILINE_REGEX, '').replace(LINE_SEPARATOR_REGEX, '\n');
|
|
@@ -4968,7 +5626,140 @@ let DYNAMIC_INFO = Symbol('cleverMerge dynamic info'), mergeCache = new WeakMap(
|
|
|
4968
5626
|
default:
|
|
4969
5627
|
throw Error('Not implemented');
|
|
4970
5628
|
}
|
|
4971
|
-
}
|
|
5629
|
+
};
|
|
5630
|
+
class BrowserslistError extends Error {
|
|
5631
|
+
constructor(message){
|
|
5632
|
+
var key, value;
|
|
5633
|
+
super(message), value = void 0, (key = "browserslist") in this ? Object.defineProperty(this, key, {
|
|
5634
|
+
value: value,
|
|
5635
|
+
enumerable: !0,
|
|
5636
|
+
configurable: !0,
|
|
5637
|
+
writable: !0
|
|
5638
|
+
}) : this[key] = value, this.name = 'BrowserslistError', this.browserslist = !0, Error.captureStackTrace && Error.captureStackTrace(this, BrowserslistError);
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
let isFileCache = {};
|
|
5642
|
+
function isFile(file) {
|
|
5643
|
+
if (file in isFileCache) return isFileCache[file];
|
|
5644
|
+
let result = node_fs.existsSync(file) && node_fs.statSync(file).isFile();
|
|
5645
|
+
return isFileCache[file] = result, result;
|
|
5646
|
+
}
|
|
5647
|
+
function parsePackage(file) {
|
|
5648
|
+
let config = JSON.parse(node_fs.readFileSync(file).toString().replace(/^\uFEFF/m, ''));
|
|
5649
|
+
if (config.browserlist && !config.browserslist) throw new BrowserslistError(`\`browserlist\` key instead of \`browserslist\` in ${file}`);
|
|
5650
|
+
let list = config.browserslist;
|
|
5651
|
+
for(let i in Array.isArray(list) && (list = {
|
|
5652
|
+
defaults: list
|
|
5653
|
+
}), 'string' == typeof list && (list = parseConfig(list)), list)!function(section) {
|
|
5654
|
+
let FORMAT = 'Browserslist config should be a string or an array of strings with browser queries';
|
|
5655
|
+
if (Array.isArray(section)) {
|
|
5656
|
+
for(let i = 0; i < section.length; i++)if ('string' != typeof section[i]) throw new BrowserslistError(FORMAT);
|
|
5657
|
+
} else if ('string' != typeof section) throw new BrowserslistError(FORMAT);
|
|
5658
|
+
}(list[i]);
|
|
5659
|
+
return list;
|
|
5660
|
+
}
|
|
5661
|
+
let IS_SECTION = /^\s*\[(.+)]\s*$/;
|
|
5662
|
+
function parseConfig(string) {
|
|
5663
|
+
let result = {
|
|
5664
|
+
defaults: []
|
|
5665
|
+
}, sections = [
|
|
5666
|
+
'defaults'
|
|
5667
|
+
];
|
|
5668
|
+
return string.toString().replace(/#[^\n]*/g, '').split(/\n|,/).map((line)=>line.trim()).filter((line)=>'' !== line).forEach((line)=>{
|
|
5669
|
+
let matched = line.match(IS_SECTION);
|
|
5670
|
+
matched ? (sections = matched[1].trim().split(' ')).forEach((section)=>{
|
|
5671
|
+
if (result[section]) throw new BrowserslistError(`Duplicate section ${section} in Browserslist config`);
|
|
5672
|
+
result[section] = [];
|
|
5673
|
+
}) : sections.forEach((section)=>{
|
|
5674
|
+
result[section].push(line);
|
|
5675
|
+
});
|
|
5676
|
+
}), result;
|
|
5677
|
+
}
|
|
5678
|
+
function eachParent(file, callback) {
|
|
5679
|
+
let dir = isFile(file) ? node_path.dirname(file) : file, loc = node_path.resolve(dir);
|
|
5680
|
+
do {
|
|
5681
|
+
let result = callback(loc);
|
|
5682
|
+
if (void 0 !== result) return result;
|
|
5683
|
+
}while (loc !== (loc = node_path.dirname(loc)));
|
|
5684
|
+
}
|
|
5685
|
+
let configCache = {}, ES_VERSIONS_MAP = {
|
|
5686
|
+
chrome: [
|
|
5687
|
+
51,
|
|
5688
|
+
52,
|
|
5689
|
+
57,
|
|
5690
|
+
64,
|
|
5691
|
+
73,
|
|
5692
|
+
80,
|
|
5693
|
+
85,
|
|
5694
|
+
94,
|
|
5695
|
+
110,
|
|
5696
|
+
119
|
|
5697
|
+
],
|
|
5698
|
+
edge: [
|
|
5699
|
+
15,
|
|
5700
|
+
15,
|
|
5701
|
+
15,
|
|
5702
|
+
79,
|
|
5703
|
+
79,
|
|
5704
|
+
80,
|
|
5705
|
+
85,
|
|
5706
|
+
94,
|
|
5707
|
+
110,
|
|
5708
|
+
119
|
|
5709
|
+
],
|
|
5710
|
+
safari: [
|
|
5711
|
+
10,
|
|
5712
|
+
10.3,
|
|
5713
|
+
11,
|
|
5714
|
+
16.4,
|
|
5715
|
+
17,
|
|
5716
|
+
17,
|
|
5717
|
+
17,
|
|
5718
|
+
17,
|
|
5719
|
+
17,
|
|
5720
|
+
17.4
|
|
5721
|
+
],
|
|
5722
|
+
firefox: [
|
|
5723
|
+
54,
|
|
5724
|
+
54,
|
|
5725
|
+
54,
|
|
5726
|
+
78,
|
|
5727
|
+
78,
|
|
5728
|
+
80,
|
|
5729
|
+
80,
|
|
5730
|
+
93,
|
|
5731
|
+
115,
|
|
5732
|
+
145
|
|
5733
|
+
],
|
|
5734
|
+
opera: [
|
|
5735
|
+
38,
|
|
5736
|
+
39,
|
|
5737
|
+
44,
|
|
5738
|
+
51,
|
|
5739
|
+
60,
|
|
5740
|
+
67,
|
|
5741
|
+
71,
|
|
5742
|
+
80,
|
|
5743
|
+
96,
|
|
5744
|
+
105
|
|
5745
|
+
],
|
|
5746
|
+
samsung: [
|
|
5747
|
+
5,
|
|
5748
|
+
6.2,
|
|
5749
|
+
6.2,
|
|
5750
|
+
8.2,
|
|
5751
|
+
11.1,
|
|
5752
|
+
13,
|
|
5753
|
+
14,
|
|
5754
|
+
17,
|
|
5755
|
+
21,
|
|
5756
|
+
25
|
|
5757
|
+
]
|
|
5758
|
+
}, aliases = {
|
|
5759
|
+
ios_saf: 'safari',
|
|
5760
|
+
and_chr: 'chrome',
|
|
5761
|
+
and_ff: 'firefox'
|
|
5762
|
+
}, renameBrowser = (name)=>aliases[name] || name, browserslistTargetHandler_resolve = (browsers)=>{
|
|
4972
5763
|
let rawChecker = (versions)=>browsers.every((v)=>{
|
|
4973
5764
|
let [name, parsedVersion] = v.split(' ');
|
|
4974
5765
|
if (!name) return !1;
|
|
@@ -5400,10 +6191,32 @@ let DYNAMIC_INFO = Symbol('cleverMerge dynamic info'), mergeCache = new WeakMap(
|
|
|
5400
6191
|
}),
|
|
5401
6192
|
require: nodeProperty
|
|
5402
6193
|
};
|
|
5403
|
-
},
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
6194
|
+
}, getBrowserslistTargetHandler = memoize(()=>browserslistTargetHandler_namespaceObject), hasBrowserslistConfig = (context)=>!!function(from) {
|
|
6195
|
+
let resolved, fromDir = isFile(from = node_path.resolve(from)) ? node_path.dirname(from) : from;
|
|
6196
|
+
if (fromDir in configCache) return configCache[fromDir];
|
|
6197
|
+
let configFile = eachParent(from, (dir)=>{
|
|
6198
|
+
let pkgBrowserslist, config = node_path.join(dir, 'browserslist'), pkg = node_path.join(dir, 'package.json'), rc = node_path.join(dir, '.browserslistrc');
|
|
6199
|
+
if (isFile(pkg)) try {
|
|
6200
|
+
pkgBrowserslist = parsePackage(pkg);
|
|
6201
|
+
} catch (e) {
|
|
6202
|
+
if (e instanceof BrowserslistError) throw e;
|
|
6203
|
+
console.warn(`[Browserslist] Could not parse ${pkg}. Ignoring it.`);
|
|
6204
|
+
}
|
|
6205
|
+
if (isFile(config) && pkgBrowserslist) throw new BrowserslistError(`${dir} contains both browserslist and package.json with browsers`);
|
|
6206
|
+
if (isFile(rc) && pkgBrowserslist) throw new BrowserslistError(`${dir} contains both .browserslistrc and package.json with browsers`);
|
|
6207
|
+
if (isFile(config) && isFile(rc)) throw new BrowserslistError(`${dir} contains both .browserslistrc and browserslist`);
|
|
6208
|
+
return isFile(config) ? config : isFile(rc) ? rc : pkgBrowserslist ? pkg : void 0;
|
|
6209
|
+
});
|
|
6210
|
+
configFile && (resolved = function(file) {
|
|
6211
|
+
if ('package.json' === node_path.basename(file)) return parsePackage(file);
|
|
6212
|
+
if (!isFile(file)) throw new BrowserslistError(`Can't read ${file} config`);
|
|
6213
|
+
return parseConfig(node_fs.readFileSync(file, 'utf-8'));
|
|
6214
|
+
}(configFile));
|
|
6215
|
+
let configDir = configFile && node_path.dirname(configFile);
|
|
6216
|
+
return eachParent(from, (dir)=>{
|
|
6217
|
+
if (resolved && (configCache[dir] = resolved), dir === configDir) return null;
|
|
6218
|
+
}), resolved;
|
|
6219
|
+
}(context), versionDependent = (major, minor)=>{
|
|
5407
6220
|
if (!major) return ()=>void 0;
|
|
5408
6221
|
let nMajor = +major, nMinor = minor ? +minor : 0;
|
|
5409
6222
|
return (vMajor, vMinor = 0)=>nMajor > vMajor || nMajor === vMajor && nMinor >= vMinor;
|
|
@@ -5419,7 +6232,35 @@ See https://github.com/browserslist/browserslist#queries for possible ways to pr
|
|
|
5419
6232
|
The recommended way is to add a 'browserslist' key to your package.json and list supported browsers (resp. node.js versions).
|
|
5420
6233
|
You can also more options via the 'target' option: 'browserslist' / 'browserslist:env' / 'browserslist:query' / 'browserslist:path-to-config' / 'browserslist:path-to-config:env'`);
|
|
5421
6234
|
if (Array.isArray(browsers) && 0 === browsers.length) throw Error('Rspack cannot parse the browserslist query. This may happen when the query contains version requirements that exceed the supported range in the browserslist-rs database. Check your browserslist configuration for invalid version numbers.');
|
|
5422
|
-
|
|
6235
|
+
let browserslistTargetHandler = getBrowserslistTargetHandler(), encodedTargets = {};
|
|
6236
|
+
for (let p of browsers){
|
|
6237
|
+
let [name, v] = p.split(' '), version = encodeVersion(v);
|
|
6238
|
+
null !== version && (!encodedTargets[name] || version < encodedTargets[name]) && (encodedTargets[name] = version);
|
|
6239
|
+
}
|
|
6240
|
+
let targets = Object.fromEntries(Object.entries(encodedTargets).map(([k, v])=>[
|
|
6241
|
+
k,
|
|
6242
|
+
decodeVersion(v)
|
|
6243
|
+
]));
|
|
6244
|
+
return {
|
|
6245
|
+
...browserslistTargetHandler.resolve(browsers),
|
|
6246
|
+
targets,
|
|
6247
|
+
esVersion: function(browsers) {
|
|
6248
|
+
let esVersion = 2024;
|
|
6249
|
+
for (let item of browsers){
|
|
6250
|
+
let pairs = item.split(' ');
|
|
6251
|
+
if (pairs.length < 2) continue;
|
|
6252
|
+
let browser = renameBrowser(pairs[0]), version = Number(pairs[1].split('-')[0]);
|
|
6253
|
+
if (Number.isNaN(version)) continue;
|
|
6254
|
+
if ('ie' === browser || 'android' === browser && version < 6) {
|
|
6255
|
+
esVersion = 5;
|
|
6256
|
+
break;
|
|
6257
|
+
}
|
|
6258
|
+
let versions = ES_VERSIONS_MAP[browser];
|
|
6259
|
+
versions && (version < versions[0] ? esVersion = Math.min(5, esVersion) : version < versions[1] ? esVersion = Math.min(2015, esVersion) : version < versions[2] ? esVersion = Math.min(2016, esVersion) : version < versions[3] ? esVersion = Math.min(2017, esVersion) : version < versions[4] ? esVersion = Math.min(2018, esVersion) : version < versions[5] ? esVersion = Math.min(2019, esVersion) : version < versions[6] ? esVersion = Math.min(2020, esVersion) : version < versions[7] ? esVersion = Math.min(2021, esVersion) : version < versions[8] ? esVersion = Math.min(2022, esVersion) : version < versions[9] && (esVersion = Math.min(2023, esVersion)));
|
|
6260
|
+
}
|
|
6261
|
+
return esVersion;
|
|
6262
|
+
}(browsers)
|
|
6263
|
+
};
|
|
5423
6264
|
}
|
|
5424
6265
|
],
|
|
5425
6266
|
[
|
|
@@ -5475,6 +6316,10 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5475
6316
|
web: !1,
|
|
5476
6317
|
webworker: !1,
|
|
5477
6318
|
browser: !1,
|
|
6319
|
+
targets: major ? {
|
|
6320
|
+
node: `${major}${minor ? `.${minor}` : ''}`
|
|
6321
|
+
} : {},
|
|
6322
|
+
esVersion: v(18) ? 2022 : v(16) ? 2021 : v(14) ? 2020 : v(12) ? 2019 : v(10) ? 2018 : v(8) ? 2017 : v(7) ? 2016 : v(6, 5) ? 2015 : 5,
|
|
5478
6323
|
require: !asyncFlag,
|
|
5479
6324
|
nodeBuiltins: !0,
|
|
5480
6325
|
nodePrefixForCoreModules: 15 > +major ? v(14, 18) : v(16),
|
|
@@ -5516,6 +6361,10 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5516
6361
|
electronMain: 'main' === context,
|
|
5517
6362
|
electronPreload: 'preload' === context,
|
|
5518
6363
|
electronRenderer: 'renderer' === context,
|
|
6364
|
+
targets: major ? {
|
|
6365
|
+
electron: `${major}${minor ? `.${minor}` : ''}`
|
|
6366
|
+
} : {},
|
|
6367
|
+
esVersion: v(23) ? 2022 : v(15) ? 2021 : v(12) ? 2020 : v(5) ? 2019 : v(3) ? 2018 : v(1, 8) ? 2017 : v(1, 5) ? 2016 : v(1, 4) ? 2015 : 5,
|
|
5519
6368
|
global: !0,
|
|
5520
6369
|
nodeBuiltins: !0,
|
|
5521
6370
|
nodePrefixForCoreModules: v(15),
|
|
@@ -5554,6 +6403,10 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5554
6403
|
webworker: null,
|
|
5555
6404
|
browser: !1,
|
|
5556
6405
|
electron: !1,
|
|
6406
|
+
targets: major ? {
|
|
6407
|
+
nwjs: `${major}${minor ? `.${minor}` : ''}`
|
|
6408
|
+
} : {},
|
|
6409
|
+
esVersion: v(0, 65) ? 2022 : v(0, 54) ? 2021 : v(0, 46) ? 2020 : v(0, 39) ? 2019 : v(0, 31) ? 2018 : v(0, 23) ? 2017 : v(0, 20) ? 2016 : v(0, 17) ? 2015 : 5,
|
|
5557
6410
|
global: !0,
|
|
5558
6411
|
nodeBuiltins: !0,
|
|
5559
6412
|
document: !1,
|
|
@@ -5583,7 +6436,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5583
6436
|
/^es(\d+)$/,
|
|
5584
6437
|
(version)=>{
|
|
5585
6438
|
let v = +version;
|
|
5586
|
-
return v < 1000 && (v += 2009), {
|
|
6439
|
+
return 5 < v && v < 1000 && (v += 2009), {
|
|
6440
|
+
esVersion: v > 2022 ? 2022 : v,
|
|
5587
6441
|
const: v >= 2015,
|
|
5588
6442
|
templateLiteral: v >= 2015,
|
|
5589
6443
|
optionalChaining: v >= 2020,
|
|
@@ -5619,6 +6473,24 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5619
6473
|
for (let tp of targetProperties)for (let key of Object.keys(tp))keys.add(key);
|
|
5620
6474
|
let result = {};
|
|
5621
6475
|
for (let key of keys){
|
|
6476
|
+
if ('esVersion' === key) {
|
|
6477
|
+
let minVersion;
|
|
6478
|
+
for (let tp of targetProperties)'number' == typeof tp.esVersion && (minVersion = void 0 === minVersion ? tp.esVersion : Math.min(minVersion, tp.esVersion));
|
|
6479
|
+
void 0 !== minVersion && (result[key] = minVersion);
|
|
6480
|
+
continue;
|
|
6481
|
+
}
|
|
6482
|
+
if ('targets' === key) {
|
|
6483
|
+
let merged = {};
|
|
6484
|
+
for (let tp of targetProperties)if (tp.targets) for (let [name, version] of Object.entries(tp.targets)){
|
|
6485
|
+
let v = encodeVersion(version);
|
|
6486
|
+
null !== v && (!merged[name] || v < merged[name]) && (merged[name] = v);
|
|
6487
|
+
}
|
|
6488
|
+
Object.keys(merged).length > 0 && (result[key] = Object.fromEntries(Object.entries(merged).map(([k, v])=>[
|
|
6489
|
+
k,
|
|
6490
|
+
decodeVersion(v)
|
|
6491
|
+
])));
|
|
6492
|
+
continue;
|
|
6493
|
+
}
|
|
5622
6494
|
let hasTrue = !1, hasFalse = !1;
|
|
5623
6495
|
for (let tp of targetProperties)switch(tp[key]){
|
|
5624
6496
|
case !0:
|
|
@@ -5634,29 +6506,27 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5634
6506
|
if ('function' != typeof options.entry) for (let key of Object.keys(options.entry))F(options.entry[key], 'import', ()=>[
|
|
5635
6507
|
'./src'
|
|
5636
6508
|
]);
|
|
5637
|
-
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, {
|
|
5638
6510
|
production,
|
|
5639
|
-
development
|
|
5640
|
-
css: options.experiments.css
|
|
6511
|
+
development
|
|
5641
6512
|
}), applySnapshotDefaults(options.snapshot, {
|
|
5642
6513
|
production
|
|
5643
6514
|
}), applyModuleDefaults(options.module, {
|
|
5644
|
-
cache: !!options.cache,
|
|
5645
6515
|
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
|
5646
|
-
css: options.experiments.css,
|
|
5647
6516
|
targetProperties,
|
|
5648
6517
|
mode: options.mode,
|
|
5649
6518
|
uniqueName: options.output.uniqueName,
|
|
5650
|
-
deferImport: options.experiments.deferImport
|
|
5651
|
-
|
|
6519
|
+
deferImport: options.experiments.deferImport,
|
|
6520
|
+
outputModule: options.output.module
|
|
6521
|
+
}), applyOutputDefaults(options, {
|
|
5652
6522
|
context: options.context,
|
|
5653
6523
|
targetProperties,
|
|
5654
6524
|
isAffectedByBrowserslist: void 0 === target || 'string' == typeof target && target.startsWith('browserslist') || Array.isArray(target) && target.some((target)=>target.startsWith('browserslist')),
|
|
5655
|
-
outputModule: options.experiments.outputModule,
|
|
5656
6525
|
entry: options.entry
|
|
5657
6526
|
}), applyExternalsPresetsDefaults(options.externalsPresets, {
|
|
5658
6527
|
targetProperties,
|
|
5659
|
-
buildHttp: !!options.experiments.buildHttp
|
|
6528
|
+
buildHttp: !!options.experiments.buildHttp,
|
|
6529
|
+
outputModule: options.output.module
|
|
5660
6530
|
}), F(options, 'externalsType', ()=>options.output.library ? options.output.library.type : options.output.module ? 'module-import' : 'var'), applyNodeDefaults(options.node, {
|
|
5661
6531
|
targetProperties,
|
|
5662
6532
|
outputModule: options.output.module
|
|
@@ -5666,43 +6536,43 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5666
6536
|
}), F(options, 'performance', ()=>!!production && !!targetProperties && (!!targetProperties.browser || null === targetProperties.browser) && {}), applyPerformanceDefaults(options.performance, {
|
|
5667
6537
|
production
|
|
5668
6538
|
}), options.resolve = cleverMerge(getResolveDefaults({
|
|
5669
|
-
context: options.context,
|
|
5670
6539
|
targetProperties,
|
|
5671
|
-
mode: options.mode
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
platform: !1 === targetProperties ? targetProperties : {
|
|
6540
|
+
mode: options.mode
|
|
6541
|
+
}), options.resolve), options.resolveLoader = cleverMerge(getResolveLoaderDefaults(), options.resolveLoader), !1 === targetProperties ? targetProperties : {
|
|
6542
|
+
platform: {
|
|
5675
6543
|
web: targetProperties.web,
|
|
5676
6544
|
browser: targetProperties.browser,
|
|
5677
6545
|
webworker: targetProperties.webworker,
|
|
5678
6546
|
node: targetProperties.node,
|
|
5679
6547
|
nwjs: targetProperties.nwjs,
|
|
5680
6548
|
electron: targetProperties.electron
|
|
5681
|
-
}
|
|
6549
|
+
},
|
|
6550
|
+
esVersion: targetProperties.esVersion,
|
|
6551
|
+
targets: targetProperties.targets
|
|
5682
6552
|
};
|
|
5683
6553
|
}, applyExperimentsDefaults = (experiments)=>{
|
|
5684
|
-
D(experiments, 'futureDefaults', !1), D(experiments, 'asyncWebAssembly',
|
|
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));
|
|
5685
6557
|
}, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
|
|
5686
6558
|
D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
|
|
5687
|
-
}, applyModuleDefaults = (module, {
|
|
5688
|
-
|
|
5689
|
-
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', [
|
|
5690
6562
|
'...'
|
|
5691
|
-
]), 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);
|
|
5692
6564
|
})(module.parser.javascript, {
|
|
5693
|
-
deferImport
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
}
|
|
5705
|
-
A(module, 'defaultRules', ()=>{
|
|
6565
|
+
deferImport,
|
|
6566
|
+
outputModule
|
|
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, {
|
|
6568
|
+
targetProperties
|
|
6569
|
+
}), F(module.generator, 'css/auto', ()=>({})), assertNotNill(module.generator['css/auto']), applyCssGeneratorOptionsDefaults(module.generator['css/auto'], {
|
|
6570
|
+
targetProperties
|
|
6571
|
+
}), D(module.generator['css/auto'], 'exportsConvention', 'as-is');
|
|
6572
|
+
let localIdentName = 'development' === mode ? uniqueName && uniqueName.length > 0 ? '[uniqueName]-[id]-[local]' : '[id]-[local]' : '[fullhash]';
|
|
6573
|
+
D(module.generator['css/auto'], 'localIdentName', localIdentName), F(module.generator, 'css/module', ()=>({})), assertNotNill(module.generator['css/module']), applyCssGeneratorOptionsDefaults(module.generator['css/module'], {
|
|
6574
|
+
targetProperties
|
|
6575
|
+
}), D(module.generator['css/module'], 'exportsConvention', 'as-is'), D(module.generator['css/module'], 'localIdentName', localIdentName), A(module, 'defaultRules', ()=>{
|
|
5706
6576
|
let esm = {
|
|
5707
6577
|
type: "javascript/esm",
|
|
5708
6578
|
resolve: {
|
|
@@ -5720,7 +6590,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5720
6590
|
type: "javascript/auto"
|
|
5721
6591
|
},
|
|
5722
6592
|
{
|
|
5723
|
-
test: /\.json
|
|
6593
|
+
test: /\.json$/,
|
|
5724
6594
|
type: 'json'
|
|
5725
6595
|
},
|
|
5726
6596
|
{
|
|
@@ -5728,22 +6598,22 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5728
6598
|
type: 'json'
|
|
5729
6599
|
},
|
|
5730
6600
|
{
|
|
5731
|
-
test: /\.mjs
|
|
6601
|
+
test: /\.mjs$/,
|
|
5732
6602
|
...esm
|
|
5733
6603
|
},
|
|
5734
6604
|
{
|
|
5735
|
-
test: /\.js
|
|
6605
|
+
test: /\.js$/,
|
|
5736
6606
|
descriptionData: {
|
|
5737
6607
|
type: 'module'
|
|
5738
6608
|
},
|
|
5739
6609
|
...esm
|
|
5740
6610
|
},
|
|
5741
6611
|
{
|
|
5742
|
-
test: /\.cjs
|
|
6612
|
+
test: /\.cjs$/,
|
|
5743
6613
|
...commonjs
|
|
5744
6614
|
},
|
|
5745
6615
|
{
|
|
5746
|
-
test: /\.js
|
|
6616
|
+
test: /\.js$/,
|
|
5747
6617
|
descriptionData: {
|
|
5748
6618
|
type: 'commonjs'
|
|
5749
6619
|
},
|
|
@@ -5774,32 +6644,13 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5774
6644
|
]
|
|
5775
6645
|
};
|
|
5776
6646
|
rules.push({
|
|
5777
|
-
test: /\.wasm
|
|
6647
|
+
test: /\.wasm$/,
|
|
5778
6648
|
...wasm
|
|
5779
6649
|
}), rules.push({
|
|
5780
6650
|
mimetype: 'application/wasm',
|
|
5781
6651
|
...wasm
|
|
5782
6652
|
});
|
|
5783
6653
|
}
|
|
5784
|
-
if (css) {
|
|
5785
|
-
let resolve = {
|
|
5786
|
-
fullySpecified: !0,
|
|
5787
|
-
preferRelative: !0
|
|
5788
|
-
};
|
|
5789
|
-
rules.push({
|
|
5790
|
-
test: /\.css$/i,
|
|
5791
|
-
type: 'css/auto',
|
|
5792
|
-
resolve
|
|
5793
|
-
}), rules.push({
|
|
5794
|
-
mimetype: 'text/css+module',
|
|
5795
|
-
type: 'css/module',
|
|
5796
|
-
resolve
|
|
5797
|
-
}), rules.push({
|
|
5798
|
-
mimetype: 'text/css',
|
|
5799
|
-
type: 'css',
|
|
5800
|
-
resolve
|
|
5801
|
-
});
|
|
5802
|
-
}
|
|
5803
6654
|
return rules.push({
|
|
5804
6655
|
dependency: 'url',
|
|
5805
6656
|
oneOf: [
|
|
@@ -5828,8 +6679,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5828
6679
|
type: 'asset/bytes'
|
|
5829
6680
|
}), rules;
|
|
5830
6681
|
});
|
|
5831
|
-
}, applyOutputDefaults = (
|
|
5832
|
-
let getLibraryName = (library)=>{
|
|
6682
|
+
}, applyOutputDefaults = (options, { context, targetProperties: tp, isAffectedByBrowserslist, entry })=>{
|
|
6683
|
+
let { output } = options, getLibraryName = (library)=>{
|
|
5833
6684
|
let libraryName = 'object' == typeof library && library && !Array.isArray(library) ? library.name : library;
|
|
5834
6685
|
return Array.isArray(libraryName) ? libraryName.join('.') : 'object' == typeof libraryName ? getLibraryName(libraryName.root) : 'string' == typeof libraryName ? libraryName : '';
|
|
5835
6686
|
};
|
|
@@ -5846,9 +6697,25 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5846
6697
|
if ('ENOENT' !== err.code) throw err.message += `\nwhile determining default 'output.uniqueName' from 'name' in ${pkgPath}`, err;
|
|
5847
6698
|
return '';
|
|
5848
6699
|
}
|
|
5849
|
-
}), 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)));
|
|
5850
6717
|
let environment = output.environment, conditionallyOptimistic = (v, c)=>void 0 === v && c || v;
|
|
5851
|
-
F(environment, 'globalThis', ()=>tp
|
|
6718
|
+
F(environment, 'globalThis', ()=>tp && tp.globalThis), F(environment, 'bigIntLiteral', ()=>{
|
|
5852
6719
|
let v;
|
|
5853
6720
|
return tp && ((v = tp.bigIntLiteral) || void 0 === v);
|
|
5854
6721
|
}), F(environment, 'const', ()=>{
|
|
@@ -5875,10 +6742,10 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5875
6742
|
}), F(environment, 'nodePrefixForCoreModules', ()=>{
|
|
5876
6743
|
let v;
|
|
5877
6744
|
return tp && ((v = tp.nodePrefixForCoreModules) || void 0 === v);
|
|
5878
|
-
}), F(environment, 'importMetaDirnameAndFilename', ()=>tp
|
|
6745
|
+
}), F(environment, 'importMetaDirnameAndFilename', ()=>tp && tp.importMetaDirnameAndFilename), F(environment, 'templateLiteral', ()=>{
|
|
5879
6746
|
let v;
|
|
5880
6747
|
return tp && ((v = tp.templateLiteral) || void 0 === v);
|
|
5881
|
-
}), F(environment, 'dynamicImport', ()=>conditionallyOptimistic(tp
|
|
6748
|
+
}), F(environment, 'dynamicImport', ()=>tp && conditionallyOptimistic(tp.dynamicImport, output.module)), F(environment, 'dynamicImportInWorker', ()=>tp && conditionallyOptimistic(tp.dynamicImportInWorker, output.module)), F(environment, 'module', ()=>tp && conditionallyOptimistic(tp.module, output.module)), F(environment, 'document', ()=>{
|
|
5882
6749
|
let v;
|
|
5883
6750
|
return tp && ((v = tp.document) || void 0 === v);
|
|
5884
6751
|
}), D(output, 'filename', output.module ? '[name].mjs' : '[name].js'), F(output, 'iife', ()=>!output.module), F(output, 'chunkFilename', ()=>{
|
|
@@ -5896,7 +6763,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5896
6763
|
return 'function' != typeof chunkFilename ? chunkFilename.replace(/\.[mc]?js(\?|$)/, '.css$1') : '[id].css';
|
|
5897
6764
|
}), D(output, 'hotUpdateChunkFilename', `[id].[fullhash].hot-update.${output.module ? 'mjs' : 'js'}`), F(output, 'hotUpdateMainFilename', ()=>`[runtime].[fullhash].hot-update.${output.module ? 'json.mjs' : 'json'}`);
|
|
5898
6765
|
let uniqueNameId = Template.toIdentifier(output.uniqueName);
|
|
5899
|
-
F(output, 'hotUpdateGlobal', ()=>`
|
|
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', ()=>{
|
|
5900
6767
|
if (tp) {
|
|
5901
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.";
|
|
5902
6769
|
if (output.module) {
|
|
@@ -5958,16 +6825,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5958
6825
|
return 'self';
|
|
5959
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);
|
|
5960
6827
|
let { trustedTypes } = output;
|
|
5961
|
-
trustedTypes && (F(trustedTypes, 'policyName', ()=>output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, '_') || '
|
|
5962
|
-
let forEachEntry = (fn)=>{
|
|
5963
|
-
if ('function' != typeof entry) for (let name of Object.keys(entry))fn(entry[name]);
|
|
5964
|
-
};
|
|
5965
|
-
A(output, 'enabledLibraryTypes', ()=>{
|
|
5966
|
-
let enabledLibraryTypes = [];
|
|
5967
|
-
return output.library && enabledLibraryTypes.push(output.library.type), forEachEntry((desc)=>{
|
|
5968
|
-
desc.library && enabledLibraryTypes.push(desc.library.type);
|
|
5969
|
-
}), enabledLibraryTypes;
|
|
5970
|
-
}), A(output, 'enabledChunkLoadingTypes', ()=>{
|
|
6828
|
+
trustedTypes && (F(trustedTypes, 'policyName', ()=>output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, '_') || 'rspack'), D(trustedTypes, 'onPolicyCreationFailure', 'stop')), A(output, 'enabledChunkLoadingTypes', ()=>{
|
|
5971
6829
|
let enabledChunkLoadingTypes = new Set();
|
|
5972
6830
|
return output.chunkLoading && enabledChunkLoadingTypes.add(output.chunkLoading), output.workerChunkLoading && enabledChunkLoadingTypes.add(output.workerChunkLoading), forEachEntry((desc)=>{
|
|
5973
6831
|
desc.chunkLoading && enabledChunkLoadingTypes.add(desc.chunkLoading);
|
|
@@ -5977,9 +6835,10 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5977
6835
|
return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
|
|
5978
6836
|
desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
|
|
5979
6837
|
}), Array.from(enabledWasmLoadingTypes);
|
|
5980
|
-
}), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-
|
|
5981
|
-
}, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp })=>{
|
|
5982
|
-
|
|
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));
|
|
6839
|
+
}, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
|
|
6840
|
+
let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
|
|
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')));
|
|
5983
6842
|
}, applyLoaderDefaults = (loader, { targetProperties, environment })=>{
|
|
5984
6843
|
F(loader, 'target', ()=>{
|
|
5985
6844
|
if (targetProperties) {
|
|
@@ -5990,23 +6849,20 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5990
6849
|
}
|
|
5991
6850
|
}), D(loader, 'environment', environment);
|
|
5992
6851
|
}, applyNodeDefaults = (node, { outputModule, targetProperties })=>{
|
|
5993
|
-
!1 !== node && (F(node, 'global', ()
|
|
6852
|
+
!1 !== node && (F(node, 'global', ()=>(!targetProperties || !targetProperties.global) && 'warn'), F(node, '__dirname', ()=>targetProperties && targetProperties.node ? outputModule ? 'node-module' : 'eval-only' : 'warn-mock'), F(node, '__filename', ()=>targetProperties && targetProperties.node ? outputModule ? 'node-module' : 'eval-only' : 'warn-mock'));
|
|
5994
6853
|
}, applyPerformanceDefaults = (performance, { production })=>{
|
|
5995
6854
|
!1 !== performance && (D(performance, 'maxAssetSize', 250000), D(performance, 'maxEntrypointSize', 250000), F(performance, 'hints', ()=>!!production && 'warning'));
|
|
5996
|
-
}, applyOptimizationDefaults = (optimization, { production, development
|
|
5997
|
-
D(optimization, '
|
|
6855
|
+
}, applyOptimizationDefaults = (optimization, { production, development })=>{
|
|
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', ()=>[
|
|
5998
6857
|
new SwcJsMinimizerRspackPlugin(),
|
|
5999
6858
|
new LightningCssMinimizerRspackPlugin()
|
|
6000
6859
|
]), F(optimization, 'nodeEnv', ()=>production ? 'production' : !!development && 'development');
|
|
6001
6860
|
let { splitChunks } = optimization;
|
|
6002
6861
|
if (splitChunks) {
|
|
6003
|
-
A(splitChunks, 'defaultSizeTypes', ()=>
|
|
6862
|
+
A(splitChunks, 'defaultSizeTypes', ()=>[
|
|
6004
6863
|
"javascript",
|
|
6005
6864
|
'css',
|
|
6006
6865
|
'unknown'
|
|
6007
|
-
] : [
|
|
6008
|
-
"javascript",
|
|
6009
|
-
'unknown'
|
|
6010
6866
|
]), D(splitChunks, 'hidePathInfo', production), D(splitChunks, 'chunks', 'async'), D(splitChunks, 'usedExports', !0 === optimization.usedExports), D(splitChunks, 'minChunks', 1), F(splitChunks, 'minSize', ()=>production ? 20000 : 10000), F(splitChunks, 'maxAsyncRequests', ()=>production ? 30 : 1 / 0), F(splitChunks, 'maxInitialRequests', ()=>production ? 30 : 1 / 0), D(splitChunks, 'automaticNameDelimiter', '-');
|
|
6011
6867
|
let { cacheGroups } = splitChunks;
|
|
6012
6868
|
cacheGroups && (F(cacheGroups, 'default', ()=>({
|
|
@@ -6017,7 +6873,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6017
6873
|
})), F(cacheGroups, 'defaultVendors', ()=>({
|
|
6018
6874
|
idHint: 'vendors',
|
|
6019
6875
|
reuseExistingChunk: !0,
|
|
6020
|
-
test: /[\\/]node_modules[\\/]
|
|
6876
|
+
test: /[\\/]node_modules[\\/]/,
|
|
6021
6877
|
priority: -10
|
|
6022
6878
|
})));
|
|
6023
6879
|
}
|
|
@@ -6040,16 +6896,15 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6040
6896
|
mainFiles: [
|
|
6041
6897
|
'index'
|
|
6042
6898
|
]
|
|
6043
|
-
}), getResolveDefaults = ({
|
|
6899
|
+
}), getResolveDefaults = ({ targetProperties, mode })=>{
|
|
6044
6900
|
let conditions = [
|
|
6045
6901
|
'webpack'
|
|
6046
6902
|
];
|
|
6047
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'));
|
|
6048
6904
|
let jsExtensions = [
|
|
6049
6905
|
'.js',
|
|
6050
|
-
'.json'
|
|
6051
|
-
|
|
6052
|
-
], browserField = targetProperties?.web && (!targetProperties.node || targetProperties.electron && targetProperties.electronRenderer), aliasFields = browserField ? [
|
|
6906
|
+
'.json'
|
|
6907
|
+
], browserField = targetProperties && targetProperties.web && (!targetProperties.node || targetProperties.electron && targetProperties.electronRenderer), aliasFields = browserField ? [
|
|
6053
6908
|
'browser'
|
|
6054
6909
|
] : [], mainFields = browserField ? [
|
|
6055
6910
|
'browser',
|
|
@@ -6094,9 +6949,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6094
6949
|
exportsFields: [
|
|
6095
6950
|
'exports'
|
|
6096
6951
|
],
|
|
6097
|
-
roots: [
|
|
6098
|
-
context
|
|
6099
|
-
],
|
|
6952
|
+
roots: [],
|
|
6100
6953
|
mainFields: [
|
|
6101
6954
|
'main'
|
|
6102
6955
|
],
|
|
@@ -6120,22 +6973,21 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6120
6973
|
unknown: cjsDeps()
|
|
6121
6974
|
}
|
|
6122
6975
|
};
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
}
|
|
6138
|
-
return resolveOptions;
|
|
6976
|
+
return resolveOptions.byDependency['css-import'] = {
|
|
6977
|
+
mainFiles: [],
|
|
6978
|
+
mainFields: [
|
|
6979
|
+
'style',
|
|
6980
|
+
'...'
|
|
6981
|
+
],
|
|
6982
|
+
conditionNames: [
|
|
6983
|
+
'development' === mode ? 'development' : 'production',
|
|
6984
|
+
'style'
|
|
6985
|
+
],
|
|
6986
|
+
extensions: [
|
|
6987
|
+
'.css'
|
|
6988
|
+
],
|
|
6989
|
+
preferRelative: !0
|
|
6990
|
+
}, resolveOptions;
|
|
6139
6991
|
}, D = (obj, prop, value)=>{
|
|
6140
6992
|
void 0 === obj[prop] && (obj[prop] = value);
|
|
6141
6993
|
}, F = (obj, prop, factory)=>{
|
|
@@ -6264,8 +7116,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6264
7116
|
]),
|
|
6265
7117
|
rules: nestedArray(module.rules, (r)=>[
|
|
6266
7118
|
...r
|
|
6267
|
-
])
|
|
6268
|
-
unsafeCache: module.unsafeCache
|
|
7119
|
+
])
|
|
6269
7120
|
})),
|
|
6270
7121
|
target: config.target,
|
|
6271
7122
|
externals: config.externals,
|
|
@@ -6301,7 +7152,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6301
7152
|
storage: {
|
|
6302
7153
|
type: 'filesystem',
|
|
6303
7154
|
directory: node_path.resolve(config.context || process.cwd(), cache.storage?.directory || 'node_modules/.cache/rspack')
|
|
6304
|
-
}
|
|
7155
|
+
},
|
|
7156
|
+
portable: cache.portable,
|
|
7157
|
+
readonly: cache.readonly
|
|
6305
7158
|
};
|
|
6306
7159
|
}),
|
|
6307
7160
|
stats: nestedConfig(config.stats, (stats)=>!1 === stats ? {
|
|
@@ -6332,7 +7185,6 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6332
7185
|
]),
|
|
6333
7186
|
experiments: nestedConfig(config.experiments, (experiments)=>({
|
|
6334
7187
|
...experiments,
|
|
6335
|
-
incremental: optionalNestedConfig(experiments.incremental, (options)=>getNormalizedIncrementalOptions(options)),
|
|
6336
7188
|
buildHttp: experiments.buildHttp,
|
|
6337
7189
|
useInputFileSystem: experiments.useInputFileSystem
|
|
6338
7190
|
})),
|
|
@@ -6341,7 +7193,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6341
7193
|
devServer: config.devServer,
|
|
6342
7194
|
amd: config.amd,
|
|
6343
7195
|
bail: config.bail,
|
|
6344
|
-
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))
|
|
6345
7198
|
};
|
|
6346
7199
|
}, getNormalizedEntryStatic = (entry)=>{
|
|
6347
7200
|
if ('string' == typeof entry) return {
|
|
@@ -6398,12 +7251,11 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6398
7251
|
}
|
|
6399
7252
|
}, getNormalizedIncrementalOptions = (incremental)=>!1 !== incremental && 'none' !== incremental && ('safe' === incremental ? {
|
|
6400
7253
|
silent: !0,
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
buildChunkGraph: !1,
|
|
7254
|
+
buildModuleGraph: !0,
|
|
7255
|
+
finishModules: !1,
|
|
7256
|
+
optimizeDependencies: !1,
|
|
7257
|
+
buildChunkGraph: !0,
|
|
7258
|
+
optimizeChunkModules: !1,
|
|
6407
7259
|
moduleIds: !1,
|
|
6408
7260
|
chunkIds: !1,
|
|
6409
7261
|
modulesHashes: !1,
|
|
@@ -6411,7 +7263,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
6411
7263
|
modulesRuntimeRequirements: !1,
|
|
6412
7264
|
chunksRuntimeRequirements: !1,
|
|
6413
7265
|
chunksHashes: !1,
|
|
6414
|
-
|
|
7266
|
+
chunkAsset: !1,
|
|
6415
7267
|
emitAssets: !0
|
|
6416
7268
|
} : !0 === incremental || 'advance-silent' === incremental ? {} : 'advance' === incremental ? {
|
|
6417
7269
|
silent: !1
|
|
@@ -7207,10 +8059,10 @@ class MultiStats {
|
|
|
7207
8059
|
hasWarnings() {
|
|
7208
8060
|
return this.stats.some((stat)=>stat.hasWarnings());
|
|
7209
8061
|
}
|
|
7210
|
-
#createChildOptions(options
|
|
8062
|
+
#createChildOptions(options, context) {
|
|
7211
8063
|
let { children: childrenOptions, ...baseOptions } = 'string' == typeof options || 'boolean' == typeof options ? {
|
|
7212
8064
|
preset: options
|
|
7213
|
-
} : options, children = this.stats.map((stat, idx)=>{
|
|
8065
|
+
} : options ?? {}, children = this.stats.map((stat, idx)=>{
|
|
7214
8066
|
let childOptions = Array.isArray(childrenOptions) ? childrenOptions[idx] : childrenOptions;
|
|
7215
8067
|
return stat.compilation.createStatsOptions({
|
|
7216
8068
|
...baseOptions,
|
|
@@ -7237,7 +8089,7 @@ class MultiStats {
|
|
|
7237
8089
|
obj.children = this.stats.map((stat, idx)=>{
|
|
7238
8090
|
let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
|
|
7239
8091
|
return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
|
|
7240
|
-
}), 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(''));
|
|
7241
8093
|
let mapError = (j, obj)=>({
|
|
7242
8094
|
...obj,
|
|
7243
8095
|
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
|
@@ -7644,7 +8496,7 @@ class NodeWatchFileSystem {
|
|
|
7644
8496
|
if ('number' != typeof startTime && startTime) throw Error("Invalid arguments: 'startTime'");
|
|
7645
8497
|
if ('object' != typeof options) throw Error("Invalid arguments: 'options'");
|
|
7646
8498
|
if ('function' != typeof callbackUndelayed && callbackUndelayed) throw Error("Invalid arguments: 'callbackUndelayed'");
|
|
7647
|
-
let oldWatcher = this.watcher, Watchpack = NodeWatchFileSystem_require('watchpack');
|
|
8499
|
+
let oldWatcher = this.watcher, Watchpack = NodeWatchFileSystem_require('../compiled/watchpack/index.js');
|
|
7648
8500
|
this.watcher = new Watchpack(options), callbackUndelayed && this.watcher?.once('change', callbackUndelayed);
|
|
7649
8501
|
let fetchTimeInfo = ()=>{
|
|
7650
8502
|
let fileTimeInfoEntries = new Map(), contextTimeInfoEntries = new Map();
|
|
@@ -7734,7 +8586,7 @@ let arraySum = (array)=>{
|
|
|
7734
8586
|
let str = `${a}`, length = lengths[i];
|
|
7735
8587
|
return str.length === length ? str : length > 5 ? `...${str.slice(-length + 3)}` : length > 0 ? str.slice(-length) : '';
|
|
7736
8588
|
});
|
|
7737
|
-
}, 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");
|
|
7738
8590
|
var CachedInputFileSystem_default = __webpack_require__.n(CachedInputFileSystem);
|
|
7739
8591
|
class NodeEnvironmentPlugin {
|
|
7740
8592
|
options;
|
|
@@ -7836,7 +8688,7 @@ class NodeEnvironmentPlugin {
|
|
|
7836
8688
|
if ('' === str) return str;
|
|
7837
8689
|
let prefixWithIndent = currentIndent + prefix;
|
|
7838
8690
|
return colors ? prefixWithIndent + colorPrefix + str.replace(/\n/g, `${colorSuffix}\n${prefix}${colorPrefix}`) + colorSuffix : prefixWithIndent + str.replace(/\n/g, `\n${prefix}`);
|
|
7839
|
-
})(
|
|
8691
|
+
})(__rspack_external_node_util_1b29d436.format(...args), prefix, colorPrefix, colorSuffix);
|
|
7840
8692
|
stream.write(`${str}\n`), writeStatusMessage();
|
|
7841
8693
|
}, writeGroupMessage = writeColored('<-> ', '\u001b[1m\u001b[36m', '\u001b[39m\u001b[22m'), writeGroupCollapsedMessage = writeColored('<+> ', '\u001b[1m\u001b[36m', '\u001b[39m\u001b[22m');
|
|
7842
8694
|
return {
|
|
@@ -8393,15 +9245,21 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8393
9245
|
if (context.makePathsRelative || (context.makePathsRelative = makePathsRelative.bindContextCache(compilation.compiler.context, compilation.compiler.root)), !context.cachedGetErrors) {
|
|
8394
9246
|
let map = new WeakMap();
|
|
8395
9247
|
context.cachedGetErrors = (compilation)=>{
|
|
8396
|
-
|
|
8397
|
-
|
|
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;
|
|
8398
9253
|
};
|
|
8399
9254
|
}
|
|
8400
9255
|
if (!context.cachedGetWarnings) {
|
|
8401
9256
|
let map = new WeakMap();
|
|
8402
9257
|
context.cachedGetWarnings = (compilation)=>{
|
|
8403
|
-
|
|
8404
|
-
|
|
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;
|
|
8405
9263
|
};
|
|
8406
9264
|
}
|
|
8407
9265
|
compilation.name && (object.name = compilation.name);
|
|
@@ -8469,7 +9327,7 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8469
9327
|
let [label, first, second] = entry.args;
|
|
8470
9328
|
'number' == typeof first && 'number' == typeof second && (message = `${label}: ${1000 * first + second / 1000000} ms`);
|
|
8471
9329
|
}
|
|
8472
|
-
message || (message = entry.args?.length ?
|
|
9330
|
+
message || (message = entry.args?.length ? __rspack_external_node_util_1b29d436.format(entry.args[0], ...entry.args.slice(1)) : '');
|
|
8473
9331
|
let newEntry = {
|
|
8474
9332
|
type,
|
|
8475
9333
|
message: message || '',
|
|
@@ -8490,7 +9348,7 @@ let iterateConfig = (config, options, fn)=>{
|
|
|
8490
9348
|
object.hash = context.getStatsCompilation(compilation).hash;
|
|
8491
9349
|
},
|
|
8492
9350
|
version: (object)=>{
|
|
8493
|
-
object.version = "5.75.0", object.rspackVersion = "2.0.0-
|
|
9351
|
+
object.version = "5.75.0", object.rspackVersion = "2.0.0-rc.0";
|
|
8494
9352
|
},
|
|
8495
9353
|
env: (object, _compilation, _context, { _env })=>{
|
|
8496
9354
|
object.env = _env;
|
|
@@ -8793,6 +9651,7 @@ let applyDefaults = (options, defaults)=>{
|
|
|
8793
9651
|
entrypoints: !0,
|
|
8794
9652
|
chunkGroups: !0,
|
|
8795
9653
|
ids: !0,
|
|
9654
|
+
assets: !0,
|
|
8796
9655
|
modules: !1,
|
|
8797
9656
|
chunks: !0,
|
|
8798
9657
|
chunkRelations: !0,
|
|
@@ -8823,11 +9682,13 @@ let applyDefaults = (options, defaults)=>{
|
|
|
8823
9682
|
detailed: {
|
|
8824
9683
|
hash: !0,
|
|
8825
9684
|
builtAt: !0,
|
|
9685
|
+
assets: !0,
|
|
8826
9686
|
relatedAssets: !0,
|
|
8827
9687
|
entrypoints: !0,
|
|
8828
9688
|
chunkGroups: !0,
|
|
8829
9689
|
ids: !0,
|
|
8830
9690
|
chunks: !0,
|
|
9691
|
+
modules: !0,
|
|
8831
9692
|
chunkRelations: !0,
|
|
8832
9693
|
chunkModules: !1,
|
|
8833
9694
|
chunkOrigins: !0,
|
|
@@ -8889,26 +9750,26 @@ let applyDefaults = (options, defaults)=>{
|
|
|
8889
9750
|
none: {
|
|
8890
9751
|
all: !1
|
|
8891
9752
|
}
|
|
8892
|
-
}, NORMAL_ON = ({ all })=>!1 !== all, NORMAL_OFF = ({ all })=>!0 === all, ON_FOR_TO_STRING = ({ all }, { forToString })=>forToString ? !1 !== all : !0 === all, OFF_FOR_TO_STRING = ({ all }, { forToString })=>forToString ? !0 === all : !1 !== all,
|
|
9753
|
+
}, NORMAL_ON = ({ all })=>!1 !== all, NORMAL_OFF = ({ all })=>!0 === all, ON_FOR_TO_STRING = ({ all }, { forToString })=>forToString ? !1 !== all : !0 === all, OFF_FOR_TO_STRING = ({ all }, { forToString })=>forToString ? !0 === all : !1 !== all, DEFAULTS = {
|
|
8893
9754
|
performance: NORMAL_ON,
|
|
8894
9755
|
hash: OFF_FOR_TO_STRING,
|
|
8895
9756
|
env: NORMAL_OFF,
|
|
8896
9757
|
version: NORMAL_ON,
|
|
8897
9758
|
timings: NORMAL_ON,
|
|
8898
9759
|
builtAt: OFF_FOR_TO_STRING,
|
|
8899
|
-
assets:
|
|
8900
|
-
entrypoints:
|
|
8901
|
-
chunkGroups:
|
|
9760
|
+
assets: NORMAL_OFF,
|
|
9761
|
+
entrypoints: NORMAL_OFF,
|
|
9762
|
+
chunkGroups: NORMAL_OFF,
|
|
8902
9763
|
chunkGroupAuxiliary: OFF_FOR_TO_STRING,
|
|
8903
9764
|
chunkGroupChildren: OFF_FOR_TO_STRING,
|
|
8904
9765
|
chunkGroupMaxAssets: (_, { forToString })=>forToString ? 5 : 1 / 0,
|
|
8905
|
-
chunks:
|
|
9766
|
+
chunks: NORMAL_OFF,
|
|
8906
9767
|
chunkRelations: OFF_FOR_TO_STRING,
|
|
8907
9768
|
chunkModules: ({ all, modules })=>!1 !== all && (!0 === all || !modules),
|
|
8908
9769
|
dependentModules: OFF_FOR_TO_STRING,
|
|
8909
9770
|
chunkOrigins: OFF_FOR_TO_STRING,
|
|
8910
9771
|
ids: OFF_FOR_TO_STRING,
|
|
8911
|
-
modules:
|
|
9772
|
+
modules: NORMAL_OFF,
|
|
8912
9773
|
nestedModules: OFF_FOR_TO_STRING,
|
|
8913
9774
|
groupModulesByType: ON_FOR_TO_STRING,
|
|
8914
9775
|
groupModulesByCacheStatus: ON_FOR_TO_STRING,
|
|
@@ -8943,7 +9804,7 @@ let applyDefaults = (options, defaults)=>{
|
|
|
8943
9804
|
moduleTrace: NORMAL_ON,
|
|
8944
9805
|
errors: NORMAL_ON,
|
|
8945
9806
|
errorsCount: NORMAL_ON,
|
|
8946
|
-
errorDetails:
|
|
9807
|
+
errorDetails: ({ all }, { forToString })=>!1 !== all && (!0 === all || !forToString || 'auto'),
|
|
8947
9808
|
errorStack: OFF_FOR_TO_STRING,
|
|
8948
9809
|
warnings: NORMAL_ON,
|
|
8949
9810
|
warningsCount: NORMAL_ON,
|
|
@@ -8959,7 +9820,7 @@ let applyDefaults = (options, defaults)=>{
|
|
|
8959
9820
|
chunksSort: ()=>!1,
|
|
8960
9821
|
assetsSort: ()=>'!size',
|
|
8961
9822
|
outputPath: OFF_FOR_TO_STRING,
|
|
8962
|
-
colors: ()
|
|
9823
|
+
colors: ()=>isStatsColorSupported()
|
|
8963
9824
|
}, normalizeFilter = (item)=>{
|
|
8964
9825
|
if ('string' == typeof item) {
|
|
8965
9826
|
let regExp = RegExp(`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, '\\$&')}([\\\\/]|$|!|\\?)`);
|
|
@@ -9716,7 +10577,7 @@ class RspackOptionsApply {
|
|
|
9716
10577
|
if (!options.externalsType) throw Error('options.externalsType should have a value after `applyRspackOptionsDefaults`');
|
|
9717
10578
|
new ExternalsPlugin(options.externalsType, options.externals, !1).apply(compiler);
|
|
9718
10579
|
}
|
|
9719
|
-
if (options.externalsPresets.node && new NodeTargetPlugin().apply(compiler), options.externalsPresets.electronMain && new ElectronTargetPlugin('main').apply(compiler), options.externalsPresets.electronPreload && new ElectronTargetPlugin('preload').apply(compiler), options.externalsPresets.electronRenderer && new ElectronTargetPlugin('renderer').apply(compiler), !options.externalsPresets.electron || options.externalsPresets.electronMain || options.externalsPresets.electronPreload || options.externalsPresets.electronRenderer || new ElectronTargetPlugin().apply(compiler), options.externalsPresets.nwjs && new ExternalsPlugin('node-commonjs', 'nw.gui', !1).apply(compiler), (options.externalsPresets.web || options.externalsPresets.webAsync || options.externalsPresets.node
|
|
10580
|
+
if (options.externalsPresets.node && new NodeTargetPlugin().apply(compiler), options.externalsPresets.electronMain && new ElectronTargetPlugin('main').apply(compiler), options.externalsPresets.electronPreload && new ElectronTargetPlugin('preload').apply(compiler), options.externalsPresets.electronRenderer && new ElectronTargetPlugin('renderer').apply(compiler), !options.externalsPresets.electron || options.externalsPresets.electronMain || options.externalsPresets.electronPreload || options.externalsPresets.electronRenderer || new ElectronTargetPlugin().apply(compiler), options.externalsPresets.nwjs && new ExternalsPlugin('node-commonjs', 'nw.gui', !1).apply(compiler), (options.externalsPresets.web || options.externalsPresets.webAsync || options.externalsPresets.node) && new HttpExternalsRspackPlugin(!0, !!options.externalsPresets.webAsync).apply(compiler), new ChunkPrefetchPreloadPlugin().apply(compiler), options.output.pathinfo && new ModuleInfoHeaderPlugin('verbose' === options.output.pathinfo).apply(compiler), 'string' == typeof options.output.chunkFormat) switch(options.output.chunkFormat){
|
|
9720
10581
|
case 'array-push':
|
|
9721
10582
|
new ArrayPushCallbackChunkFormatPlugin().apply(compiler);
|
|
9722
10583
|
break;
|
|
@@ -9749,8 +10610,13 @@ class RspackOptionsApply {
|
|
|
9749
10610
|
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
|
|
9750
10611
|
namespace: options.output.devtoolNamespace
|
|
9751
10612
|
}).apply(compiler);
|
|
9752
|
-
|
|
9753
|
-
|
|
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);
|
|
10618
|
+
}
|
|
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);
|
|
9754
10620
|
let moduleIds = options.optimization.moduleIds;
|
|
9755
10621
|
if (moduleIds) switch(moduleIds){
|
|
9756
10622
|
case 'named':
|
|
@@ -9833,13 +10699,16 @@ function createCompiler(userOptions) {
|
|
|
9833
10699
|
if (new NodeEnvironmentPlugin({
|
|
9834
10700
|
infrastructureLogging: options.infrastructureLogging
|
|
9835
10701
|
}).apply(compiler), Array.isArray(options.plugins)) for (let plugin of options.plugins)'function' == typeof plugin ? plugin.call(compiler, compiler) : plugin && plugin.apply(compiler);
|
|
9836
|
-
let
|
|
9837
|
-
return
|
|
10702
|
+
let tp = applyRspackOptionsDefaults(compiler.options);
|
|
10703
|
+
return tp && (compiler.platform = tp.platform, compiler.target = {
|
|
10704
|
+
esVersion: tp.esVersion,
|
|
10705
|
+
targets: tp.targets
|
|
10706
|
+
}), compiler.hooks.environment.call(), compiler.hooks.afterEnvironment.call(), new RspackOptionsApply().process(compiler.options, compiler), compiler.hooks.initialize.call(), compiler;
|
|
9838
10707
|
}
|
|
9839
10708
|
function isMultiRspackOptions(o) {
|
|
9840
10709
|
return Array.isArray(o);
|
|
9841
10710
|
}
|
|
9842
|
-
function
|
|
10711
|
+
function rspack_rspack(options, callback) {
|
|
9843
10712
|
try {
|
|
9844
10713
|
if (isMultiRspackOptions(options)) for (let option of options)validateRspackConfig(option);
|
|
9845
10714
|
else validateRspackConfig(options);
|
|
@@ -10136,7 +11005,7 @@ class TraceHookPlugin {
|
|
|
10136
11005
|
});
|
|
10137
11006
|
}
|
|
10138
11007
|
}
|
|
10139
|
-
let CORE_VERSION = "2.0.0-
|
|
11008
|
+
let CORE_VERSION = "2.0.0-rc.0", VFILES_BY_COMPILER = new WeakMap();
|
|
10140
11009
|
class VirtualModulesPlugin {
|
|
10141
11010
|
#staticModules;
|
|
10142
11011
|
#compiler;
|
|
@@ -10281,22 +11150,23 @@ class Watching {
|
|
|
10281
11150
|
let startTime = this.startTime;
|
|
10282
11151
|
this.startTime = void 0, compilation.startTime = startTime, compilation.endTime = Date.now();
|
|
10283
11152
|
let cbs = this.callbacks;
|
|
10284
|
-
this.callbacks = []
|
|
10285
|
-
let fileDependencies = new Set([
|
|
10286
|
-
...compilation.fileDependencies
|
|
10287
|
-
]);
|
|
10288
|
-
fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
|
|
10289
|
-
let contextDependencies = new Set([
|
|
10290
|
-
...compilation.contextDependencies
|
|
10291
|
-
]);
|
|
10292
|
-
contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
|
|
10293
|
-
let missingDependencies = new Set([
|
|
10294
|
-
...compilation.missingDependencies
|
|
10295
|
-
]);
|
|
10296
|
-
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)=>{
|
|
10297
11154
|
if (err) return handleError(err, cbs);
|
|
10298
11155
|
for (let cb of (this.handler(null, stats), process.nextTick(()=>{
|
|
10299
|
-
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
|
+
}
|
|
10300
11170
|
}), cbs))cb(null);
|
|
10301
11171
|
this.compiler.hooks.afterDone.call(stats);
|
|
10302
11172
|
});
|
|
@@ -10316,7 +11186,7 @@ class Watching {
|
|
|
10316
11186
|
this.suspended && (this.suspended = !1, this.#invalidate());
|
|
10317
11187
|
}
|
|
10318
11188
|
}
|
|
10319
|
-
let Compiler_require = createRequire(import.meta.url);
|
|
11189
|
+
let Compiler_require = createRequire(import.meta.url), GET_COMPILER_ID = Symbol('getCompilerId');
|
|
10320
11190
|
class Compiler {
|
|
10321
11191
|
#instance;
|
|
10322
11192
|
#initial;
|
|
@@ -10355,6 +11225,7 @@ class Compiler {
|
|
|
10355
11225
|
cache;
|
|
10356
11226
|
compilerPath;
|
|
10357
11227
|
#platform;
|
|
11228
|
+
#target;
|
|
10358
11229
|
options;
|
|
10359
11230
|
unsafeFastDrop = !1;
|
|
10360
11231
|
__internal_browser_require;
|
|
@@ -10446,8 +11317,19 @@ class Compiler {
|
|
|
10446
11317
|
]),
|
|
10447
11318
|
additionalPass: new AsyncSeriesHook([])
|
|
10448
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
|
+
});
|
|
10449
11331
|
let compilerRspack = Object.assign(function(...params) {
|
|
10450
|
-
return
|
|
11332
|
+
return rspack_rspack(...params);
|
|
10451
11333
|
}, exports_namespaceObject, {
|
|
10452
11334
|
RuntimeGlobals: createCompilerRuntimeGlobals(options)
|
|
10453
11335
|
});
|
|
@@ -10458,9 +11340,14 @@ class Compiler {
|
|
|
10458
11340
|
node: null,
|
|
10459
11341
|
nwjs: null,
|
|
10460
11342
|
electron: null
|
|
10461
|
-
}, this.__internal_browser_require = ()=>{
|
|
11343
|
+
}, this.#target = {}, this.__internal_browser_require = ()=>{
|
|
10462
11344
|
throw Error('Cannot execute user defined code in browser without `BrowserRequirePlugin`');
|
|
10463
|
-
}, 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
|
+
});
|
|
10464
11351
|
}
|
|
10465
11352
|
get recordsInputPath() {
|
|
10466
11353
|
return unsupported('Compiler.recordsInputPath');
|
|
@@ -10483,6 +11370,12 @@ class Compiler {
|
|
|
10483
11370
|
set platform(platform) {
|
|
10484
11371
|
this.#platform = platform;
|
|
10485
11372
|
}
|
|
11373
|
+
get target() {
|
|
11374
|
+
return this.#target;
|
|
11375
|
+
}
|
|
11376
|
+
set target(target) {
|
|
11377
|
+
this.#target = target;
|
|
11378
|
+
}
|
|
10486
11379
|
get __internal__builtinPlugins() {
|
|
10487
11380
|
return this.#builtinPlugins;
|
|
10488
11381
|
}
|
|
@@ -10613,7 +11506,8 @@ class Compiler {
|
|
|
10613
11506
|
}) : this.hooks.shutdown.callAsync((err)=>{
|
|
10614
11507
|
if (err) return callback(err);
|
|
10615
11508
|
this.cache.shutdown(()=>{
|
|
10616
|
-
this.#instance?.close()
|
|
11509
|
+
let closePromise = this.#instance?.close();
|
|
11510
|
+
closePromise ? closePromise.then(()=>callback(), callback) : callback();
|
|
10617
11511
|
});
|
|
10618
11512
|
});
|
|
10619
11513
|
}
|
|
@@ -10654,7 +11548,7 @@ class Compiler {
|
|
|
10654
11548
|
}
|
|
10655
11549
|
#getInstance(callback) {
|
|
10656
11550
|
var output;
|
|
10657
|
-
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.
|
|
10658
11552
|
|
|
10659
11553
|
Help:
|
|
10660
11554
|
Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
|
|
@@ -10715,8 +11609,7 @@ Help:
|
|
|
10715
11609
|
k,
|
|
10716
11610
|
getRawGeneratorOptions(v, k)
|
|
10717
11611
|
]).filter(([_, v])=>void 0 !== v)),
|
|
10718
|
-
noParse: module.noParse
|
|
10719
|
-
unsafeCache: module.unsafeCache
|
|
11612
|
+
noParse: module.noParse
|
|
10720
11613
|
};
|
|
10721
11614
|
}(options.module, {
|
|
10722
11615
|
compiler: this,
|
|
@@ -10726,7 +11619,7 @@ Help:
|
|
|
10726
11619
|
}),
|
|
10727
11620
|
optimization: options.optimization,
|
|
10728
11621
|
stats: {
|
|
10729
|
-
colors:
|
|
11622
|
+
colors: void 0 === (statsOptions = function(options) {
|
|
10730
11623
|
if ('boolean' == typeof options || 'string' == typeof options) return presetToOptions(options);
|
|
10731
11624
|
if (!options) return {};
|
|
10732
11625
|
let obj = {
|
|
@@ -10734,10 +11627,11 @@ Help:
|
|
|
10734
11627
|
...options
|
|
10735
11628
|
};
|
|
10736
11629
|
return delete obj.preset, obj;
|
|
10737
|
-
}(options.stats).colors
|
|
11630
|
+
}(options.stats)).colors ? isStatsColorSupported() : !!statsOptions.colors
|
|
10738
11631
|
},
|
|
10739
11632
|
cache: options.cache || !1,
|
|
10740
11633
|
experiments,
|
|
11634
|
+
incremental: options.incremental,
|
|
10741
11635
|
node: function(node) {
|
|
10742
11636
|
if (!1 !== node) {
|
|
10743
11637
|
if (isNil(node.__dirname) || isNil(node.global) || isNil(node.__filename)) throw Error('node.__dirname, node.global, node.__filename should not be nil');
|
|
@@ -10997,6 +11891,29 @@ Help:
|
|
|
10997
11891
|
return queried.promise(getCompiler().__internal__get_compilation().chunks, getCompiler().__internal__get_compilation().modules);
|
|
10998
11892
|
};
|
|
10999
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
|
+
}),
|
|
11000
11917
|
registerCompilationChunkHashTaps: createTap(binding_default().RegisterJsTapKind.CompilationChunkHash, function() {
|
|
11001
11918
|
return getCompiler().__internal__get_compilation().hooks.chunkHash;
|
|
11002
11919
|
}, function(queried) {
|
|
@@ -11539,68 +12456,7 @@ class LoaderTargetPlugin {
|
|
|
11539
12456
|
});
|
|
11540
12457
|
}
|
|
11541
12458
|
}
|
|
11542
|
-
let
|
|
11543
|
-
function isRequiredVersion(str) {
|
|
11544
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
11545
|
-
}
|
|
11546
|
-
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
11547
|
-
function isPlainObject(value) {
|
|
11548
|
-
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
11549
|
-
}
|
|
11550
|
-
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
11551
|
-
name = binding_namespaceObject.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
11552
|
-
opts;
|
|
11553
|
-
constructor(opts){
|
|
11554
|
-
super(), this.opts = opts;
|
|
11555
|
-
}
|
|
11556
|
-
raw(compiler) {
|
|
11557
|
-
var isDev;
|
|
11558
|
-
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
|
|
11559
|
-
if (!manifestOptions) return {
|
|
11560
|
-
statsFileName: STATS_FILE_NAME,
|
|
11561
|
-
manifestFileName: MANIFEST_FILE_NAME
|
|
11562
|
-
};
|
|
11563
|
-
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;
|
|
11564
|
-
return {
|
|
11565
|
-
statsFileName: join(filePath, fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME),
|
|
11566
|
-
manifestFileName: join(filePath, manifestFileName)
|
|
11567
|
-
};
|
|
11568
|
-
}(this.opts), rawOptions = {
|
|
11569
|
-
name: this.opts.name,
|
|
11570
|
-
globalName: this.opts.globalName,
|
|
11571
|
-
fileName,
|
|
11572
|
-
filePath,
|
|
11573
|
-
manifestFileName,
|
|
11574
|
-
statsFileName,
|
|
11575
|
-
disableAssetsAnalyze,
|
|
11576
|
-
remoteAliasMap,
|
|
11577
|
-
exposes,
|
|
11578
|
-
shared,
|
|
11579
|
-
buildInfo: (isDev = 'development' === compiler.options.mode, pkg = function(root) {
|
|
11580
|
-
let pkgPath = join(root ? external_node_path_resolve(root) : process.cwd(), 'package.json');
|
|
11581
|
-
try {
|
|
11582
|
-
let content = readFileSync(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
11583
|
-
try {
|
|
11584
|
-
let parsed = JSON.parse(input);
|
|
11585
|
-
if (guard(parsed)) return parsed;
|
|
11586
|
-
} catch {}
|
|
11587
|
-
}(content, isPlainObject);
|
|
11588
|
-
if (parsed) {
|
|
11589
|
-
let filtered = {};
|
|
11590
|
-
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
11591
|
-
if (Object.keys(filtered).length > 0) return filtered;
|
|
11592
|
-
}
|
|
11593
|
-
} catch {}
|
|
11594
|
-
return {};
|
|
11595
|
-
}(compiler.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, {
|
|
11596
|
-
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
11597
|
-
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
11598
|
-
})
|
|
11599
|
-
};
|
|
11600
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
11601
|
-
}
|
|
11602
|
-
}
|
|
11603
|
-
let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
12459
|
+
let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
11604
12460
|
let items = [];
|
|
11605
12461
|
var fn = (key, value)=>{
|
|
11606
12462
|
items.push([
|
|
@@ -11617,63 +12473,7 @@ let ModuleFederationRuntimePlugin = base_create(binding_namespaceObject.BuiltinP
|
|
|
11617
12473
|
else if ('object' == typeof options) object(options);
|
|
11618
12474
|
else throw Error('Unexpected options format');
|
|
11619
12475
|
return items;
|
|
11620
|
-
},
|
|
11621
|
-
function getRemoteInfos(options) {
|
|
11622
|
-
if (!options.remotes) return {};
|
|
11623
|
-
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
11624
|
-
external: Array.isArray(item) ? item : [
|
|
11625
|
-
item
|
|
11626
|
-
],
|
|
11627
|
-
shareScope: options.shareScope || 'default'
|
|
11628
|
-
}), (item)=>({
|
|
11629
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
11630
|
-
item.external
|
|
11631
|
-
],
|
|
11632
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
11633
|
-
})), remoteInfos = {};
|
|
11634
|
-
for (let [key, config] of remotes)for (let external of config.external){
|
|
11635
|
-
let [externalType, externalRequest] = function(external) {
|
|
11636
|
-
let result = function(external) {
|
|
11637
|
-
if (/^[a-z0-9-]+ /.test(external)) {
|
|
11638
|
-
let idx = external.indexOf(' ');
|
|
11639
|
-
return [
|
|
11640
|
-
external.slice(0, idx),
|
|
11641
|
-
external.slice(idx + 1)
|
|
11642
|
-
];
|
|
11643
|
-
}
|
|
11644
|
-
return null;
|
|
11645
|
-
}(external);
|
|
11646
|
-
return null === result ? [
|
|
11647
|
-
remoteType,
|
|
11648
|
-
external
|
|
11649
|
-
] : result;
|
|
11650
|
-
}(external);
|
|
11651
|
-
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
11652
|
-
let [url, global] = function(urlAndGlobal) {
|
|
11653
|
-
let index = urlAndGlobal.indexOf('@');
|
|
11654
|
-
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
11655
|
-
urlAndGlobal.substring(index + 1),
|
|
11656
|
-
urlAndGlobal.substring(0, index)
|
|
11657
|
-
];
|
|
11658
|
-
}(externalRequest);
|
|
11659
|
-
remoteInfos[key].push({
|
|
11660
|
-
alias: key,
|
|
11661
|
-
name: global,
|
|
11662
|
-
entry: url,
|
|
11663
|
-
externalType,
|
|
11664
|
-
shareScope: config.shareScope
|
|
11665
|
-
});
|
|
11666
|
-
} else remoteInfos[key].push({
|
|
11667
|
-
alias: key,
|
|
11668
|
-
name: void 0,
|
|
11669
|
-
entry: void 0,
|
|
11670
|
-
externalType,
|
|
11671
|
-
shareScope: config.shareScope
|
|
11672
|
-
});
|
|
11673
|
-
}
|
|
11674
|
-
return remoteInfos;
|
|
11675
|
-
}
|
|
11676
|
-
let compilerSet = new WeakSet();
|
|
12476
|
+
}, compilerSet = new WeakSet();
|
|
11677
12477
|
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
11678
12478
|
enhanced;
|
|
11679
12479
|
name = binding_namespaceObject.BuiltinPluginName.ShareRuntimePlugin;
|
|
@@ -11684,42 +12484,55 @@ class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
|
11684
12484
|
if (!compilerSet.has(compiler)) return compilerSet.add(compiler), createBuiltinPlugin(this.name, this.enhanced);
|
|
11685
12485
|
}
|
|
11686
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
|
+
}
|
|
11687
12530
|
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
11688
12531
|
name = binding_namespaceObject.BuiltinPluginName.ConsumeSharedPlugin;
|
|
11689
12532
|
_options;
|
|
11690
12533
|
constructor(options){
|
|
11691
12534
|
super(), this._options = {
|
|
11692
|
-
consumes:
|
|
11693
|
-
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
11694
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
11695
|
-
import: key,
|
|
11696
|
-
shareScope: options.shareScope || 'default',
|
|
11697
|
-
shareKey: key,
|
|
11698
|
-
requiredVersion: item,
|
|
11699
|
-
strictVersion: !0,
|
|
11700
|
-
packageName: void 0,
|
|
11701
|
-
singleton: !1,
|
|
11702
|
-
eager: !1
|
|
11703
|
-
} : {
|
|
11704
|
-
import: key,
|
|
11705
|
-
shareScope: options.shareScope || 'default',
|
|
11706
|
-
shareKey: key,
|
|
11707
|
-
requiredVersion: void 0,
|
|
11708
|
-
packageName: void 0,
|
|
11709
|
-
strictVersion: !1,
|
|
11710
|
-
singleton: !1,
|
|
11711
|
-
eager: !1
|
|
11712
|
-
};
|
|
11713
|
-
}, (item, key)=>({
|
|
11714
|
-
import: !1 === item.import ? void 0 : item.import || key,
|
|
11715
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
11716
|
-
shareKey: item.shareKey || key,
|
|
11717
|
-
requiredVersion: item.requiredVersion,
|
|
11718
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
11719
|
-
packageName: item.packageName,
|
|
11720
|
-
singleton: !!item.singleton,
|
|
11721
|
-
eager: !!item.eager
|
|
11722
|
-
})),
|
|
12535
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
11723
12536
|
enhanced: options.enhanced ?? !1
|
|
11724
12537
|
};
|
|
11725
12538
|
}
|
|
@@ -11740,28 +12553,30 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
11740
12553
|
_provides;
|
|
11741
12554
|
_enhanced;
|
|
11742
12555
|
constructor(options){
|
|
11743
|
-
|
|
12556
|
+
var options1, shareScope, enhanced;
|
|
12557
|
+
super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
|
|
11744
12558
|
if (Array.isArray(item)) throw Error('Unexpected array of provides');
|
|
11745
12559
|
return {
|
|
11746
12560
|
shareKey: item,
|
|
11747
12561
|
version: void 0,
|
|
11748
|
-
shareScope:
|
|
12562
|
+
shareScope: shareScope || 'default',
|
|
11749
12563
|
eager: !1
|
|
11750
12564
|
};
|
|
11751
12565
|
}, (item)=>{
|
|
11752
12566
|
let raw = {
|
|
11753
12567
|
shareKey: item.shareKey,
|
|
11754
12568
|
version: item.version,
|
|
11755
|
-
shareScope: item.shareScope ||
|
|
12569
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
11756
12570
|
eager: !!item.eager
|
|
11757
12571
|
};
|
|
11758
|
-
return
|
|
12572
|
+
return enhanced ? {
|
|
11759
12573
|
...raw,
|
|
11760
12574
|
singleton: item.singleton,
|
|
11761
12575
|
requiredVersion: item.requiredVersion,
|
|
11762
|
-
strictVersion: item.strictVersion
|
|
12576
|
+
strictVersion: item.strictVersion,
|
|
12577
|
+
treeShakingMode: item.treeShakingMode
|
|
11763
12578
|
} : raw;
|
|
11764
|
-
}), this._enhanced = options.enhanced;
|
|
12579
|
+
})), this._enhanced = options.enhanced;
|
|
11765
12580
|
}
|
|
11766
12581
|
raw(compiler) {
|
|
11767
12582
|
new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
|
|
@@ -11772,32 +12587,43 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
|
11772
12587
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
11773
12588
|
}
|
|
11774
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
|
+
}
|
|
11775
12619
|
class SharePlugin {
|
|
11776
12620
|
_shareScope;
|
|
11777
12621
|
_consumes;
|
|
11778
12622
|
_provides;
|
|
11779
12623
|
_enhanced;
|
|
12624
|
+
_sharedOptions;
|
|
11780
12625
|
constructor(options){
|
|
11781
|
-
let sharedOptions =
|
|
11782
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
11783
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
11784
|
-
import: key,
|
|
11785
|
-
requiredVersion: item
|
|
11786
|
-
} : {
|
|
11787
|
-
import: item
|
|
11788
|
-
};
|
|
11789
|
-
}, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
|
|
11790
|
-
[key]: {
|
|
11791
|
-
import: options.import,
|
|
11792
|
-
shareKey: options.shareKey || key,
|
|
11793
|
-
shareScope: options.shareScope,
|
|
11794
|
-
requiredVersion: options.requiredVersion,
|
|
11795
|
-
strictVersion: options.strictVersion,
|
|
11796
|
-
singleton: options.singleton,
|
|
11797
|
-
packageName: options.packageName,
|
|
11798
|
-
eager: options.eager
|
|
11799
|
-
}
|
|
11800
|
-
})), 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])=>({
|
|
11801
12627
|
[options.import || key]: {
|
|
11802
12628
|
shareKey: options.shareKey || key,
|
|
11803
12629
|
shareScope: options.shareScope,
|
|
@@ -11805,10 +12631,11 @@ class SharePlugin {
|
|
|
11805
12631
|
eager: options.eager,
|
|
11806
12632
|
singleton: options.singleton,
|
|
11807
12633
|
requiredVersion: options.requiredVersion,
|
|
11808
|
-
strictVersion: options.strictVersion
|
|
12634
|
+
strictVersion: options.strictVersion,
|
|
12635
|
+
treeShakingMode: options.treeShaking?.mode
|
|
11809
12636
|
}
|
|
11810
12637
|
}));
|
|
11811
|
-
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;
|
|
11812
12639
|
}
|
|
11813
12640
|
apply(compiler) {
|
|
11814
12641
|
new ConsumeSharedPlugin({
|
|
@@ -11822,15 +12649,566 @@ class SharePlugin {
|
|
|
11822
12649
|
}).apply(compiler);
|
|
11823
12650
|
}
|
|
11824
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
|
+
}
|
|
11825
13201
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
11826
13202
|
name = binding_namespaceObject.BuiltinPluginName.ContainerPlugin;
|
|
11827
13203
|
_options;
|
|
11828
13204
|
constructor(options){
|
|
11829
|
-
super()
|
|
13205
|
+
super();
|
|
13206
|
+
let shareScope = options.shareScope || 'default', enhanced = options.enhanced ?? !1;
|
|
13207
|
+
validateShareScope(shareScope, enhanced, 'ContainerPlugin'), this._options = {
|
|
11830
13208
|
name: options.name,
|
|
11831
|
-
shareScope
|
|
13209
|
+
shareScope,
|
|
11832
13210
|
library: options.library || {
|
|
11833
|
-
type: '
|
|
13211
|
+
type: 'global',
|
|
11834
13212
|
name: options.name
|
|
11835
13213
|
},
|
|
11836
13214
|
runtime: options.runtime,
|
|
@@ -11846,7 +13224,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
11846
13224
|
],
|
|
11847
13225
|
name: item.name || void 0
|
|
11848
13226
|
})),
|
|
11849
|
-
enhanced
|
|
13227
|
+
enhanced
|
|
11850
13228
|
};
|
|
11851
13229
|
}
|
|
11852
13230
|
raw(compiler) {
|
|
@@ -11871,29 +13249,38 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
|
|
|
11871
13249
|
name = binding_namespaceObject.BuiltinPluginName.ContainerReferencePlugin;
|
|
11872
13250
|
_options;
|
|
11873
13251
|
constructor(options){
|
|
11874
|
-
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 = {
|
|
11875
13268
|
remoteType: options.remoteType,
|
|
11876
|
-
remotes
|
|
11877
|
-
|
|
11878
|
-
item
|
|
11879
|
-
],
|
|
11880
|
-
shareScope: options.shareScope || 'default'
|
|
11881
|
-
}), (item)=>({
|
|
11882
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
11883
|
-
item.external
|
|
11884
|
-
],
|
|
11885
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
11886
|
-
})),
|
|
11887
|
-
enhanced: options.enhanced ?? !1
|
|
13269
|
+
remotes,
|
|
13270
|
+
enhanced
|
|
11888
13271
|
};
|
|
11889
13272
|
}
|
|
11890
13273
|
raw(compiler) {
|
|
11891
|
-
let { remoteType, remotes } = this._options, remoteExternals = {};
|
|
13274
|
+
let { remoteType, remotes } = this._options, remoteExternals = {}, importExternals = {};
|
|
11892
13275
|
for (let [key, config] of remotes){
|
|
11893
13276
|
let i = 0;
|
|
11894
|
-
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
|
+
}
|
|
11895
13282
|
}
|
|
11896
|
-
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);
|
|
11897
13284
|
let rawOptions = {
|
|
11898
13285
|
remoteType: this._options.remoteType,
|
|
11899
13286
|
remotes: this._options.remotes.map(([key, r])=>({
|
|
@@ -11913,7 +13300,7 @@ async function transform(source, options) {
|
|
|
11913
13300
|
let _options = JSON.stringify(options || {});
|
|
11914
13301
|
return binding_default().transform(source, _options);
|
|
11915
13302
|
}
|
|
11916
|
-
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 = {
|
|
11917
13304
|
getNormalizedRspackOptions: getNormalizedRspackOptions,
|
|
11918
13305
|
applyRspackOptionsDefaults: applyRspackOptionsDefaults,
|
|
11919
13306
|
getNormalizedWebpackOptions: getNormalizedRspackOptions,
|
|
@@ -11956,10 +13343,12 @@ let exports_rspackVersion = "2.0.0-canary-20260116", exports_version = "5.75.0",
|
|
|
11956
13343
|
ContainerReferencePlugin: ContainerReferencePlugin,
|
|
11957
13344
|
ModuleFederationPlugin: class {
|
|
11958
13345
|
_options;
|
|
13346
|
+
_treeShakingSharedPlugin;
|
|
11959
13347
|
constructor(_options){
|
|
11960
13348
|
this._options = _options;
|
|
11961
13349
|
}
|
|
11962
13350
|
apply(compiler) {
|
|
13351
|
+
var options;
|
|
11963
13352
|
let { webpack } = compiler, paths = function(options, compiler) {
|
|
11964
13353
|
let runtimeToolsPath;
|
|
11965
13354
|
if (options.implementation) runtimeToolsPath = options.implementation;
|
|
@@ -11988,101 +13377,55 @@ let exports_rspackVersion = "2.0.0-canary-20260116", exports_version = "5.75.0",
|
|
|
11988
13377
|
runtime: runtimePath
|
|
11989
13378
|
};
|
|
11990
13379
|
}(this._options, compiler);
|
|
11991
|
-
|
|
13380
|
+
compiler.options.resolve.alias = {
|
|
11992
13381
|
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
11993
13382
|
'@module-federation/runtime': paths.runtime,
|
|
11994
13383
|
...compiler.options.resolve.alias
|
|
11995
|
-
},
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
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,
|
|
12017
13426
|
enhanced: !0
|
|
12018
|
-
}
|
|
12019
|
-
|
|
12020
|
-
...this._options.manifest
|
|
12021
|
-
}, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
|
|
12022
|
-
if (!library) return;
|
|
12023
|
-
let libName = library.name;
|
|
12024
|
-
if (libName) {
|
|
12025
|
-
if ('string' == typeof libName) return libName;
|
|
12026
|
-
if (Array.isArray(libName)) return libName[0];
|
|
12027
|
-
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12028
|
-
}
|
|
12029
|
-
}(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
12030
|
-
if (cur[1].length > 1) return sum;
|
|
12031
|
-
let { entry, alias, name } = cur[1][0];
|
|
12032
|
-
return entry && name && (sum[alias] = {
|
|
12033
|
-
name,
|
|
12034
|
-
entry
|
|
12035
|
-
}), sum;
|
|
12036
|
-
}, {}), manifestExposes = function(exposes) {
|
|
12037
|
-
if (!exposes) return;
|
|
12038
|
-
let result = parseOptions(exposes, (value)=>({
|
|
12039
|
-
import: Array.isArray(value) ? value : [
|
|
12040
|
-
value
|
|
12041
|
-
],
|
|
12042
|
-
name: void 0
|
|
12043
|
-
}), (value)=>({
|
|
12044
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
12045
|
-
value.import
|
|
12046
|
-
],
|
|
12047
|
-
name: value.name ?? void 0
|
|
12048
|
-
})).map(([exposeKey, info])=>{
|
|
12049
|
-
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12050
|
-
return {
|
|
12051
|
-
path: exposeKey,
|
|
12052
|
-
name: exposeName
|
|
12053
|
-
};
|
|
12054
|
-
});
|
|
12055
|
-
return result.length > 0 ? result : void 0;
|
|
12056
|
-
}(this._options.exposes);
|
|
12057
|
-
void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
|
|
12058
|
-
let manifestShared = function(shared) {
|
|
12059
|
-
if (!shared) return;
|
|
12060
|
-
let result = parseOptions(shared, (item, key)=>{
|
|
12061
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12062
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12063
|
-
import: key,
|
|
12064
|
-
requiredVersion: item
|
|
12065
|
-
} : {
|
|
12066
|
-
import: item
|
|
12067
|
-
};
|
|
12068
|
-
}, (item)=>item).map(([key, config])=>{
|
|
12069
|
-
let name = config.shareKey || key;
|
|
12070
|
-
return {
|
|
12071
|
-
name,
|
|
12072
|
-
version: 'string' == typeof config.version ? config.version : void 0,
|
|
12073
|
-
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12074
|
-
singleton: config.singleton
|
|
12075
|
-
};
|
|
12076
|
-
});
|
|
12077
|
-
return result.length > 0 ? result : void 0;
|
|
12078
|
-
}(this._options.shared);
|
|
12079
|
-
void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
|
|
12080
|
-
...manifestOptions,
|
|
12081
|
-
name: containerName,
|
|
12082
|
-
globalName,
|
|
12083
|
-
remoteAliasMap
|
|
12084
|
-
}).apply(compiler);
|
|
12085
|
-
}
|
|
13427
|
+
};
|
|
13428
|
+
new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
12086
13429
|
}
|
|
12087
13430
|
},
|
|
12088
13431
|
ModuleFederationPluginV1: class {
|
|
@@ -12119,6 +13462,7 @@ let exports_rspackVersion = "2.0.0-canary-20260116", exports_version = "5.75.0",
|
|
|
12119
13462
|
}
|
|
12120
13463
|
}, sharing = {
|
|
12121
13464
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
13465
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
12122
13466
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
12123
13467
|
SharePlugin: SharePlugin
|
|
12124
13468
|
}, exports_experiments = {
|
|
@@ -12130,8 +13474,7 @@ let exports_rspackVersion = "2.0.0-canary-20260116", exports_version = "5.75.0",
|
|
|
12130
13474
|
await JavaScriptTracer.cleanupJavaScriptTrace(), (0, binding_namespaceObject.syncTraceEvent)(JavaScriptTracer.events), (0, binding_namespaceObject.cleanupGlobalTrace)();
|
|
12131
13475
|
}
|
|
12132
13476
|
},
|
|
12133
|
-
RemoveDuplicateModulesPlugin:
|
|
12134
|
-
EsmLibraryPlugin: EsmLibraryPlugin,
|
|
13477
|
+
RemoveDuplicateModulesPlugin: RemoveDuplicateModulesPlugin_RemoveDuplicateModulesPlugin,
|
|
12135
13478
|
RsdoctorPlugin: RsdoctorPluginImpl,
|
|
12136
13479
|
RstestPlugin: RstestPlugin,
|
|
12137
13480
|
RslibPlugin: RslibPlugin,
|
|
@@ -12158,12 +13501,36 @@ let exports_rspackVersion = "2.0.0-canary-20260116", exports_version = "5.75.0",
|
|
|
12158
13501
|
if (INTERNAL_PLUGIN_NAMES.includes(name)) throw Error(`Cannot register native plugin with name '${name}', it conflicts with internal plugin names.`);
|
|
12159
13502
|
return base_create(name, resolve, affectedHooks);
|
|
12160
13503
|
},
|
|
12161
|
-
VirtualModulesPlugin: VirtualModulesPlugin
|
|
12162
|
-
|
|
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);
|
|
12163
13532
|
src_fn.rspack = src_fn, src_fn.webpack = src_fn;
|
|
12164
13533
|
let src_rspack_0 = src_fn;
|
|
12165
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;
|
|
12166
13535
|
export default src_rspack_0;
|
|
12167
|
-
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 };
|
|
12168
|
-
|
|
12169
|
-
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 };
|