@rsbuild/core 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.d.ts +2 -0
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/declaration.d.ts +2 -2
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +160 -38
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +1 -0
- package/dist/1.js +1 -0
- package/dist/client/hmr.js +19 -8
- package/dist/http-proxy-middleware.js +8 -4
- package/dist/index.d.ts +1 -1
- package/dist/m.js +288 -203
- package/dist/manifest-plugin.js +1 -1
- package/dist/memfs.js +1 -1
- package/dist/range-parser.js +86 -48
- package/dist/rslib-runtime.js +9 -6
- package/dist/server/buildManager.d.ts +3 -2
- package/dist/server/devServer.d.ts +2 -0
- package/dist/server/socketServer.d.ts +9 -2
- package/dist/sirv.js +3 -2
- package/dist/transformRawLoader.mjs +2 -2
- package/dist/types/config.d.ts +7 -2
- package/dist/types/plugin.d.ts +7 -0
- package/package.json +11 -15
- package/types.d.ts +9 -0
package/dist/m.js
CHANGED
|
@@ -4,7 +4,7 @@ import { rspackRequire, moduleFactories, compatGetDefaultExport, createFakeNames
|
|
|
4
4
|
import { rspack as core_rspack } from "@rspack/core";
|
|
5
5
|
import node_util, { format as external_node_util_format, promisify, stripVTControlCharacters } from "node:util";
|
|
6
6
|
import node_path, { dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, resolve as external_node_path_resolve, sep } from "node:path";
|
|
7
|
-
import {
|
|
7
|
+
import { createRequire, isBuiltin, createRequire as __rspack_createRequire } from "node:module";
|
|
8
8
|
import node_fs, { existsSync, readFileSync } from "node:fs";
|
|
9
9
|
import node_os, { constants } from "node:os";
|
|
10
10
|
import node_process from "node:process";
|
|
@@ -292,8 +292,8 @@ moduleFactories.add({
|
|
|
292
292
|
};
|
|
293
293
|
};
|
|
294
294
|
},
|
|
295
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
296
|
-
let yaml, { resolve } = __rspack_createRequire_require("node:path"), config = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lilconfig/3.1.3/8e9a79516bf61f8427342cef50cdad2cdc2572f42288ba8053b88eadfdc0ebef/node_modules/lilconfig/src/index.js"), loadOptions = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
295
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/index.js" (module) {
|
|
296
|
+
let yaml, { resolve } = __rspack_createRequire_require("node:path"), config = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lilconfig/3.1.3/8e9a79516bf61f8427342cef50cdad2cdc2572f42288ba8053b88eadfdc0ebef/node_modules/lilconfig/src/index.js"), loadOptions = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/options.js"), loadPlugins = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/plugins.js"), req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/req.js");
|
|
297
297
|
async function processResult(ctx, result) {
|
|
298
298
|
let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
|
|
299
299
|
default: obj
|
|
@@ -366,8 +366,8 @@ moduleFactories.add({
|
|
|
366
366
|
});
|
|
367
367
|
};
|
|
368
368
|
},
|
|
369
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
370
|
-
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
369
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/options.js" (module) {
|
|
370
|
+
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/req.js");
|
|
371
371
|
module.exports = async function options(config, file) {
|
|
372
372
|
if (config.parser && 'string' == typeof config.parser) try {
|
|
373
373
|
config.parser = await req(config.parser, file);
|
|
@@ -387,8 +387,8 @@ moduleFactories.add({
|
|
|
387
387
|
return config;
|
|
388
388
|
};
|
|
389
389
|
},
|
|
390
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
391
|
-
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
390
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/plugins.js" (module) {
|
|
391
|
+
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/req.js");
|
|
392
392
|
async function load(plugin, options, file) {
|
|
393
393
|
try {
|
|
394
394
|
if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
|
|
@@ -404,7 +404,7 @@ moduleFactories.add({
|
|
|
404
404
|
}), list;
|
|
405
405
|
};
|
|
406
406
|
},
|
|
407
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
407
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/req.js" (module) {
|
|
408
408
|
let tsx, jiti, { createRequire } = __rspack_createRequire_require("node:module"), { pathToFileURL } = __rspack_createRequire_require("node:url"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
|
|
409
409
|
module.exports = async function req(name, rootFile = __rspack_import_meta_filename__) {
|
|
410
410
|
let url = createRequire(rootFile).resolve(name);
|
|
@@ -552,58 +552,9 @@ isDebug() && (src_logger.level = 'verbose'), applyDebugOverride(src_logger);
|
|
|
552
552
|
let logger_createLogger = (...args)=>{
|
|
553
553
|
let instance = createLogger(...args);
|
|
554
554
|
return isDebug() && args[0]?.level === void 0 && (instance.level = 'verbose'), applyDebugOverride(instance), instance;
|
|
555
|
-
}
|
|
556
|
-
function toArr(any) {
|
|
557
|
-
return null == any ? [] : Array.isArray(any) ? any : [
|
|
558
|
-
any
|
|
559
|
-
];
|
|
560
|
-
}
|
|
561
|
-
function toVal(out, key, val, opts) {
|
|
562
|
-
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || !0 === val ? "" : String(val) : "boolean" == typeof val ? val : ~opts.boolean.indexOf(key) ? "false" !== val && ("true" === val || (out._.push(0 * (x = +val) == 0 ? x : val), !!val)) : 0 * (x = +val) == 0 ? x : val;
|
|
563
|
-
out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
|
|
564
|
-
old,
|
|
565
|
-
nxt
|
|
566
|
-
];
|
|
567
|
-
}
|
|
568
|
-
function lib_default(args, opts) {
|
|
569
|
-
opts = opts || {};
|
|
570
|
-
var k, arr, arg, name, val, out = {
|
|
571
|
-
_: []
|
|
572
|
-
}, i = 0, j = 0, idx = 0, len = (args = args || []).length;
|
|
573
|
-
let alibi = void 0 !== opts.alias, strict = void 0 !== opts.unknown, defaults = void 0 !== opts.default;
|
|
574
|
-
if (opts.alias = opts.alias || {}, opts.string = toArr(opts.string), opts.boolean = toArr(opts.boolean), alibi) for(k in opts.alias)for(arr = opts.alias[k] = toArr(opts.alias[k]), i = 0; i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
575
|
-
for(i = opts.boolean.length; i-- > 0;)for(j = (arr = opts.alias[opts.boolean[i]] || []).length; j-- > 0;)opts.boolean.push(arr[j]);
|
|
576
|
-
for(i = opts.string.length; i-- > 0;)for(j = (arr = opts.alias[opts.string[i]] || []).length; j-- > 0;)opts.string.push(arr[j]);
|
|
577
|
-
if (defaults) {
|
|
578
|
-
for(k in opts.default)if (name = typeof opts.default[k], arr = opts.alias[k] = opts.alias[k] || [], void 0 !== opts[name]) for(opts[name].push(k), i = 0; i < arr.length; i++)opts[name].push(arr[i]);
|
|
579
|
-
}
|
|
580
|
-
let keys = strict ? Object.keys(opts.alias) : [];
|
|
581
|
-
for(i = 0; i < len; i++){
|
|
582
|
-
if ("--" === (arg = args[i])) {
|
|
583
|
-
out._ = out._.concat(args.slice(++i));
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
|
|
587
|
-
if (0 === j) out._.push(arg);
|
|
588
|
-
else if ("no-" === arg.substring(j, j + 3)) {
|
|
589
|
-
if (name = arg.substring(j + 3), strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
590
|
-
out[name] = !1;
|
|
591
|
-
} else {
|
|
592
|
-
for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
|
|
593
|
-
for(name = arg.substring(j, idx), val = arg.substring(++idx) || i + 1 === len || 45 === ("" + args[i + 1]).charCodeAt(0) || args[++i], arr = 2 === j ? [
|
|
594
|
-
name
|
|
595
|
-
] : name, idx = 0; idx < arr.length; idx++){
|
|
596
|
-
if (name = arr[idx], strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
|
|
597
|
-
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
if (defaults) for(k in opts.default)void 0 === out[k] && (out[k] = opts.default[k]);
|
|
602
|
-
if (alibi) for(k in out)for(arr = opts.alias[k] || []; arr.length > 0;)out[arr.shift()] = out[k];
|
|
603
|
-
return out;
|
|
604
|
-
}
|
|
555
|
+
}, BRACKETS_AND_REST_RE = /[<[].+/, FILE_NAME_RE = /([^\\/]+)$/;
|
|
605
556
|
function removeBrackets(v) {
|
|
606
|
-
return v.replace(
|
|
557
|
+
return v.replace(BRACKETS_AND_REST_RE, "").trim();
|
|
607
558
|
}
|
|
608
559
|
function findAllBrackets(v) {
|
|
609
560
|
let angledMatch, squareMatch, ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g, SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g, res = [], parse = (match)=>{
|
|
@@ -649,7 +600,7 @@ function setDotProp(obj, keys, val) {
|
|
|
649
600
|
current[key] = val;
|
|
650
601
|
return;
|
|
651
602
|
}
|
|
652
|
-
if (null == current[key]) {
|
|
603
|
+
if (!Object.hasOwn(current, key) || null == current[key]) {
|
|
653
604
|
let nextKeyIsArrayIndex = +keys[i + 1] > -1;
|
|
654
605
|
current[key] = nextKeyIsArrayIndex ? [] : {};
|
|
655
606
|
}
|
|
@@ -662,7 +613,7 @@ function setByType(obj, transforms) {
|
|
|
662
613
|
].flat(), "function" == typeof transform.transformFunction && (obj[key] = obj[key].map(transform.transformFunction)));
|
|
663
614
|
}
|
|
664
615
|
function getFileName(input) {
|
|
665
|
-
let m =
|
|
616
|
+
let m = FILE_NAME_RE.exec(input);
|
|
666
617
|
return m ? m[1] : "";
|
|
667
618
|
}
|
|
668
619
|
function camelcaseOptionName(name) {
|
|
@@ -672,7 +623,9 @@ var CACError = class extends Error {
|
|
|
672
623
|
constructor(message){
|
|
673
624
|
super(message), this.name = "CACError", "function" != typeof Error.captureStackTrace && (this.stack = Error(message).stack);
|
|
674
625
|
}
|
|
675
|
-
}
|
|
626
|
+
};
|
|
627
|
+
let LEADING_DASHES_RE = /^-{1,2}/, NEGATED_PREFIX_RE = /^no-/;
|
|
628
|
+
var Option = class {
|
|
676
629
|
rawName;
|
|
677
630
|
description;
|
|
678
631
|
name;
|
|
@@ -683,8 +636,8 @@ var CACError = class extends Error {
|
|
|
683
636
|
negated;
|
|
684
637
|
constructor(rawName, description, config){
|
|
685
638
|
this.rawName = rawName, this.description = description, this.config = Object.assign({}, config), rawName = rawName.replaceAll(".*", ""), this.negated = !1, this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
686
|
-
let name = v.trim().replace(
|
|
687
|
-
return name.startsWith("no-") && (this.negated = !0, name = name.replace(
|
|
639
|
+
let name = v.trim().replace(LEADING_DASHES_RE, "");
|
|
640
|
+
return name.startsWith("no-") && (this.negated = !0, name = name.replace(NEGATED_PREFIX_RE, "")), camelcaseOptionName(name);
|
|
688
641
|
}).sort((a, b)=>a.length - b.length), this.name = this.names.at(-1), this.negated && null == this.config.default && (this.config.default = !0), rawName.includes("<") ? this.required = !0 : rawName.includes("[") ? this.required = !1 : this.isBoolean = !0;
|
|
689
642
|
}
|
|
690
643
|
};
|
|
@@ -813,14 +766,75 @@ var Command = class {
|
|
|
813
766
|
}
|
|
814
767
|
}
|
|
815
768
|
checkUnusedArgs() {
|
|
816
|
-
let maximumArgsCount = this.args.some((arg)=>arg.variadic) ?
|
|
769
|
+
let maximumArgsCount = this.args.some((arg)=>arg.variadic) ? 1e400 : this.args.length;
|
|
817
770
|
if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg)=>`\`${arg}\``).join(", ")}`);
|
|
818
771
|
}
|
|
819
772
|
}, GlobalCommand = class extends Command {
|
|
820
773
|
constructor(cli){
|
|
821
774
|
super("@@global@@", "", {}, cli);
|
|
822
775
|
}
|
|
823
|
-
}
|
|
776
|
+
};
|
|
777
|
+
function isNumeric(val) {
|
|
778
|
+
return Number.isFinite(+val);
|
|
779
|
+
}
|
|
780
|
+
function toVal(out, key, val, booleans) {
|
|
781
|
+
let next;
|
|
782
|
+
"boolean" == typeof val ? next = val : booleans.includes(key) ? "false" === val ? next = !1 : "true" === val ? next = !0 : (out._.push(isNumeric(val) ? +val : val), next = !!val) : next = isNumeric(val) ? +val : val;
|
|
783
|
+
let old = out[key];
|
|
784
|
+
out[key] = null == old ? next : Array.isArray(old) ? old.concat(next) : [
|
|
785
|
+
old,
|
|
786
|
+
next
|
|
787
|
+
];
|
|
788
|
+
}
|
|
789
|
+
function mri(args, opts) {
|
|
790
|
+
let out = Object.create(null);
|
|
791
|
+
out._ = [];
|
|
792
|
+
let aliases = Object.create(null);
|
|
793
|
+
for (let name of (Object.assign(aliases, opts.alias), Object.keys(aliases))){
|
|
794
|
+
let list = aliases[name];
|
|
795
|
+
for (let [i, alias] of list.entries())aliases[alias] = [
|
|
796
|
+
...list.slice(0, i),
|
|
797
|
+
...list.slice(i + 1),
|
|
798
|
+
name
|
|
799
|
+
];
|
|
800
|
+
}
|
|
801
|
+
let booleans = [
|
|
802
|
+
...opts.boolean
|
|
803
|
+
];
|
|
804
|
+
for (let name of opts.boolean){
|
|
805
|
+
let list = aliases[name];
|
|
806
|
+
list && booleans.push(...list);
|
|
807
|
+
}
|
|
808
|
+
for(let i = 0; i < args.length; i++){
|
|
809
|
+
let arg = args[i];
|
|
810
|
+
if ("--" === arg) {
|
|
811
|
+
out._ = out._.concat(args.slice(i + 1));
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
let dashes = 0;
|
|
815
|
+
for(; "-" === arg[dashes];)dashes++;
|
|
816
|
+
if (0 === dashes) {
|
|
817
|
+
out._.push(arg);
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
if ("no-" === arg.slice(dashes, dashes + 3)) {
|
|
821
|
+
out[arg.slice(dashes + 3)] = !1;
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
let eq = dashes + 1;
|
|
825
|
+
for(; eq < arg.length && "=" !== arg[eq];)eq++;
|
|
826
|
+
let name = arg.slice(dashes, eq), val = arg.slice(eq + 1) || i + 1 === args.length || String(args[i + 1]).startsWith("-") || args[++i], names = 2 === dashes ? [
|
|
827
|
+
name
|
|
828
|
+
] : name.split("");
|
|
829
|
+
for (let [idx, flag] of names.entries())toVal(out, flag, idx + 1 < names.length || val, booleans);
|
|
830
|
+
}
|
|
831
|
+
for (let key of Object.keys(out)){
|
|
832
|
+
let list = aliases[key];
|
|
833
|
+
if (list) for (let alias of list)out[alias] = out[key];
|
|
834
|
+
}
|
|
835
|
+
return out;
|
|
836
|
+
}
|
|
837
|
+
var CAC = class extends EventTarget {
|
|
824
838
|
name;
|
|
825
839
|
commands;
|
|
826
840
|
globalCommand;
|
|
@@ -914,7 +928,7 @@ var Command = class {
|
|
|
914
928
|
...command ? command.options : []
|
|
915
929
|
], mriOptions = getMriOptions(cliOptions), argsAfterDoubleDashes = [], doubleDashesIndex = argv.indexOf("--");
|
|
916
930
|
-1 !== doubleDashesIndex && (argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1), argv = argv.slice(0, doubleDashesIndex));
|
|
917
|
-
let parsed =
|
|
931
|
+
let parsed = mri(argv, mriOptions), args = (parsed = Object.keys(parsed).reduce((res, name)=>({
|
|
918
932
|
...res,
|
|
919
933
|
[camelcaseOptionName(name)]: parsed[name]
|
|
920
934
|
}), {
|
|
@@ -1993,8 +2007,8 @@ class RspackChain extends ChainedMap {
|
|
|
1993
2007
|
]);
|
|
1994
2008
|
}
|
|
1995
2009
|
}
|
|
1996
|
-
let vendors_require = createRequire(import.meta.url);
|
|
1997
|
-
var cjs_0_default = compatGetDefaultExport(
|
|
2010
|
+
let vendors_require = createRequire(import.meta.url), cjs_0 = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/deepmerge/4.3.1/56471899410038644780b3527c5076e78d3f57091a0da3ac0daf6d994929353d/node_modules/deepmerge/dist/cjs.js");
|
|
2011
|
+
var cjs_0_default = compatGetDefaultExport(cjs_0);
|
|
1998
2012
|
let setNodeEnv = (env)=>{
|
|
1999
2013
|
process.env.NODE_ENV = env;
|
|
2000
2014
|
}, isCI = ()=>!!process.env.CI && 'false' !== process.env.CI, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), objectPrototype = Object.prototype, helpers_getProto = Object.getPrototypeOf, isPlainObject = (obj)=>{
|
|
@@ -2079,11 +2093,8 @@ function resolveFileName(stats, logger) {
|
|
|
2079
2093
|
let file = stats.file || stats.moduleName;
|
|
2080
2094
|
if (file) return removeLoaderChainDelimiter(file, logger);
|
|
2081
2095
|
if (stats.moduleIdentifier) {
|
|
2082
|
-
let
|
|
2083
|
-
if (
|
|
2084
|
-
let fileName = matched.pop();
|
|
2085
|
-
if (fileName) return removeLoaderChainDelimiter(fileName, logger);
|
|
2086
|
-
}
|
|
2096
|
+
let fileName = stats.moduleIdentifier.slice(stats.moduleIdentifier.lastIndexOf('!') + 1);
|
|
2097
|
+
if (fileName) return removeLoaderChainDelimiter(fileName, logger);
|
|
2087
2098
|
}
|
|
2088
2099
|
return '';
|
|
2089
2100
|
}
|
|
@@ -2095,12 +2106,12 @@ function formatModuleTrace(stats, errorFile, root, level, logger) {
|
|
|
2095
2106
|
let formatted = removeLoaderChainDelimiter(errorFile, logger);
|
|
2096
2107
|
moduleNames[0] !== formatted && moduleNames.unshift(formatted);
|
|
2097
2108
|
}
|
|
2098
|
-
let trace = moduleNames.
|
|
2109
|
+
let trace = moduleNames.toReversed();
|
|
2099
2110
|
return trace.length > 4 && !isVerbose(logger) && (trace = [
|
|
2100
2111
|
...trace.slice(0, 2),
|
|
2101
2112
|
`... (${trace.length - 2 - 2} hidden)`,
|
|
2102
2113
|
...trace.slice(trace.length - 2)
|
|
2103
|
-
]), color.dim(`Import traces (entry → ${level}):\n ${trace.join('\n ')} ${color.bold(color.red('×'))}`);
|
|
2114
|
+
]), color.dim(`Import traces (entry → ${level}):\n ${trace.map((name)=>formatDiagnosticPath(name, root)).join('\n ')} ${color.bold(color.red('×'))}`);
|
|
2104
2115
|
}
|
|
2105
2116
|
function hintUnknownFiles(message) {
|
|
2106
2117
|
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
@@ -2109,37 +2120,45 @@ function hintUnknownFiles(message) {
|
|
|
2109
2120
|
for (let plugin of [
|
|
2110
2121
|
{
|
|
2111
2122
|
test: /File: .+\.s(c|a)ss/,
|
|
2112
|
-
|
|
2123
|
+
name: 'sass',
|
|
2124
|
+
keyword: 'Sass'
|
|
2113
2125
|
},
|
|
2114
2126
|
{
|
|
2115
2127
|
test: /File: .+\.less/,
|
|
2116
|
-
|
|
2128
|
+
name: 'less',
|
|
2129
|
+
keyword: 'Less'
|
|
2117
2130
|
},
|
|
2118
2131
|
{
|
|
2119
2132
|
test: /File: .+\.styl(us)?/,
|
|
2120
|
-
|
|
2133
|
+
name: 'stylus',
|
|
2134
|
+
keyword: 'Stylus'
|
|
2121
2135
|
},
|
|
2122
2136
|
{
|
|
2123
2137
|
test: /File: .+\.vue?/,
|
|
2124
|
-
|
|
2138
|
+
name: 'vue',
|
|
2139
|
+
keyword: 'Vue'
|
|
2125
2140
|
},
|
|
2126
2141
|
{
|
|
2127
2142
|
test: /File: .+\.svelte?/,
|
|
2128
|
-
|
|
2143
|
+
name: 'svelte',
|
|
2144
|
+
keyword: 'Svelte'
|
|
2129
2145
|
},
|
|
2130
2146
|
{
|
|
2131
2147
|
test: /File: .+\.mdx/,
|
|
2132
|
-
|
|
2148
|
+
name: 'mdx',
|
|
2149
|
+
keyword: 'MDX'
|
|
2133
2150
|
},
|
|
2134
2151
|
{
|
|
2135
2152
|
test: /File: .+\.toml/,
|
|
2136
|
-
|
|
2153
|
+
name: 'toml',
|
|
2154
|
+
keyword: 'TOML'
|
|
2137
2155
|
},
|
|
2138
2156
|
{
|
|
2139
2157
|
test: /File: .+\.yaml/,
|
|
2140
|
-
|
|
2158
|
+
name: 'yaml',
|
|
2159
|
+
keyword: 'YAML'
|
|
2141
2160
|
}
|
|
2142
|
-
])if (plugin.test.test(message)) return message.replace(hint, plugin.
|
|
2161
|
+
])if (plugin.test.test(message)) return message.replace(hint, createPluginHint(plugin.name, plugin.keyword));
|
|
2143
2162
|
return message;
|
|
2144
2163
|
}
|
|
2145
2164
|
function formatStatsError(stats, root, level = 'error', logger) {
|
|
@@ -2147,11 +2166,11 @@ function formatStatsError(stats, root, level = 'error', logger) {
|
|
|
2147
2166
|
if (!fileName) return '';
|
|
2148
2167
|
let DATA_URI_PREFIX = "data:text/javascript,";
|
|
2149
2168
|
if (fileName.startsWith(DATA_URI_PREFIX)) {
|
|
2150
|
-
let snippet = fileName.
|
|
2169
|
+
let snippet = fileName.slice(DATA_URI_PREFIX.length);
|
|
2151
2170
|
return snippet.length > 30 && (snippet = `${snippet.slice(0, 30)}...`), `File: ${color.cyan('data-uri virtual module')} ${color.dim(`(${snippet})`)}\n`;
|
|
2152
2171
|
}
|
|
2153
2172
|
let prefix = root + sep;
|
|
2154
|
-
return (fileName = fileName.startsWith(prefix) ? fileName.
|
|
2173
|
+
return (fileName = fileName.startsWith(prefix) ? `.${sep}${fileName.slice(prefix.length)}` : formatDiagnosticPath(fileName, root), /:\d+:\d+/.test(fileName)) ? `File: ${color.cyan(fileName)}\n` : stats.loc ? `File: ${color.cyan(`${fileName}:${stats.loc}`)}\n` : `File: ${color.cyan(`${fileName}:1:1`)}\n`;
|
|
2155
2174
|
})(fileName, stats, root)}${stats.message}`, verbose = isVerbose(logger);
|
|
2156
2175
|
if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level || isVerbose(logger)) {
|
|
2157
2176
|
let moduleTrace = formatModuleTrace(stats, fileName, root, level, logger);
|
|
@@ -2160,7 +2179,7 @@ function formatStatsError(stats, root, level = 'error', logger) {
|
|
|
2160
2179
|
let innerError = '-- inner error --';
|
|
2161
2180
|
!verbose && message.includes(innerError) && (message = message.split(innerError)[0]);
|
|
2162
2181
|
let lines = (message = ((message)=>{
|
|
2163
|
-
if (
|
|
2182
|
+
if (!message.includes('produce different content for the same output file') && !message.includes('Multiple assets emit different content to the same filename')) return message;
|
|
2164
2183
|
let extraMessage = `You may need to adjust ${color.yellow('output.filename')} configuration to prevent name conflicts. (See ${color.yellow('https://rsbuild.rs/config/output/filename')})`;
|
|
2165
2184
|
return `${message}\n${extraMessage}`;
|
|
2166
2185
|
})(message = ((message)=>{
|
|
@@ -2178,7 +2197,7 @@ function formatStatsError(stats, root, level = 'error', logger) {
|
|
|
2178
2197
|
let matchArray = stripVTControlCharacters(message).match(/Can't resolve '(\w+)'/);
|
|
2179
2198
|
if (!matchArray) return message;
|
|
2180
2199
|
let moduleName = matchArray[1];
|
|
2181
|
-
return moduleName &&
|
|
2200
|
+
return moduleName && isBuiltin(moduleName) ? getTips(moduleName) : message;
|
|
2182
2201
|
})(message = hintUnknownFiles(message)))).split('\n');
|
|
2183
2202
|
return (message = (lines = lines.filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim())).join('\n')).trim();
|
|
2184
2203
|
}
|
|
@@ -2247,7 +2266,11 @@ function formatStats(stats, hasErrors, root, logger) {
|
|
|
2247
2266
|
}
|
|
2248
2267
|
return {};
|
|
2249
2268
|
}
|
|
2250
|
-
let removeLoaderChainDelimiter = (moduleId, logger)=>
|
|
2269
|
+
let removeLoaderChainDelimiter = (moduleId, logger)=>{
|
|
2270
|
+
if (isVerbose(logger)) return moduleId;
|
|
2271
|
+
let index = moduleId.indexOf('!=!');
|
|
2272
|
+
return -1 === index ? moduleId : moduleId.slice(0, index);
|
|
2273
|
+
};
|
|
2251
2274
|
function createEnvironmentAsyncHook() {
|
|
2252
2275
|
let preGroup = [], postGroup = [], defaultGroup = [], tapEnvironment = ({ environment, handler: cb })=>{
|
|
2253
2276
|
isFunction(cb) ? defaultGroup.push({
|
|
@@ -2533,7 +2556,7 @@ async function pathExists(path) {
|
|
|
2533
2556
|
async function isFileExists(file) {
|
|
2534
2557
|
return node_fs.promises.access(file, node_fs.constants.F_OK).then(()=>!0).catch(()=>!1);
|
|
2535
2558
|
}
|
|
2536
|
-
|
|
2559
|
+
function fileExistsByCompilation({ inputFileSystem }, filePath) {
|
|
2537
2560
|
return new Promise((resolve)=>{
|
|
2538
2561
|
inputFileSystem ? inputFileSystem.stat(filePath, (err, stats)=>{
|
|
2539
2562
|
err ? resolve(!1) : resolve(!!stats?.isFile());
|
|
@@ -2587,8 +2610,14 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2587
2610
|
'provider',
|
|
2588
2611
|
'customLogger'
|
|
2589
2612
|
]), merge = (x, y, path = '')=>{
|
|
2590
|
-
|
|
2591
|
-
|
|
2613
|
+
if (((key)=>{
|
|
2614
|
+
let realKey = key;
|
|
2615
|
+
if (key.startsWith('environments.')) {
|
|
2616
|
+
let index = key.indexOf('.', 13);
|
|
2617
|
+
realKey = -1 === index ? '' : key.slice(index + 1);
|
|
2618
|
+
}
|
|
2619
|
+
return OVERRIDE_PATHS.has(realKey) || realKey.startsWith('output.filename.');
|
|
2620
|
+
})(path)) return y ?? x;
|
|
2592
2621
|
if (void 0 === x) return isPlainObject(y) ? cloneDeep(y) : y;
|
|
2593
2622
|
if (void 0 === y) return isPlainObject(x) ? cloneDeep(x) : x;
|
|
2594
2623
|
let typeX = typeof x, typeY = typeof y;
|
|
@@ -2645,7 +2674,6 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2645
2674
|
return 2 === configs.length ? merge(configs[0], configs[1]) : 0 === configs.length ? {} : configs.reduce((result, config)=>merge(result, config), {});
|
|
2646
2675
|
}, defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
|
|
2647
2676
|
dev: {
|
|
2648
|
-
hmr: !0,
|
|
2649
2677
|
liveReload: !0,
|
|
2650
2678
|
browserLogs: {
|
|
2651
2679
|
stackTrace: DEFAULT_STACK_TRACE
|
|
@@ -2873,7 +2901,11 @@ let isEnvironmentMatch = (pluginEnvironment, specifiedEnvironment)=>pluginEnviro
|
|
|
2873
2901
|
function createPluginManager(logger) {
|
|
2874
2902
|
let plugins = [];
|
|
2875
2903
|
return {
|
|
2876
|
-
getPlugins: (options = {})=>
|
|
2904
|
+
getPlugins: (options = {})=>{
|
|
2905
|
+
let result = [];
|
|
2906
|
+
for (let plugin of plugins)isEnvironmentMatch(plugin.environment, options.environment) && result.push(plugin.instance);
|
|
2907
|
+
return result;
|
|
2908
|
+
},
|
|
2877
2909
|
getAllPluginsWithMeta: ()=>plugins,
|
|
2878
2910
|
addPlugins: (newPlugins, options)=>{
|
|
2879
2911
|
let { before, environment } = options || {};
|
|
@@ -2902,11 +2934,6 @@ async function initPlugins({ context, pluginManager }) {
|
|
|
2902
2934
|
let plugins = pluginManager.getAllPluginsWithMeta();
|
|
2903
2935
|
plugins = ((plugins)=>{
|
|
2904
2936
|
let allLines = [], pluginNames = new Set(plugins.map((item)=>item.instance.name));
|
|
2905
|
-
function getPlugin(name) {
|
|
2906
|
-
let targets = plugins.filter((item)=>item.instance.name === name);
|
|
2907
|
-
if (!targets.length) throw Error(`${color.dim('[rsbuild:plugin]')} Plugin "${color.yellow(name)}" not existed`);
|
|
2908
|
-
return targets;
|
|
2909
|
-
}
|
|
2910
2937
|
for (let plugin of plugins){
|
|
2911
2938
|
if (plugin.instance.pre) for (let pre of plugin.instance.pre)pre && pluginNames.has(pre) && allLines.push([
|
|
2912
2939
|
pre,
|
|
@@ -2917,10 +2944,23 @@ async function initPlugins({ context, pluginManager }) {
|
|
|
2917
2944
|
post
|
|
2918
2945
|
]);
|
|
2919
2946
|
}
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2947
|
+
if (0 === allLines.length && pluginNames.size === plugins.length) return plugins.slice();
|
|
2948
|
+
let pluginsByName = new Map();
|
|
2949
|
+
for (let plugin of plugins){
|
|
2950
|
+
let { name } = plugin.instance, group = pluginsByName.get(name);
|
|
2951
|
+
group ? group.push(plugin) : pluginsByName.set(name, [
|
|
2952
|
+
plugin
|
|
2953
|
+
]);
|
|
2954
|
+
}
|
|
2955
|
+
function getPlugin(name) {
|
|
2956
|
+
let targets = pluginsByName.get(name) ?? [];
|
|
2957
|
+
if (!targets.length) throw Error(`${color.dim('[rsbuild:plugin]')} Plugin "${color.yellow(name)}" not existed`);
|
|
2958
|
+
return targets;
|
|
2959
|
+
}
|
|
2960
|
+
let endPoints = new Set(allLines.map((line)=>line[1])), zeroEndPoint = plugins.find((item)=>!endPoints.has(item.instance.name)), sortedPoint = [], sortedPluginNames = new Set();
|
|
2961
|
+
for(; zeroEndPoint;){
|
|
2962
|
+
let { name } = zeroEndPoint.instance, pluginInstances = getPlugin(name);
|
|
2963
|
+
sortedPoint.push(...pluginInstances), sortedPluginNames.add(name), endPoints = new Set((allLines = allLines.filter((line)=>line[0] !== name)).map((line)=>line[1])), zeroEndPoint = plugins.find((item)=>!sortedPluginNames.has(item.instance.name) && !endPoints.has(item.instance.name));
|
|
2924
2964
|
}
|
|
2925
2965
|
if (allLines.length) {
|
|
2926
2966
|
let restInRingPoints = {};
|
|
@@ -3033,7 +3073,7 @@ function initPluginAPI({ context, pluginManager }) {
|
|
|
3033
3073
|
}, GLOBAL_EXPOSED_KEY = Symbol('global-exposed'), exposed = new Map(), expose = (id, api, options)=>{
|
|
3034
3074
|
let exposedAPIs = exposed.get(id) ?? new Map(), key = options?.environment ?? GLOBAL_EXPOSED_KEY;
|
|
3035
3075
|
exposedAPIs.set(key, api), exposed.set(id, exposedAPIs);
|
|
3036
|
-
}, transformId = 0, transformer = {}, processAssetsFns = [], resolveFns = [];
|
|
3076
|
+
}, transformId = 0, transformer = {}, preTransformIds = new Set(), processAssetsFns = [], resolveFns = [];
|
|
3037
3077
|
hooks.modifyBundlerChain.tap((chain, { target, environment })=>{
|
|
3038
3078
|
let pluginName = 'RsbuildCorePlugin';
|
|
3039
3079
|
chain.plugin(pluginName).use(class {
|
|
@@ -3079,13 +3119,17 @@ function initPluginAPI({ context, pluginManager }) {
|
|
|
3079
3119
|
logger: context.logger,
|
|
3080
3120
|
transform: (0, (descriptor, handler)=>{
|
|
3081
3121
|
let id = `rsbuild-transform-${transformId++}`;
|
|
3082
|
-
transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
|
|
3122
|
+
transformer[id] = handler, void 0 !== descriptor.as && 'pre' === descriptor.order && preTransformIds.add(id), hooks.modifyBundlerChain.tapEnvironment({
|
|
3083
3123
|
environment: environment,
|
|
3084
3124
|
handler: (chain, { target, environment: environmentContext })=>{
|
|
3085
3125
|
if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environmentContext.name)) return;
|
|
3086
3126
|
let rule = chain.module.rule(id);
|
|
3087
|
-
|
|
3088
|
-
|
|
3127
|
+
if (preTransformIds.has(id)) {
|
|
3128
|
+
let firstRuleName = chain.module.rules.order().order.find((name)=>!preTransformIds.has(name));
|
|
3129
|
+
firstRuleName && rule.before(firstRuleName);
|
|
3130
|
+
}
|
|
3131
|
+
void 0 !== descriptor.as && rule.set('as', descriptor.as), descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with), descriptor.mimetype && rule.mimetype(descriptor.mimetype), descriptor.order && 'default' !== descriptor.order ? rule.enforce(descriptor.order) : descriptor.enforce && rule.enforce(descriptor.enforce);
|
|
3132
|
+
let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = join(LOADER_PATH, loaderName), use = rule.use(id).loader(loaderPath).options({
|
|
3089
3133
|
id,
|
|
3090
3134
|
getEnvironment: ()=>environmentContext
|
|
3091
3135
|
});
|
|
@@ -3175,7 +3219,8 @@ function initPluginAPI({ context, pluginManager }) {
|
|
|
3175
3219
|
});
|
|
3176
3220
|
}
|
|
3177
3221
|
function getAbsoluteDistPath(cwd, config) {
|
|
3178
|
-
|
|
3222
|
+
let dirRoot = config.output?.distPath?.root ?? "dist";
|
|
3223
|
+
return ensureAbsolutePath(cwd, dirRoot);
|
|
3179
3224
|
}
|
|
3180
3225
|
let browsersListCache = new Map();
|
|
3181
3226
|
function getBrowserslist(path) {
|
|
@@ -3258,7 +3303,7 @@ async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
|
3258
3303
|
return config;
|
|
3259
3304
|
})(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, hooks = initHooks();
|
|
3260
3305
|
return {
|
|
3261
|
-
version: "2.3.
|
|
3306
|
+
version: "2.3.4",
|
|
3262
3307
|
rootPath,
|
|
3263
3308
|
configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
|
|
3264
3309
|
configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
|
|
@@ -3346,7 +3391,7 @@ async function emitConfigFiles({ bundlerConfigs, environmentConfigs, extraConfig
|
|
|
3346
3391
|
};
|
|
3347
3392
|
}),
|
|
3348
3393
|
...bundlerConfigs.map(({ name, content })=>{
|
|
3349
|
-
let
|
|
3394
|
+
let outputFile = `rspack.config.${name}.mjs`, outputFilePath = join(outputPath, outputFile);
|
|
3350
3395
|
return node_fs.existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
|
|
3351
3396
|
path: outputFilePath,
|
|
3352
3397
|
label: `Rspack Config (${name})`,
|
|
@@ -3691,11 +3736,12 @@ function getConfigUtils(getCurrentConfig, chainUtils) {
|
|
|
3691
3736
|
};
|
|
3692
3737
|
}
|
|
3693
3738
|
function getChainUtils(target, environment, environments) {
|
|
3739
|
+
let nodeEnv = process.env.NODE_ENV || '';
|
|
3694
3740
|
return {
|
|
3695
3741
|
rspack: core_rspack,
|
|
3696
3742
|
environment,
|
|
3697
3743
|
environments,
|
|
3698
|
-
env:
|
|
3744
|
+
env: nodeEnv,
|
|
3699
3745
|
target,
|
|
3700
3746
|
isDev: 'development' === environment.config.mode,
|
|
3701
3747
|
isProd: 'production' === environment.config.mode,
|
|
@@ -3768,7 +3814,10 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
3768
3814
|
if (config.mode) return config.mode;
|
|
3769
3815
|
let nodeEnv = process.env.NODE_ENV || '';
|
|
3770
3816
|
return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
|
|
3771
|
-
})(),
|
|
3817
|
+
})(), defaultConfig.dev = {
|
|
3818
|
+
...defaultConfig.dev,
|
|
3819
|
+
hmr: 'development' === defaultConfig.mode
|
|
3820
|
+
}, mergeRsbuildConfig(defaultConfig, config)), environments = {}, mergedEnvironments = ((normalizedConfig, rootPath, specifiedEnvironments)=>{
|
|
3772
3821
|
let defaultEntry, { environments, dev, server: _server, ...baseConfig } = normalizedConfig, isEnvironmentEnabled = (name)=>!specifiedEnvironments || specifiedEnvironments.includes(name), baseEnvironmentConfig = {
|
|
3773
3822
|
...baseConfig,
|
|
3774
3823
|
dev: pick(dev, allowedEnvironmentDevKeys)
|
|
@@ -3871,14 +3920,14 @@ function cutPath(originalFilePath, root) {
|
|
|
3871
3920
|
return parts.length > 3 ? parts.slice(-3).join(sep) : parts.join(sep);
|
|
3872
3921
|
}
|
|
3873
3922
|
function isLikelyFile(filePath) {
|
|
3874
|
-
return (filePath.
|
|
3923
|
+
return filePath.slice(filePath.lastIndexOf(sep) + 1).includes('.');
|
|
3875
3924
|
}
|
|
3876
3925
|
function formatFileList(paths, rootPath) {
|
|
3877
3926
|
let files = paths.filter(isLikelyFile);
|
|
3878
3927
|
0 === files.length && paths.length > 0 && (files = [
|
|
3879
3928
|
paths[0]
|
|
3880
3929
|
]);
|
|
3881
|
-
let fileInfo = files.
|
|
3930
|
+
let fileInfo = files.length ? cutPath(files[0], rootPath) : '';
|
|
3882
3931
|
return files.length > 1 ? `${fileInfo} and ${files.length - 1} more` : fileInfo;
|
|
3883
3932
|
}
|
|
3884
3933
|
function printBuildLog(compiler, context, lazyModules) {
|
|
@@ -3904,9 +3953,9 @@ async function createCompiler_createCompiler(options) {
|
|
|
3904
3953
|
bundlerConfigs: rspackConfigs,
|
|
3905
3954
|
environments: context.environments
|
|
3906
3955
|
}), (version = core_rspack.rspackVersion).includes('-canary') && (version = version.split('-canary')[0]), !(!(version && /^[\d.]+$/.test(version)) || ((version1, version2)=>{
|
|
3907
|
-
let parts1 = version1.split('.')
|
|
3956
|
+
let parts1 = version1.split('.'), parts2 = version2.split('.'), len = Math.max(parts1.length, parts2.length);
|
|
3908
3957
|
for(let i = 0; i < len; i++){
|
|
3909
|
-
let item1 = parts1[i] ?? 0, item2 = parts2[i] ?? 0;
|
|
3958
|
+
let item1 = Number(parts1[i] ?? 0), item2 = Number(parts2[i] ?? 0);
|
|
3910
3959
|
if (item1 > item2) return 1;
|
|
3911
3960
|
if (item1 < item2) return -1;
|
|
3912
3961
|
}
|
|
@@ -3986,7 +4035,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
3986
4035
|
let isFirstCompile = !0, { environmentList } = context;
|
|
3987
4036
|
onBeforeCompile({
|
|
3988
4037
|
compiler,
|
|
3989
|
-
beforeEnvironmentCompile:
|
|
4038
|
+
beforeEnvironmentCompile: (buildIndex)=>{
|
|
3990
4039
|
let environment = environmentList[buildIndex];
|
|
3991
4040
|
return context.hooks.onBeforeEnvironmentCompile.callBatch({
|
|
3992
4041
|
environment: environment.name,
|
|
@@ -4000,7 +4049,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
4000
4049
|
]
|
|
4001
4050
|
});
|
|
4002
4051
|
},
|
|
4003
|
-
beforeCompile:
|
|
4052
|
+
beforeCompile: ()=>context.hooks.onBeforeDevCompile.callBatch({
|
|
4004
4053
|
bundlerConfigs,
|
|
4005
4054
|
environments: context.environments,
|
|
4006
4055
|
isFirstCompile,
|
|
@@ -4066,14 +4115,14 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (inp
|
|
|
4066
4115
|
let commonDistPath = getCommonParentPath(environmentWithHtml.map((item)=>item.distPath));
|
|
4067
4116
|
return environmentWithHtml.reduce((prev, environmentContext)=>{
|
|
4068
4117
|
let { distPath, config } = environmentContext, distPrefix = relative(commonDistPath, distPath).split(sep).join('/'), routes = formatRoutes(environmentContext.htmlPaths, context.normalizedConfig.server.base, posix.join(distPrefix, config.output.distPath.html), config.html.outputStructure);
|
|
4069
|
-
return prev.concat(
|
|
4118
|
+
return prev.concat(routes);
|
|
4070
4119
|
}, []);
|
|
4071
4120
|
}, formatRoutes = (entry, base, distPathPrefix, outputStructure)=>{
|
|
4072
|
-
let prefix = joinUrlPath(base, formatPrefix(distPathPrefix));
|
|
4073
|
-
return
|
|
4121
|
+
let prefix = joinUrlPath(base, formatPrefix(distPathPrefix)), entryNames = Object.keys(entry), index = entryNames.indexOf('index');
|
|
4122
|
+
return index > 0 && (entryNames.splice(index, 1), entryNames.unshift('index')), entryNames.map((entryName)=>({
|
|
4074
4123
|
entryName,
|
|
4075
4124
|
pathname: prefix + ('index' === entryName && 'nested' !== outputStructure ? '' : entryName)
|
|
4076
|
-
}))
|
|
4125
|
+
}));
|
|
4077
4126
|
}, formatName = (name)=>name ? `(${name.length > 20 ? `${name.slice(0, 19)}…` : name})` : name;
|
|
4078
4127
|
function getURLMessages(urls, routes, { maxRoutes = 10, showAllRoutes, cliShortcutsEnabled }) {
|
|
4079
4128
|
let prevName, routeLimit = showAllRoutes ? 1 / 0 : void 0 === maxRoutes ? 10 : 1 / 0 === maxRoutes ? maxRoutes : Math.max(0, Math.floor(maxRoutes)), printableRoutes = 0 === routeLimit ? [] : routes.slice(0, routeLimit), moreEntries = routeLimit > 0 ? routes.length - printableRoutes.length : 0, nameCount = 0;
|
|
@@ -4239,7 +4288,7 @@ function getServerTerminator(server) {
|
|
|
4239
4288
|
}), ()=>new Promise((resolve, reject)=>{
|
|
4240
4289
|
for (let socket of pendingSockets)socket.destroy();
|
|
4241
4290
|
listened ? server.close((err)=>{
|
|
4242
|
-
err ? reject(err) : resolve();
|
|
4291
|
+
err && 'ERR_SERVER_NOT_RUNNING' !== err.code ? reject(err) : resolve();
|
|
4243
4292
|
}) : resolve();
|
|
4244
4293
|
});
|
|
4245
4294
|
}
|
|
@@ -4423,8 +4472,8 @@ function loadEnv({ cwd = process.cwd(), mode = process.env.NODE_ENV || '', prefi
|
|
|
4423
4472
|
});
|
|
4424
4473
|
let publicVars = {}, rawPublicVars = {};
|
|
4425
4474
|
for (let key of Object.keys(processEnv))if (prefixes.some((prefix)=>key.startsWith(prefix))) {
|
|
4426
|
-
let val = processEnv[key];
|
|
4427
|
-
publicVars[`import.meta.env.${key}`] =
|
|
4475
|
+
let val = processEnv[key], serialized = JSON.stringify(val);
|
|
4476
|
+
publicVars[`import.meta.env.${key}`] = serialized, publicVars[`process.env.${key}`] = serialized, rawPublicVars[key] = val;
|
|
4428
4477
|
}
|
|
4429
4478
|
let cleaned = !1;
|
|
4430
4479
|
return {
|
|
@@ -5021,8 +5070,9 @@ function parseMinifyOptions(config) {
|
|
|
5021
5070
|
cssOptions: minify.cssOptions
|
|
5022
5071
|
};
|
|
5023
5072
|
}
|
|
5024
|
-
|
|
5025
|
-
|
|
5073
|
+
let postcss_load_config_src = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/index.js");
|
|
5074
|
+
var postcss_load_config_src_default = compatGetDefaultExport(postcss_load_config_src);
|
|
5075
|
+
function getLightningCSSLoaderOptions(config, targets, minify) {
|
|
5026
5076
|
let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
|
|
5027
5077
|
targets,
|
|
5028
5078
|
errorRecovery: !0
|
|
@@ -5702,7 +5752,7 @@ async function getMetaTags(entryName, config, templateContent) {
|
|
|
5702
5752
|
return templateContent && metaTags.charset && /<meta\b(?:[^>"']|"[^"]*"|'[^']*')*?\scharset\s*=/i.test(templateContent) && delete metaTags.charset, metaTags;
|
|
5703
5753
|
}
|
|
5704
5754
|
function getTemplateParameters(entryName, config, assetPrefix) {
|
|
5705
|
-
return
|
|
5755
|
+
return (compilation, assets, assetTags, pluginOptions)=>{
|
|
5706
5756
|
let { mountId, templateParameters } = config.html, rspackConfig = compilation.options;
|
|
5707
5757
|
return reduceConfigsWithContext({
|
|
5708
5758
|
initial: {
|
|
@@ -5745,10 +5795,12 @@ function updateSourceMappingURL({ source, compilation, publicPath, type, config
|
|
|
5745
5795
|
}
|
|
5746
5796
|
function getMatchedAsset(name, assets, tests) {
|
|
5747
5797
|
let asset;
|
|
5748
|
-
|
|
5798
|
+
for (let test of tests)if (isFunction(test)) {
|
|
5799
|
+
if ((asset ??= assets[name]) && test({
|
|
5749
5800
|
name,
|
|
5750
5801
|
size: asset.size()
|
|
5751
|
-
})
|
|
5802
|
+
})) return asset;
|
|
5803
|
+
} else if (test.test(name)) return asset ?? assets[name];
|
|
5752
5804
|
}
|
|
5753
5805
|
function getInlineTests(config) {
|
|
5754
5806
|
let isProd = 'production' === config.mode, { inlineStyles, inlineScripts } = config.output, scriptTests = [], styleTests = [];
|
|
@@ -5846,18 +5898,22 @@ let getServerUrlFromClientConfig = async (config, context)=>{
|
|
|
5846
5898
|
let protocol = client.protocol ? `${'wss' === client.protocol ? 'https' : 'http'}:` : '', hostname = await getHostInUrl(client.host || devServer.hostname), port = client.port && '<port>' !== client.port ? client.port : devServer.port;
|
|
5847
5899
|
return `${protocol}//${hostname}:${port}`;
|
|
5848
5900
|
};
|
|
5849
|
-
function recursiveChunkGroup(chunkGroup, visited
|
|
5850
|
-
if (visited.has(chunkGroup)) return
|
|
5901
|
+
function recursiveChunkGroup(chunkGroup, visited, names) {
|
|
5902
|
+
if (visited.has(chunkGroup)) return;
|
|
5851
5903
|
visited.add(chunkGroup);
|
|
5852
5904
|
let parents = chunkGroup.getParents();
|
|
5853
|
-
|
|
5854
|
-
chunkGroup
|
|
5855
|
-
|
|
5905
|
+
if (!parents.length) {
|
|
5906
|
+
let { name } = chunkGroup;
|
|
5907
|
+
name && names.add(name);
|
|
5908
|
+
return;
|
|
5909
|
+
}
|
|
5910
|
+
for (let parent of parents)recursiveChunkGroup(parent, visited, names);
|
|
5856
5911
|
}
|
|
5857
5912
|
function recursiveChunkEntryNames(chunk) {
|
|
5858
|
-
let
|
|
5913
|
+
let names = new Set(), visited = new Set();
|
|
5914
|
+
for (let chunkGroup of chunk.groupsIterable)recursiveChunkGroup(chunkGroup, visited, names);
|
|
5859
5915
|
return [
|
|
5860
|
-
...
|
|
5916
|
+
...names
|
|
5861
5917
|
];
|
|
5862
5918
|
}
|
|
5863
5919
|
function isChunksFiltered(chunkName, includeChunks, excludeChunks) {
|
|
@@ -5867,7 +5923,7 @@ function doesChunkBelongToHtml({ chunk, htmlPluginData }) {
|
|
|
5867
5923
|
let { options } = htmlPluginData.plugin;
|
|
5868
5924
|
return recursiveChunkEntryNames(chunk).some((chunkName)=>isChunksFiltered(chunkName, options?.chunks, options?.excludeChunks));
|
|
5869
5925
|
}
|
|
5870
|
-
let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(rspackRequire
|
|
5926
|
+
let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(()=>rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/rspack-manifest-plugin/5.2.2/a5aff6a67a64dc2cd6fba2fe392c361454bba759c9980bb6bfe1a6686c72e73b/node_modules/rspack-manifest-plugin/dist/index.js"))), isCSSPath = (filePath)=>filePath.endsWith('.css');
|
|
5871
5927
|
function normalizeManifestObjectConfig(manifest) {
|
|
5872
5928
|
let defaultOptions = {
|
|
5873
5929
|
prefix: !0,
|
|
@@ -6012,6 +6068,7 @@ function generateLinks(options, type, compilation, data, HTMLCount, isDev) {
|
|
|
6012
6068
|
chunk.auxiliaryFiles ?? []
|
|
6013
6069
|
])for (let file of files)isDev && file.endsWith('.hot-update.js') || file.endsWith('.map') || uniqueFiles.add(file);
|
|
6014
6070
|
let sortedFilteredFiles = ((files, include, exclude)=>{
|
|
6071
|
+
if (!include && !exclude) return files;
|
|
6015
6072
|
let includeRegExp = [], excludeRegExp = [], includeFn = [], excludeFn = [];
|
|
6016
6073
|
if (include) for (let item of helpers_castArray(include))'string' == typeof item ? includeRegExp.push(new RegExp(item)) : isFunction(item) ? includeFn.push(item) : includeRegExp.push(item);
|
|
6017
6074
|
if (exclude) for (let item of helpers_castArray(exclude))'string' == typeof item ? excludeRegExp.push(new RegExp(item)) : isFunction(item) ? excludeFn.push(item) : excludeRegExp.push(item);
|
|
@@ -6498,7 +6555,7 @@ function getContentType(str) {
|
|
|
6498
6555
|
}
|
|
6499
6556
|
let BYTES_RANGE_REGEXP = /^ *bytes/i;
|
|
6500
6557
|
function getValueContentRangeHeader(type, size, range) {
|
|
6501
|
-
return `${type} ${range ? `${range.start}-${range.end}` : '*'}
|
|
6558
|
+
return `${type} ${range ? `${range.start}-${range.end}` : '*'}/${size}`;
|
|
6502
6559
|
}
|
|
6503
6560
|
function parseHttpDate(date) {
|
|
6504
6561
|
let timestamp = date && Date.parse(date);
|
|
@@ -6588,7 +6645,7 @@ function destroyStream(stream, suppress) {
|
|
|
6588
6645
|
'number' == typeof fd && this.close();
|
|
6589
6646
|
}), 'function' == typeof stream.addListener && suppress && (stream.removeAllListeners('error'), stream.addListener('error', ()=>{}));
|
|
6590
6647
|
}
|
|
6591
|
-
let getRangeParser = cachedImport_cachedImport(()=>import("./range-parser.js")
|
|
6648
|
+
let getRangeParser = cachedImport_cachedImport(()=>import("./range-parser.js"));
|
|
6592
6649
|
function sendError(res, code) {
|
|
6593
6650
|
let content = {
|
|
6594
6651
|
400: 'Bad Request',
|
|
@@ -6657,18 +6714,19 @@ function createAssetsMiddleware(context, { waitForAssets, waitForBuild }, output
|
|
|
6657
6714
|
return;
|
|
6658
6715
|
}
|
|
6659
6716
|
}
|
|
6660
|
-
if (rangeHeader) {
|
|
6661
|
-
let
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
combine: !0
|
|
6665
|
-
});
|
|
6666
|
-
})(`${size}|${rangeHeader}`);
|
|
6667
|
-
if (isRangeFresh(req.headers, res) || (parsedRanges = []), -1 === parsedRanges) {
|
|
6717
|
+
if (rangeHeader && isRangeFresh(req.headers, res)) {
|
|
6718
|
+
let { parse, combineRanges } = await getRangeParser(), { code, ranges } = parse(size, rangeHeader);
|
|
6719
|
+
if (1 === code || 3 === code) logger.error("[rsbuild:middleware] A malformed 'Range' header was provided. A regular response will be sent for this request.");
|
|
6720
|
+
else if (2 === code && 0 === ranges.length) {
|
|
6668
6721
|
logger.error("[rsbuild:middleware] Unsatisfiable range for 'Range' header."), res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size)), sendError(res, 416);
|
|
6669
6722
|
return;
|
|
6723
|
+
} else if (ranges.length > 0) {
|
|
6724
|
+
let combined = ranges.length > 1 ? combineRanges(ranges) : ranges;
|
|
6725
|
+
if (1 === combined.length) {
|
|
6726
|
+
let [range] = combined;
|
|
6727
|
+
res.statusCode = 206, res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size, range)), [offset, len] = getOffsetAndLenFromRange(range);
|
|
6728
|
+
} else logger.error("[rsbuild:middleware] A 'Range' header with multiple ranges was provided. Multiple ranges are not supported, so a regular response will be sent for this request.");
|
|
6670
6729
|
}
|
|
6671
|
-
-2 === parsedRanges ? logger.error("[rsbuild:middleware] A malformed 'Range' header was provided. A regular response will be sent for this request.") : parsedRanges.length > 1 && logger.error("[rsbuild:middleware] A 'Range' header with multiple ranges was provided. Multiple ranges are not supported, so a regular response will be sent for this request."), -2 !== parsedRanges && 1 === parsedRanges.length && (res.statusCode = 206, res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size, parsedRanges[0])), [offset, len] = getOffsetAndLenFromRange(parsedRanges[0]));
|
|
6672
6730
|
}
|
|
6673
6731
|
if ('HEAD' === req.method) {
|
|
6674
6732
|
res.setHeader('Content-Length', len), 404 === res.statusCode && (res.statusCode = 200), res.end();
|
|
@@ -6709,7 +6767,7 @@ function setupMemoryFileSystemCleanup(fileSystem, compilers) {
|
|
|
6709
6767
|
compilation.hash !== lastHash && (generation++, lastHash = compilation.hash);
|
|
6710
6768
|
let outputPath = compilation.getPath(compiler.outputPath);
|
|
6711
6769
|
for (let name of getAssetNames(compilation)){
|
|
6712
|
-
let queryIndex = name.indexOf('?'),
|
|
6770
|
+
let queryIndex = name.indexOf('?'), filename = -1 === queryIndex ? name : name.slice(0, queryIndex), filePath = join(outputPath, filename);
|
|
6713
6771
|
lastSeen.set(filePath, generation);
|
|
6714
6772
|
}
|
|
6715
6773
|
for (let [filePath, seen] of lastSeen)if (!(seen >= generation - 1) && (lastSeen.delete(filePath), !lastSeenByCompiler.some((assets)=>assets.has(filePath)))) try {
|
|
@@ -6982,12 +7040,12 @@ let closeCode = [
|
|
|
6982
7040
|
49
|
|
6983
7041
|
];
|
|
6984
7042
|
function ansiHTML(text) {
|
|
6985
|
-
let
|
|
7043
|
+
let openSpans = 0, ret = text.replace(/\x1B\[([0-9;]+)m/g, (_match, sequences)=>{
|
|
6986
7044
|
let style = '';
|
|
6987
7045
|
for (let seq of sequences.split(';'))styles[seq] && (style += `${styles[seq]};`);
|
|
6988
|
-
return style ? (
|
|
7046
|
+
return style ? (openSpans++, `<span style="${style}">`) : closeCode.includes(Number(sequences)) && openSpans > 0 ? (openSpans--, '</span>') : '';
|
|
6989
7047
|
});
|
|
6990
|
-
return
|
|
7048
|
+
return openSpans > 0 && (ret += '</span>'.repeat(openSpans)), ret;
|
|
6991
7049
|
}
|
|
6992
7050
|
function formatDisplayPath(filePath, isAbsolute, root) {
|
|
6993
7051
|
if (NODE_MODULES_REGEX.test(filePath)) for (let needle of [
|
|
@@ -7035,13 +7093,14 @@ class SocketServer {
|
|
|
7035
7093
|
currentHash = new Map();
|
|
7036
7094
|
environmentStats = new Map();
|
|
7037
7095
|
onSocketConnect;
|
|
7038
|
-
|
|
7039
|
-
|
|
7096
|
+
onSocketCustomMessage;
|
|
7097
|
+
constructor(context, options, getOutputFileSystem, onSocketConnect, onSocketCustomMessage){
|
|
7098
|
+
this.context = context, this.options = options, this.getOutputFileSystem = getOutputFileSystem, this.onSocketConnect = onSocketConnect, this.onSocketCustomMessage = onSocketCustomMessage;
|
|
7040
7099
|
}
|
|
7041
7100
|
upgrade = (req, socket, head)=>{
|
|
7042
7101
|
if (!this.wsServer.shouldHandle(req)) return;
|
|
7043
7102
|
let query = parseQueryString(req);
|
|
7044
|
-
this.context.environmentList.
|
|
7103
|
+
this.context.environmentList.some(({ webSocketToken })=>webSocketToken === query.token) ? this.wsServer.handleUpgrade(req, socket, head, (connection)=>{
|
|
7045
7104
|
this.wsServer.emit('connection', connection, req);
|
|
7046
7105
|
}) : socket.destroy();
|
|
7047
7106
|
};
|
|
@@ -7114,7 +7173,7 @@ class SocketServer {
|
|
|
7114
7173
|
} else for (let sockets of this.socketsMap.values())sendToSockets(sockets);
|
|
7115
7174
|
}
|
|
7116
7175
|
async close() {
|
|
7117
|
-
for (let socket of (this.clearHeartbeatTimer(), this.onSocketConnect = void 0, this.wsServer.removeAllListeners(), this.wsServer.clients))socket.terminate();
|
|
7176
|
+
for (let socket of (this.clearHeartbeatTimer(), this.onSocketConnect = void 0, this.onSocketCustomMessage = void 0, this.wsServer.removeAllListeners(), this.wsServer.clients))socket.terminate();
|
|
7118
7177
|
for (let sockets of this.socketsMap.values())sockets.forEach((socket)=>{
|
|
7119
7178
|
socket.close();
|
|
7120
7179
|
});
|
|
@@ -7133,6 +7192,10 @@ class SocketServer {
|
|
|
7133
7192
|
if (!context.normalizedConfig) return;
|
|
7134
7193
|
let environment = this.getEnvironmentByToken(token);
|
|
7135
7194
|
if (!environment) return;
|
|
7195
|
+
if ('custom' === payload.type) {
|
|
7196
|
+
'string' == typeof payload.event && this.onSocketCustomMessage?.(socket, token, payload.event, payload.data);
|
|
7197
|
+
return;
|
|
7198
|
+
}
|
|
7136
7199
|
let { browserLogs, client } = environment.config.dev;
|
|
7137
7200
|
if ('client-error' === payload.type && !context.buildState.hasErrors && browserLogs) {
|
|
7138
7201
|
let stackTrace = isObject(browserLogs) && browserLogs.stackTrace || DEFAULT_STACK_TRACE, outputFs = this.getOutputFileSystem(), stackFrames = payload.stack ? stack_trace_parser_esm_parse(payload.stack) : null, cache = {
|
|
@@ -7255,8 +7318,8 @@ class BuildManager {
|
|
|
7255
7318
|
config;
|
|
7256
7319
|
resolvedPort;
|
|
7257
7320
|
context;
|
|
7258
|
-
constructor({ config, context, compiler, resolvedPort, onSocketConnect }){
|
|
7259
|
-
this.config = config, this.context = context, this.compiler = compiler, this.resolvedPort = resolvedPort, this.outputFileSystem = node_fs, this.socketServer = new SocketServer(context, config.dev, ()=>this.outputFileSystem, onSocketConnect), this.context.socketServer = this.socketServer;
|
|
7321
|
+
constructor({ config, context, compiler, resolvedPort, onSocketConnect, onSocketCustomMessage }){
|
|
7322
|
+
this.config = config, this.context = context, this.compiler = compiler, this.resolvedPort = resolvedPort, this.outputFileSystem = node_fs, this.socketServer = new SocketServer(context, config.dev, ()=>this.outputFileSystem, onSocketConnect, onSocketCustomMessage), this.context.socketServer = this.socketServer;
|
|
7260
7323
|
}
|
|
7261
7324
|
async init() {
|
|
7262
7325
|
await this.setupCompilationMiddleware(), await this.socketServer.prepare();
|
|
@@ -7468,11 +7531,12 @@ function gzipMiddleware_gzipMiddleware({ filter, level = node_zlib.constants.Z_B
|
|
|
7468
7531
|
let start = ()=>{
|
|
7469
7532
|
if (started) return;
|
|
7470
7533
|
if (started = !0, ((res)=>{
|
|
7534
|
+
let index;
|
|
7471
7535
|
if (res.getHeader('Content-Encoding')) return !1;
|
|
7472
7536
|
let contentType = res.getHeader('Content-Type');
|
|
7473
7537
|
if (!contentType) return !1;
|
|
7474
7538
|
let contentTypeValue = String(contentType);
|
|
7475
|
-
if (!CONTENT_TYPE_REGEX.test(contentTypeValue) || 'text/event-stream' === contentTypeValue.
|
|
7539
|
+
if (!CONTENT_TYPE_REGEX.test(contentTypeValue) || 'text/event-stream' === (-1 === (index = contentTypeValue.indexOf(';')) ? contentTypeValue : contentTypeValue.slice(0, index)).trim().toLowerCase()) return !1;
|
|
7476
7540
|
let size = res.getHeader('Content-Length');
|
|
7477
7541
|
return void 0 === size || Number(size) > 1024;
|
|
7478
7542
|
})(res)) {
|
|
@@ -7585,7 +7649,7 @@ let faviconFallbackMiddleware = (req, res, next)=>{
|
|
|
7585
7649
|
return;
|
|
7586
7650
|
}
|
|
7587
7651
|
next();
|
|
7588
|
-
}, middlewares_isFileExists =
|
|
7652
|
+
}, middlewares_isFileExists = (filePath, outputFileSystem)=>new Promise((resolve)=>{
|
|
7589
7653
|
outputFileSystem.stat(filePath, (_error, stats)=>{
|
|
7590
7654
|
resolve(!!stats?.isFile());
|
|
7591
7655
|
});
|
|
@@ -7705,11 +7769,10 @@ let isModuleNamespaceObject = (moduleExports)=>'[object Module]' === Object.prot
|
|
|
7705
7769
|
let normalizedModuleExports = null !== moduleExports && ('object' == typeof moduleExports || 'function' == typeof moduleExports) ? moduleExports : {
|
|
7706
7770
|
default: moduleExports
|
|
7707
7771
|
}, exports = [
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
], syntheticModule = new SyntheticModule(exports, ()=>{
|
|
7772
|
+
'default'
|
|
7773
|
+
];
|
|
7774
|
+
for (let name of Object.keys(normalizedModuleExports))'default' !== name && exports.push(name);
|
|
7775
|
+
let syntheticModule = new SyntheticModule(exports, ()=>{
|
|
7713
7776
|
for (let name of exports)if ('default' === name) {
|
|
7714
7777
|
let defaultExport = isModuleNamespaceObject(normalizedModuleExports) && 'default' in normalizedModuleExports ? normalizedModuleExports.default : moduleExports;
|
|
7715
7778
|
syntheticModule.setExport(name, defaultExport);
|
|
@@ -7734,7 +7797,14 @@ class BasicRunner {
|
|
|
7734
7797
|
}
|
|
7735
7798
|
getRequire() {
|
|
7736
7799
|
let entryRequire = this.requirers.get('entry');
|
|
7737
|
-
return (currentDirectory, modulePath, context = {})=>
|
|
7800
|
+
return (currentDirectory, modulePath, context = {})=>{
|
|
7801
|
+
let p = modulePath;
|
|
7802
|
+
if ('string' == typeof modulePath) {
|
|
7803
|
+
let index = modulePath.indexOf('?');
|
|
7804
|
+
-1 !== index && (p = modulePath.slice(0, index));
|
|
7805
|
+
}
|
|
7806
|
+
return entryRequire(currentDirectory, p, context);
|
|
7807
|
+
};
|
|
7738
7808
|
}
|
|
7739
7809
|
getFile(modulePath, currentDirectory) {
|
|
7740
7810
|
if (Array.isArray(modulePath)) return {
|
|
@@ -8056,7 +8126,22 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8056
8126
|
let currentStats = stats[index];
|
|
8057
8127
|
return currentStats || waiters[index].promise;
|
|
8058
8128
|
}
|
|
8059
|
-
}), hotConnectCallbacks = new Map(),
|
|
8129
|
+
}), hotConnectCallbacks = new Map(), hotEventCallbacks = new Map(), hotClients = new WeakMap(), getHotClient = (socket)=>{
|
|
8130
|
+
let client = hotClients.get(socket);
|
|
8131
|
+
return client || (client = {
|
|
8132
|
+
send: createHotSend(socket)
|
|
8133
|
+
}, hotClients.set(socket, client)), client;
|
|
8134
|
+
}, runHotCallbacks = (callbacks, ...args)=>{
|
|
8135
|
+
for (let callback of [
|
|
8136
|
+
...callbacks
|
|
8137
|
+
])try {
|
|
8138
|
+
Promise.resolve(callback(...args)).catch((error)=>{
|
|
8139
|
+
logger.error(error);
|
|
8140
|
+
});
|
|
8141
|
+
} catch (error) {
|
|
8142
|
+
logger.error(error);
|
|
8143
|
+
}
|
|
8144
|
+
}, protocol = isHttps ? 'https' : 'http', urls = await getAddressUrls({
|
|
8060
8145
|
protocol,
|
|
8061
8146
|
port,
|
|
8062
8147
|
host
|
|
@@ -8080,7 +8165,7 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8080
8165
|
logger
|
|
8081
8166
|
}), state = {}, webSocketServers = new Set(), cleanupGracefulShutdown = middlewareMode ? null : setupGracefulShutdown(), closeServerResources = ()=>{
|
|
8082
8167
|
if (closingPromise) return closingPromise;
|
|
8083
|
-
hotConnectCallbacks = void 0;
|
|
8168
|
+
hotConnectCallbacks = void 0, hotEventCallbacks = void 0;
|
|
8084
8169
|
let onUpgrade = state.devMiddlewares?.onUpgrade;
|
|
8085
8170
|
if (onUpgrade && webSocketServers) for (let server of webSocketServers)server.removeListener('upgrade', onUpgrade);
|
|
8086
8171
|
return webSocketServers = void 0, unregisterRestart?.(), unregisterRestart = void 0, closingPromise = (async ()=>{
|
|
@@ -8137,6 +8222,16 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8137
8222
|
return callbacks || (callbacks = new Set(), hotConnectCallbacks.set(webSocketToken, callbacks)), callbacks.add(callback), ()=>{
|
|
8138
8223
|
hotConnectCallbacks?.get(webSocketToken)?.delete(callback);
|
|
8139
8224
|
};
|
|
8225
|
+
},
|
|
8226
|
+
on: (event, callback)=>{
|
|
8227
|
+
if (!runCompile) throw Error(getErrorMsg('hot.on'));
|
|
8228
|
+
if (!hotEventCallbacks) return ()=>{};
|
|
8229
|
+
let events = hotEventCallbacks.get(webSocketToken);
|
|
8230
|
+
events || (events = new Map(), hotEventCallbacks.set(webSocketToken, events));
|
|
8231
|
+
let callbacks = events.get(event);
|
|
8232
|
+
return callbacks || (callbacks = new Set(), events.set(event, callbacks)), callbacks.add(callback), ()=>{
|
|
8233
|
+
hotEventCallbacks?.get(webSocketToken)?.get(event)?.delete(callback);
|
|
8234
|
+
};
|
|
8140
8235
|
}
|
|
8141
8236
|
},
|
|
8142
8237
|
getStats: async ()=>{
|
|
@@ -8249,19 +8344,11 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8249
8344
|
resolvedPort: port,
|
|
8250
8345
|
onSocketConnect: (socket, token)=>{
|
|
8251
8346
|
let callbacks = hotConnectCallbacks?.get(token);
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
...callbacks
|
|
8258
|
-
])try {
|
|
8259
|
-
Promise.resolve(callback(client)).catch((error)=>{
|
|
8260
|
-
logger.error(error);
|
|
8261
|
-
});
|
|
8262
|
-
} catch (error) {
|
|
8263
|
-
logger.error(error);
|
|
8264
|
-
}
|
|
8347
|
+
callbacks?.size && runHotCallbacks(callbacks, getHotClient(socket));
|
|
8348
|
+
},
|
|
8349
|
+
onSocketCustomMessage: (socket, token, event, data)=>{
|
|
8350
|
+
let callbacks = hotEventCallbacks?.get(token)?.get(event);
|
|
8351
|
+
callbacks?.size && runHotCallbacks(callbacks, data, getHotClient(socket));
|
|
8265
8352
|
}
|
|
8266
8353
|
});
|
|
8267
8354
|
return await buildManager.init(), buildManager;
|
|
@@ -8573,7 +8660,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8573
8660
|
javascript: {
|
|
8574
8661
|
typeReexportsPresence: 'tolerant'
|
|
8575
8662
|
}
|
|
8576
|
-
}), isProd && chain.optimization.chunkIds('compact-hashed').moduleIds('compact-hashed'),
|
|
8663
|
+
}), isProd && chain.optimization.chunkIds('compact-hashed').moduleIds('compact-hashed'), config.dev.hmr && 'web' === target && (isDev || 'none' === config.mode && 'dev' === api.context.action) && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(rspack.HotModuleReplacementPlugin);
|
|
8577
8664
|
});
|
|
8578
8665
|
}
|
|
8579
8666
|
},
|
|
@@ -8608,11 +8695,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8608
8695
|
name: 'rsbuild:source-map',
|
|
8609
8696
|
setup (api) {
|
|
8610
8697
|
let normalizeExtractOptions = (extract = {})=>{
|
|
8611
|
-
let hasLegacyJs = 'js' in extract, hasFlatFields =
|
|
8612
|
-
'test',
|
|
8613
|
-
'include',
|
|
8614
|
-
'exclude'
|
|
8615
|
-
].some((key)=>void 0 !== extract[key]);
|
|
8698
|
+
let hasLegacyJs = 'js' in extract, hasFlatFields = void 0 !== extract.test || void 0 !== extract.include || void 0 !== extract.exclude;
|
|
8616
8699
|
if (!1 === extract.js) return !1;
|
|
8617
8700
|
if (hasLegacyJs && !hasFlatFields) {
|
|
8618
8701
|
var target;
|
|
@@ -8681,10 +8764,10 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8681
8764
|
...chain.get('experiments'),
|
|
8682
8765
|
newCache: !0
|
|
8683
8766
|
}), cacheEnabled = !0;
|
|
8684
|
-
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, environment, cacheConfig.buildDependencies),
|
|
8767
|
+
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, environment, cacheConfig.buildDependencies), useDigest = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length, cacheVersion = `rsbuild-2.3.4-${environment.name}-${env}`;
|
|
8685
8768
|
chain.cache({
|
|
8686
8769
|
type: 'persistent',
|
|
8687
|
-
version: cacheVersion,
|
|
8770
|
+
version: useDigest ? `${cacheVersion}-${await helpers_hash(JSON.stringify(cacheConfig.cacheDigest))}` : cacheVersion,
|
|
8688
8771
|
storage: {
|
|
8689
8772
|
type: 'filesystem',
|
|
8690
8773
|
directory: cacheDirectory
|
|
@@ -9697,10 +9780,8 @@ try {
|
|
|
9697
9780
|
bodyTags
|
|
9698
9781
|
};
|
|
9699
9782
|
}), api.modifyBundlerChain((chain, { CHAIN_ID, environment, isDev })=>{
|
|
9700
|
-
let { config, htmlPaths } = environment;
|
|
9701
|
-
if (0 === Object.keys(htmlPaths).length) return;
|
|
9702
|
-
let { performance: { preload, prefetch } } = config;
|
|
9703
|
-
if (!preload && !prefetch) return;
|
|
9783
|
+
let { config, htmlPaths } = environment, { performance: { preload, prefetch } } = config;
|
|
9784
|
+
if (!preload && !prefetch || 0 === Object.keys(htmlPaths).length) return;
|
|
9704
9785
|
let HTMLCount = chain.entryPoints.values().length, excludes = ((config)=>{
|
|
9705
9786
|
let { scriptTests, styleTests } = getInlineTests(config);
|
|
9706
9787
|
return [
|
|
@@ -9941,11 +10022,15 @@ try {
|
|
|
9941
10022
|
}), api.modifyHTMLTags({
|
|
9942
10023
|
order: 'post',
|
|
9943
10024
|
handler: ({ headTags, bodyTags }, { environment })=>{
|
|
9944
|
-
let { config } = environment, { nonce } = config.security
|
|
10025
|
+
let { config } = environment, { nonce } = config.security;
|
|
10026
|
+
if (!nonce) return {
|
|
10027
|
+
headTags,
|
|
10028
|
+
bodyTags
|
|
10029
|
+
};
|
|
10030
|
+
for (let tag of [
|
|
9945
10031
|
...headTags,
|
|
9946
10032
|
...bodyTags
|
|
9947
|
-
];
|
|
9948
|
-
if (nonce) for (let tag of allTags)isNonceTag(tag) && (tag.attrs ??= {}, tag.attrs.nonce = nonce);
|
|
10033
|
+
])isNonceTag(tag) && (tag.attrs ??= {}, tag.attrs.nonce = nonce);
|
|
9949
10034
|
return {
|
|
9950
10035
|
headTags,
|
|
9951
10036
|
bodyTags
|
|
@@ -10021,13 +10106,13 @@ async function createRsbuild(options = {}) {
|
|
|
10021
10106
|
let isFirstCompile = !0, { environmentList } = context;
|
|
10022
10107
|
onBeforeCompile({
|
|
10023
10108
|
compiler,
|
|
10024
|
-
beforeCompile:
|
|
10109
|
+
beforeCompile: ()=>context.hooks.onBeforeBuild.callBatch({
|
|
10025
10110
|
bundlerConfigs: rspackConfigs,
|
|
10026
10111
|
environments: context.environments,
|
|
10027
10112
|
isWatch,
|
|
10028
10113
|
isFirstCompile
|
|
10029
10114
|
}),
|
|
10030
|
-
beforeEnvironmentCompile:
|
|
10115
|
+
beforeEnvironmentCompile: (buildIndex)=>{
|
|
10031
10116
|
let environment = environmentList[buildIndex];
|
|
10032
10117
|
return context.hooks.onBeforeEnvironmentCompile.callBatch({
|
|
10033
10118
|
environment: environment.name,
|
|
@@ -10432,7 +10517,7 @@ let applyServerOptions = (command)=>{
|
|
|
10432
10517
|
};
|
|
10433
10518
|
function setupCommands(argv) {
|
|
10434
10519
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
10435
|
-
cli.version("2.3.
|
|
10520
|
+
cli.version("2.3.4"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
10436
10521
|
default: 'auto'
|
|
10437
10522
|
}).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
10438
10523
|
type: [
|
|
@@ -10497,7 +10582,7 @@ function setupCommands(argv) {
|
|
|
10497
10582
|
}
|
|
10498
10583
|
function showGreeting() {
|
|
10499
10584
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10500
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.3.
|
|
10585
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.3.4\n`);
|
|
10501
10586
|
}
|
|
10502
10587
|
function setupLogLevel(argv) {
|
|
10503
10588
|
if (argv.length <= 3) return;
|
|
@@ -10519,5 +10604,5 @@ function runCLI({ argv = process.argv } = {}) {
|
|
|
10519
10604
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10520
10605
|
}
|
|
10521
10606
|
}
|
|
10522
|
-
let src_version = "2.3.
|
|
10607
|
+
let src_version = "2.3.4";
|
|
10523
10608
|
export { core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
|