@rsbuild/core 2.1.5 → 2.1.6
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/@rstackjs/load-config/index.d.ts +66 -0
- package/compiled/@rstackjs/load-config/license +21 -0
- package/compiled/@rstackjs/load-config/package.json +1 -0
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.d.ts +4 -4
- package/compiled/html-rspack-plugin/index.js +53 -48
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/index.d.ts +7 -14
- package/compiled/rslog/package.json +1 -1
- package/dist/711.js +126 -218
- package/dist/manifest-plugin.js +37 -33
- package/dist/memfs.js +369 -201
- package/dist-types/loadConfig.d.ts +4 -39
- package/package.json +7 -6
- /package/dist/{fresh-import.js → freshImport.js} +0 -0
package/dist/711.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/*! LICENSE: 711.js.LICENSE.txt */
|
|
2
|
-
let
|
|
2
|
+
let runtimeProcessArgs, runtimeInfo, swcHelpersPath, pluginHelper_htmlPlugin;
|
|
3
3
|
import { rspack as core_rspack } from "@rspack/core";
|
|
4
4
|
import node_util, { stripVTControlCharacters } from "node:util";
|
|
5
|
-
import node_process from "node:process";
|
|
6
|
-
import node_os, { constants as external_node_os_constants } from "node:os";
|
|
7
|
-
import node_tty from "node:tty";
|
|
8
5
|
import node_path, { dirname as external_node_path_dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, resolve as external_node_path_resolve, sep, win32 } from "node:path";
|
|
9
6
|
import { builtinModules, createRequire, createRequire as __rspack_createRequire } from "node:module";
|
|
10
7
|
import node_fs, { existsSync } from "node:fs";
|
|
8
|
+
import node_os, { constants as external_node_os_constants } from "node:os";
|
|
9
|
+
import node_process from "node:process";
|
|
11
10
|
import { URL as external_node_url_URL, pathToFileURL, fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
12
11
|
import { isPromise, isRegExp } from "node:util/types";
|
|
13
12
|
import { readFile } from "node:fs/promises";
|
|
@@ -387,8 +386,8 @@ __webpack_require__.add({
|
|
|
387
386
|
return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
|
|
388
387
|
}
|
|
389
388
|
},
|
|
390
|
-
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
391
|
-
let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
389
|
+
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
390
|
+
let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/req.js");
|
|
392
391
|
async function processResult(ctx, result) {
|
|
393
392
|
let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
|
|
394
393
|
default: obj
|
|
@@ -461,8 +460,8 @@ __webpack_require__.add({
|
|
|
461
460
|
});
|
|
462
461
|
};
|
|
463
462
|
},
|
|
464
|
-
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
465
|
-
let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
463
|
+
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
464
|
+
let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/req.js");
|
|
466
465
|
module.exports = async function options(config, file) {
|
|
467
466
|
if (config.parser && 'string' == typeof config.parser) try {
|
|
468
467
|
config.parser = await req(config.parser, file);
|
|
@@ -482,8 +481,8 @@ __webpack_require__.add({
|
|
|
482
481
|
return config;
|
|
483
482
|
};
|
|
484
483
|
},
|
|
485
|
-
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
486
|
-
let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
484
|
+
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
485
|
+
let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/req.js");
|
|
487
486
|
async function load(plugin, options, file) {
|
|
488
487
|
try {
|
|
489
488
|
if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
|
|
@@ -499,7 +498,7 @@ __webpack_require__.add({
|
|
|
499
498
|
}), list;
|
|
500
499
|
};
|
|
501
500
|
},
|
|
502
|
-
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
501
|
+
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
503
502
|
let tsx, jiti, { createRequire } = __webpack_require__("node:module?1bcb"), { pathToFileURL } = __webpack_require__("node:url?b4ec"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
|
|
504
503
|
module.exports = async function req(name, rootFile = __rspack_import_meta_filename__) {
|
|
505
504
|
let url = createRequire(rootFile).resolve(name);
|
|
@@ -625,135 +624,33 @@ let createStyler = (style)=>(text)=>node_util.styleText(style, String(text)), co
|
|
|
625
624
|
magenta: createStyler('magenta'),
|
|
626
625
|
underline: createStyler('underline'),
|
|
627
626
|
strikethrough: createStyler('strikethrough')
|
|
628
|
-
}
|
|
629
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
630
|
-
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
631
|
-
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
632
|
-
}
|
|
633
|
-
let { env: dist_env } = node_process;
|
|
634
|
-
function envForceColor() {
|
|
635
|
-
if (!('FORCE_COLOR' in dist_env)) return;
|
|
636
|
-
if ('true' === dist_env.FORCE_COLOR) return 1;
|
|
637
|
-
if ('false' === dist_env.FORCE_COLOR) return 0;
|
|
638
|
-
if (0 === dist_env.FORCE_COLOR.length) return 1;
|
|
639
|
-
let level = Math.min(Number.parseInt(dist_env.FORCE_COLOR, 10), 3);
|
|
640
|
-
if ([
|
|
641
|
-
0,
|
|
642
|
-
1,
|
|
643
|
-
2,
|
|
644
|
-
3
|
|
645
|
-
].includes(level)) return level;
|
|
646
|
-
}
|
|
647
|
-
function translateLevel(level) {
|
|
648
|
-
return 0 !== level && {
|
|
649
|
-
level,
|
|
650
|
-
hasBasic: !0,
|
|
651
|
-
has256: level >= 2,
|
|
652
|
-
has16m: level >= 3
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = !0 } = {}) {
|
|
656
|
-
let noFlagForceColor = envForceColor();
|
|
657
|
-
void 0 !== noFlagForceColor && (flagForceColor = noFlagForceColor);
|
|
658
|
-
let forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
659
|
-
if (0 === forceColor) return 0;
|
|
660
|
-
if (sniffFlags) {
|
|
661
|
-
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
|
|
662
|
-
if (hasFlag('color=256')) return 2;
|
|
663
|
-
}
|
|
664
|
-
if ('TF_BUILD' in dist_env && 'AGENT_NAME' in dist_env) return 1;
|
|
665
|
-
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
666
|
-
let min = forceColor || 0;
|
|
667
|
-
if ('dumb' === dist_env.TERM) return min;
|
|
668
|
-
if ('win32' === node_process.platform) {
|
|
669
|
-
let osRelease = node_os.release().split('.');
|
|
670
|
-
return Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ? Number(osRelease[2]) >= 14931 ? 3 : 2 : 1;
|
|
671
|
-
}
|
|
672
|
-
if ('CI' in dist_env) return [
|
|
673
|
-
'GITHUB_ACTIONS',
|
|
674
|
-
'GITEA_ACTIONS',
|
|
675
|
-
'CIRCLECI'
|
|
676
|
-
].some((key)=>key in dist_env) ? 3 : [
|
|
677
|
-
'TRAVIS',
|
|
678
|
-
'APPVEYOR',
|
|
679
|
-
'GITLAB_CI',
|
|
680
|
-
'BUILDKITE',
|
|
681
|
-
'DRONE'
|
|
682
|
-
].some((sign)=>sign in dist_env) || 'codeship' === dist_env.CI_NAME ? 1 : min;
|
|
683
|
-
if ('TEAMCITY_VERSION' in dist_env) return +!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(dist_env.TEAMCITY_VERSION);
|
|
684
|
-
if ('truecolor' === dist_env.COLORTERM || 'xterm-kitty' === dist_env.TERM || 'xterm-ghostty' === dist_env.TERM || 'wezterm' === dist_env.TERM) return 3;
|
|
685
|
-
if ('TERM_PROGRAM' in dist_env) {
|
|
686
|
-
let version = Number.parseInt((dist_env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
687
|
-
switch(dist_env.TERM_PROGRAM){
|
|
688
|
-
case 'iTerm.app':
|
|
689
|
-
return version >= 3 ? 3 : 2;
|
|
690
|
-
case 'Apple_Terminal':
|
|
691
|
-
return 2;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
return /-256(color)?$/i.test(dist_env.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(dist_env.TERM) || 'COLORTERM' in dist_env ? 1 : min;
|
|
695
|
-
}
|
|
696
|
-
function createSupportsColor(stream, options = {}) {
|
|
697
|
-
return translateLevel(_supportsColor(stream, {
|
|
698
|
-
streamIsTTY: stream && stream.isTTY,
|
|
699
|
-
...options
|
|
700
|
-
}));
|
|
701
|
-
}
|
|
702
|
-
hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never') ? flagForceColor = 0 : (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) && (flagForceColor = 1);
|
|
703
|
-
let supportsColor = {
|
|
704
|
-
stdout: createSupportsColor({
|
|
705
|
-
isTTY: node_tty.isatty(1)
|
|
706
|
-
}),
|
|
707
|
-
stderr: createSupportsColor({
|
|
708
|
-
isTTY: node_tty.isatty(2)
|
|
709
|
-
})
|
|
710
|
-
}, colorLevel = supportsColor.stdout ? supportsColor.stdout.level : 0, errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/, anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/, indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/, isWord = (char)=>!/[\s\n]/.test(char), LOG_LEVEL = {
|
|
627
|
+
}, supportsTrueColor = !0 === process.stdout.isTTY && process.stdout.hasColors(16777216, process.env), LOG_LEVEL = {
|
|
711
628
|
silent: -1,
|
|
712
629
|
error: 0,
|
|
713
630
|
warn: 1,
|
|
714
631
|
info: 2,
|
|
715
632
|
log: 2,
|
|
716
633
|
verbose: 3
|
|
634
|
+
}, createLogType = (label, level, style)=>{
|
|
635
|
+
let formattedLabel;
|
|
636
|
+
return {
|
|
637
|
+
get label () {
|
|
638
|
+
return formattedLabel ??= color.bold(style(label.padEnd(7)));
|
|
639
|
+
},
|
|
640
|
+
level
|
|
641
|
+
};
|
|
717
642
|
}, LOG_TYPES = {
|
|
718
|
-
error:
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
label: 'warn',
|
|
725
|
-
level: 'warn',
|
|
726
|
-
color: color.yellow
|
|
727
|
-
},
|
|
728
|
-
info: {
|
|
729
|
-
label: 'info',
|
|
730
|
-
level: 'info',
|
|
731
|
-
color: color.cyan
|
|
732
|
-
},
|
|
733
|
-
start: {
|
|
734
|
-
label: 'start',
|
|
735
|
-
level: 'info',
|
|
736
|
-
color: color.cyan
|
|
737
|
-
},
|
|
738
|
-
ready: {
|
|
739
|
-
label: 'ready',
|
|
740
|
-
level: 'info',
|
|
741
|
-
color: color.green
|
|
742
|
-
},
|
|
743
|
-
success: {
|
|
744
|
-
label: 'success',
|
|
745
|
-
level: 'info',
|
|
746
|
-
color: color.green
|
|
747
|
-
},
|
|
643
|
+
error: createLogType('error', 'error', color.red),
|
|
644
|
+
warn: createLogType('warn', 'warn', color.yellow),
|
|
645
|
+
info: createLogType('info', 'info', color.cyan),
|
|
646
|
+
start: createLogType('start', 'info', color.cyan),
|
|
647
|
+
ready: createLogType('ready', 'info', color.green),
|
|
648
|
+
success: createLogType('success', 'info', color.green),
|
|
748
649
|
log: {
|
|
749
650
|
level: 'info'
|
|
750
651
|
},
|
|
751
|
-
debug:
|
|
752
|
-
|
|
753
|
-
level: 'verbose',
|
|
754
|
-
color: color.magenta
|
|
755
|
-
}
|
|
756
|
-
}, normalizeErrorMessage = (err)=>{
|
|
652
|
+
debug: createLogType('debug', 'verbose', color.magenta)
|
|
653
|
+
}, errorStackRegExp = /at [^\r\n]{0,200}(?::\d+:\d+[\s)]*|\(<anonymous>\)|\(index\s\d+\))$/, normalizeErrorMessage = (err)=>{
|
|
757
654
|
if (err.stack) {
|
|
758
655
|
let [rawName, ...rest] = err.stack.split('\n'), name = rawName.startsWith('Error: ') ? rawName.slice(7) : rawName;
|
|
759
656
|
return `${name}\n${color.gray(rest.join('\n'))}`;
|
|
@@ -764,22 +661,15 @@ let supportsColor = {
|
|
|
764
661
|
let logType = LOG_TYPES[type], { level } = logType;
|
|
765
662
|
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
766
663
|
if (null == message) return console1.log();
|
|
767
|
-
let label = '', text = '';
|
|
768
|
-
if (
|
|
664
|
+
let label = 'label' in logType ? logType.label : '', text = '';
|
|
665
|
+
if (message instanceof Error) {
|
|
769
666
|
text += normalizeErrorMessage(message);
|
|
770
667
|
let { cause } = message;
|
|
771
668
|
cause && (text += color.yellow('\n [cause]: '), text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause));
|
|
772
|
-
} else text = 'error' === level && 'string' == typeof message ? message.split('\n').map((line)=>errorStackRegExp.test(line)
|
|
773
|
-
prefix && (text = `${prefix} ${text}`), console1['error' === level || 'warn' === level ? level : 'log'](label
|
|
669
|
+
} else text = 'error' === level && 'string' == typeof message ? message.split('\n').map((line)=>errorStackRegExp.test(line) ? color.gray(line) : line).join('\n') : `${message}`;
|
|
670
|
+
prefix && (text = `${prefix} ${text}`), console1['error' === level || 'warn' === level ? level : 'log'](label ? `${label} ${text}` : text, ...args);
|
|
774
671
|
}, logger = {
|
|
775
|
-
greet: (message)=>log('log', ((message)
|
|
776
|
-
if (colorLevel < 3) return 2 === colorLevel ? color.cyan(message) : message;
|
|
777
|
-
let chars = [
|
|
778
|
-
...message
|
|
779
|
-
], steps = chars.filter(isWord).length, r = 189, g = 255, b = 243, rStep = -115 / steps, gStep = -61 / steps, bStep = -89 / steps, output = '';
|
|
780
|
-
for (let char of chars)isWord(char) && (r += rStep, g += gStep, b += bStep), output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
781
|
-
return color.bold(output);
|
|
782
|
-
})(message))
|
|
672
|
+
greet: (message)=>log('log', supportsTrueColor ? `\x1b[1;38;2;132;225;199m${message}\x1b[39;22m` : color.bold(color.cyan(message)))
|
|
783
673
|
};
|
|
784
674
|
return Object.keys(LOG_TYPES).forEach((key)=>{
|
|
785
675
|
logger[key] = (...args)=>log(key, ...args);
|
|
@@ -3509,7 +3399,7 @@ function createPublicContext(context) {
|
|
|
3509
3399
|
async function createContext(options, userConfig, logger) {
|
|
3510
3400
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
3511
3401
|
return {
|
|
3512
|
-
version: "2.1.
|
|
3402
|
+
version: "2.1.6",
|
|
3513
3403
|
rootPath,
|
|
3514
3404
|
distPath: '',
|
|
3515
3405
|
cachePath,
|
|
@@ -4953,7 +4843,7 @@ function parseMinifyOptions(config) {
|
|
|
4953
4843
|
cssOptions: minify.cssOptions
|
|
4954
4844
|
};
|
|
4955
4845
|
}
|
|
4956
|
-
let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.
|
|
4846
|
+
let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.17/node_modules/postcss-load-config/src/index.js");
|
|
4957
4847
|
var postcss_load_config_src_default = __webpack_require__.n(postcss_load_config_src);
|
|
4958
4848
|
async function getLightningCSSLoaderOptions(config, targets, minify) {
|
|
4959
4849
|
let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
|
|
@@ -6727,7 +6617,7 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6727
6617
|
}
|
|
6728
6618
|
async function setupOutputFileSystem(writeToDisk, compilers) {
|
|
6729
6619
|
if (!0 !== writeToDisk) {
|
|
6730
|
-
let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.
|
|
6620
|
+
let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.64.0/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
|
|
6731
6621
|
for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
|
|
6732
6622
|
}
|
|
6733
6623
|
let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
|
|
@@ -8009,14 +7899,15 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
8009
7899
|
});
|
|
8010
7900
|
}, createCacheableFunction = (getter)=>{
|
|
8011
7901
|
let cache = new WeakMap();
|
|
8012
|
-
return
|
|
7902
|
+
return (stats, entryName, utils)=>{
|
|
8013
7903
|
let cachedEntries = cache.get(stats);
|
|
8014
|
-
|
|
8015
|
-
let
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
})
|
|
7904
|
+
cachedEntries || (cachedEntries = new Map(), cache.set(stats, cachedEntries));
|
|
7905
|
+
let cachedPromise = cachedEntries.get(entryName);
|
|
7906
|
+
if (cachedPromise) return cachedPromise;
|
|
7907
|
+
let promise = Promise.resolve().then(()=>getter(stats, entryName, utils)).catch((error)=>{
|
|
7908
|
+
throw cachedEntries.delete(entryName), error;
|
|
7909
|
+
});
|
|
7910
|
+
return cachedEntries.set(entryName, promise), promise;
|
|
8020
7911
|
};
|
|
8021
7912
|
}, cleanupCallbacks = new Set(), handleTermination = async (exitCode)=>{
|
|
8022
7913
|
try {
|
|
@@ -9527,7 +9418,7 @@ try {
|
|
|
9527
9418
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
9528
9419
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
9529
9420
|
if (!1 === manifest) return;
|
|
9530
|
-
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.1.
|
|
9421
|
+
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.1.4/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
|
|
9531
9422
|
manifestFilenames.set(environment.name, manifestOptions.filename);
|
|
9532
9423
|
let pluginOptions = {
|
|
9533
9424
|
fileName: manifestOptions.filename,
|
|
@@ -9881,61 +9772,59 @@ async function createRsbuild(options = {}) {
|
|
|
9881
9772
|
});
|
|
9882
9773
|
})), rsbuild;
|
|
9883
9774
|
}
|
|
9884
|
-
function
|
|
9885
|
-
return config;
|
|
9886
|
-
}
|
|
9887
|
-
let DEFAULT_CONFIG_FILE_NAMES = [
|
|
9888
|
-
'rsbuild.config.ts',
|
|
9889
|
-
'rsbuild.config.js',
|
|
9890
|
-
'rsbuild.config.mts',
|
|
9891
|
-
'rsbuild.config.mjs',
|
|
9892
|
-
'rsbuild.config.cts',
|
|
9893
|
-
'rsbuild.config.cjs'
|
|
9894
|
-
], canReadExport = (module)=>null !== module && ('object' == typeof module || 'function' == typeof module), getConfigExport = (configModule, exportName, configFilePath)=>{
|
|
9775
|
+
let canReadExport = (module)=>null !== module && ('object' == typeof module || 'function' == typeof module), getConfigExport = (configModule, exportName, configPath)=>{
|
|
9895
9776
|
if (!1 === exportName) return {};
|
|
9896
9777
|
if ('default' === exportName) return canReadExport(configModule) && 'default' in configModule ? configModule.default : configModule;
|
|
9897
9778
|
if (canReadExport(configModule) && Object.hasOwn(configModule, exportName)) return configModule[exportName];
|
|
9898
|
-
throw Error(`Cannot find export ${
|
|
9899
|
-
},
|
|
9779
|
+
throw Error(`Cannot find export ${exportName} in config file: ${configPath}`);
|
|
9780
|
+
}, loadWithJiti = async (configPath, exportName, fresh)=>{
|
|
9781
|
+
let createJiti;
|
|
9900
9782
|
try {
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9783
|
+
({ createJiti } = await import("../compiled/jiti/lib/jiti.mjs"));
|
|
9784
|
+
} catch (error) {
|
|
9785
|
+
throw Error('The "jiti" package is required to load this config. Install it with your package manager.', {
|
|
9786
|
+
cause: error
|
|
9787
|
+
});
|
|
9905
9788
|
}
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
return freshImportResult ? {
|
|
9909
|
-
configModule: freshImportResult.result,
|
|
9910
|
-
dependencies: freshImportResult.dependencies.sort()
|
|
9911
|
-
} : {
|
|
9912
|
-
configModule: await import(`${configFileURL}?t=${Date.now()}`),
|
|
9913
|
-
dependencies: []
|
|
9914
|
-
};
|
|
9915
|
-
}, loadConfigWithJiti = async (configFilePath, exportName)=>{
|
|
9916
|
-
let { createJiti } = await import("../compiled/jiti/lib/jiti.mjs"), jiti = createJiti(import.meta.filename, {
|
|
9917
|
-
moduleCache: !1,
|
|
9789
|
+
let jiti = createJiti(configPath, {
|
|
9790
|
+
moduleCache: !fresh,
|
|
9918
9791
|
interopDefault: !0,
|
|
9919
9792
|
nativeModules: [
|
|
9920
9793
|
"typescript"
|
|
9921
9794
|
]
|
|
9922
9795
|
});
|
|
9923
9796
|
return 'default' === exportName ? {
|
|
9924
|
-
configExport: await jiti.import(
|
|
9797
|
+
configExport: await jiti.import(configPath, {
|
|
9925
9798
|
default: !0
|
|
9926
9799
|
}),
|
|
9927
9800
|
dependencies: []
|
|
9928
9801
|
} : {
|
|
9929
|
-
configExport: getConfigExport(await jiti.import(
|
|
9802
|
+
configExport: getConfigExport(await jiti.import(configPath), exportName, configPath),
|
|
9803
|
+
dependencies: []
|
|
9804
|
+
};
|
|
9805
|
+
}, JS_CONFIG_REGEXP = /\.(?:js|mjs|cjs)$/, loadWithNative = async (configPath, fresh)=>{
|
|
9806
|
+
let configFileURL = pathToFileURL(configPath).href;
|
|
9807
|
+
if (!fresh) return {
|
|
9808
|
+
configModule: await import(configFileURL),
|
|
9809
|
+
dependencies: []
|
|
9810
|
+
};
|
|
9811
|
+
let { freshImport } = await import("./freshImport.js"), freshImportResult = await freshImport(configFileURL);
|
|
9812
|
+
return freshImportResult ? {
|
|
9813
|
+
configModule: freshImportResult.result,
|
|
9814
|
+
dependencies: freshImportResult.dependencies.sort()
|
|
9815
|
+
} : {
|
|
9816
|
+
configModule: await import(`${configFileURL}?t=${Date.now()}`),
|
|
9930
9817
|
dependencies: []
|
|
9931
9818
|
};
|
|
9932
9819
|
};
|
|
9933
|
-
async function
|
|
9934
|
-
let loadedConfig
|
|
9820
|
+
async function dist_loadConfig({ cwd = process.cwd(), path, configFileNames = [], loader = 'auto', exportName = 'default', configParams = [], fresh = !1 } = {}) {
|
|
9821
|
+
let loadedConfig;
|
|
9822
|
+
if (!path && 0 === configFileNames.length) throw Error('Either `path` or at least one `configFileNames` entry must be provided.');
|
|
9823
|
+
let configPath = ((root, customConfig, configFileNames = [])=>{
|
|
9935
9824
|
if (customConfig) {
|
|
9936
9825
|
let customConfigPath = external_node_path_isAbsolute(customConfig) ? customConfig : join(root, customConfig);
|
|
9937
9826
|
if (node_fs.existsSync(customConfigPath)) return customConfigPath;
|
|
9938
|
-
throw Error(`Cannot find config file: ${
|
|
9827
|
+
throw Error(`Cannot find config file: ${customConfigPath}`);
|
|
9939
9828
|
}
|
|
9940
9829
|
for (let file of configFileNames){
|
|
9941
9830
|
let configFile = join(root, file);
|
|
@@ -9943,55 +9832,74 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, configFileName
|
|
|
9943
9832
|
}
|
|
9944
9833
|
return null;
|
|
9945
9834
|
})(cwd, path, configFileNames);
|
|
9946
|
-
if (!
|
|
9835
|
+
if (!configPath) return {
|
|
9947
9836
|
content: {},
|
|
9948
|
-
filePath:
|
|
9837
|
+
filePath: configPath,
|
|
9949
9838
|
dependencies: []
|
|
9950
9839
|
};
|
|
9951
|
-
|
|
9952
|
-
configFilePath
|
|
9953
|
-
}, config);
|
|
9954
|
-
if ('native' === loader || 'auto' === loader && (process.features.typescript || process.versions.bun || process.versions.deno) || /\.(?:js|mjs|cjs)$/.test(configFilePath)) {
|
|
9840
|
+
if ('native' === loader || 'auto' === loader && (process.features.typescript || process.versions.bun || process.versions.deno) || JS_CONFIG_REGEXP.test(configPath)) {
|
|
9955
9841
|
let result;
|
|
9956
9842
|
try {
|
|
9957
|
-
result = await
|
|
9843
|
+
result = await loadWithNative(configPath, fresh);
|
|
9958
9844
|
} catch (err) {
|
|
9959
|
-
|
|
9960
|
-
if ('native' === loader) throw src_logger.error(errorMessage), err;
|
|
9961
|
-
src_logger.debug(`${errorMessage}, fallback to jiti.`), src_logger.debug(err);
|
|
9845
|
+
if ('native' === loader) throw err;
|
|
9962
9846
|
}
|
|
9963
9847
|
result && (loadedConfig = {
|
|
9964
|
-
configExport: getConfigExport(result.configModule, exportName,
|
|
9848
|
+
configExport: getConfigExport(result.configModule, exportName, configPath),
|
|
9965
9849
|
dependencies: result.dependencies
|
|
9966
9850
|
});
|
|
9967
9851
|
}
|
|
9968
|
-
|
|
9969
|
-
loadedConfig = await loadConfigWithJiti(configFilePath, exportName);
|
|
9970
|
-
} catch (err) {
|
|
9971
|
-
throw src_logger.error(`Failed to load file with jiti: ${color.dim(configFilePath)}`), err;
|
|
9972
|
-
}
|
|
9852
|
+
loadedConfig || (loadedConfig = await loadWithJiti(configPath, exportName, fresh));
|
|
9973
9853
|
let { configExport, dependencies } = loadedConfig;
|
|
9974
9854
|
if ('function' == typeof configExport) {
|
|
9975
|
-
let
|
|
9976
|
-
env: nodeEnv,
|
|
9977
|
-
command: command ?? process.argv[2],
|
|
9978
|
-
envMode: envMode || nodeEnv,
|
|
9979
|
-
meta
|
|
9980
|
-
}, result = await configExport(configParams);
|
|
9855
|
+
let result = await configExport(...configParams);
|
|
9981
9856
|
if (void 0 === result) throw Error('The config function must return a config object.');
|
|
9982
9857
|
return {
|
|
9983
|
-
content:
|
|
9984
|
-
filePath:
|
|
9858
|
+
content: result,
|
|
9859
|
+
filePath: configPath,
|
|
9985
9860
|
dependencies
|
|
9986
9861
|
};
|
|
9987
9862
|
}
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
filePath: configFilePath,
|
|
9863
|
+
return {
|
|
9864
|
+
content: configExport,
|
|
9865
|
+
filePath: configPath,
|
|
9992
9866
|
dependencies
|
|
9993
9867
|
};
|
|
9994
9868
|
}
|
|
9869
|
+
function defineConfig(config) {
|
|
9870
|
+
return config;
|
|
9871
|
+
}
|
|
9872
|
+
let DEFAULT_CONFIG_FILE_NAMES = [
|
|
9873
|
+
'rsbuild.config.ts',
|
|
9874
|
+
'rsbuild.config.js',
|
|
9875
|
+
'rsbuild.config.mts',
|
|
9876
|
+
'rsbuild.config.mjs',
|
|
9877
|
+
'rsbuild.config.cts',
|
|
9878
|
+
'rsbuild.config.cjs'
|
|
9879
|
+
];
|
|
9880
|
+
async function loadConfig_loadConfig({ cwd = process.cwd(), path, configFileNames = DEFAULT_CONFIG_FILE_NAMES, envMode, meta, loader = 'auto', command, exportName = 'default' } = {}) {
|
|
9881
|
+
let nodeEnv = process.env.NODE_ENV || '', configParams = {
|
|
9882
|
+
env: nodeEnv,
|
|
9883
|
+
command: command ?? process.argv[2],
|
|
9884
|
+
envMode: envMode || nodeEnv,
|
|
9885
|
+
meta
|
|
9886
|
+
}, result = await dist_loadConfig({
|
|
9887
|
+
cwd,
|
|
9888
|
+
path,
|
|
9889
|
+
configFileNames,
|
|
9890
|
+
loader,
|
|
9891
|
+
exportName,
|
|
9892
|
+
configParams: [
|
|
9893
|
+
configParams
|
|
9894
|
+
],
|
|
9895
|
+
fresh: !0
|
|
9896
|
+
});
|
|
9897
|
+
if (!result.filePath) return src_logger.debug('no config file found.'), result;
|
|
9898
|
+
if (!isObject(result.content)) throw Error(`The config must be an object or a function that returns an object, get ${color.yellow(String(result.content))}`);
|
|
9899
|
+
return result.content._privateMeta = {
|
|
9900
|
+
configFilePath: result.filePath
|
|
9901
|
+
}, src_logger.debug('configuration loaded from:', result.filePath), result;
|
|
9902
|
+
}
|
|
9995
9903
|
let cliState = {
|
|
9996
9904
|
options: {}
|
|
9997
9905
|
}, initCliAction = (command, options)=>{
|
|
@@ -10124,7 +10032,7 @@ let applyServerOptions = (command)=>{
|
|
|
10124
10032
|
};
|
|
10125
10033
|
function setupCommands(argv) {
|
|
10126
10034
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
10127
|
-
cli.version("2.1.
|
|
10035
|
+
cli.version("2.1.6"), 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)', {
|
|
10128
10036
|
default: 'auto'
|
|
10129
10037
|
}).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', {
|
|
10130
10038
|
type: [
|
|
@@ -10188,7 +10096,7 @@ function setupCommands(argv) {
|
|
|
10188
10096
|
}
|
|
10189
10097
|
function showGreeting() {
|
|
10190
10098
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10191
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.1.
|
|
10099
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.1.6\n`);
|
|
10192
10100
|
}
|
|
10193
10101
|
function setupLogLevel(argv) {
|
|
10194
10102
|
if (argv.length <= 3) return;
|
|
@@ -10210,5 +10118,5 @@ function runCLI({ argv = process.argv } = {}) {
|
|
|
10210
10118
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10211
10119
|
}
|
|
10212
10120
|
}
|
|
10213
|
-
let src_version = "2.1.
|
|
10121
|
+
let src_version = "2.1.6";
|
|
10214
10122
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, 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 };
|