@rsbuild/core 2.2.11 → 2.2.13
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.d.ts +16 -2
- package/compiled/html-rspack-plugin/index.js +78 -28
- package/compiled/jiti/lib/jiti-cli.mjs +0 -0
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/ws/index.d.ts +4 -0
- package/compiled/ws/package.json +1 -1
- package/dist/cssUrlLoader.mjs +15 -5
- package/dist/launch-editor-middleware.js +1 -1
- package/dist/loader/cssUrlLoader.d.ts +1 -0
- package/dist/m.js +324 -179
- package/dist/manifest-plugin.js +1 -1
- package/dist/memfs.js +1 -1
- package/dist/plugins/fileSize.d.ts +11 -0
- package/dist/server/assets-middleware/getFileFromUrl.d.ts +1 -0
- package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +1 -2
- package/dist/server/assets-middleware/setupWriteToDisk.d.ts +10 -13
- package/dist/server/hostCheck.d.ts +7 -0
- package/dist/types/config.d.ts +8 -1
- package/dist/types/plugin.d.ts +1 -0
- package/package.json +13 -9
package/dist/m.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
let runtimeProcessArgs, runtimeInfo, swcHelpersPath, pluginHelper_htmlPlugin;
|
|
3
3
|
import { rspackRequire, moduleFactories, compatGetDefaultExport, createFakeNamespaceObject } from "./rslib-runtime.js";
|
|
4
4
|
import { rspack as core_rspack } from "@rspack/core";
|
|
5
|
-
import node_util, { promisify, stripVTControlCharacters } from "node:util";
|
|
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
7
|
import { builtinModules, createRequire, createRequire as __rspack_createRequire } from "node:module";
|
|
8
8
|
import node_fs, { existsSync } from "node:fs";
|
|
@@ -12,7 +12,8 @@ import { URL as external_node_url_URL, pathToFileURL, fileURLToPath as __rspack_
|
|
|
12
12
|
import { isPromise, isRegExp } from "node:util/types";
|
|
13
13
|
import { readFile } from "node:fs/promises";
|
|
14
14
|
import node_zlib, { constants as external_node_zlib_constants } from "node:zlib";
|
|
15
|
-
import { once } from "node:events";
|
|
15
|
+
import { once as external_node_events_once } from "node:events";
|
|
16
|
+
import { isIP } from "node:net";
|
|
16
17
|
import { ALL_INTERFACES_IPV4, IMAGE_EXTENSIONS, ASSETS_DIST_DIR, FONT_DIST_DIR, AUDIO_EXTENSIONS, ensureAbsolutePath, NODE_MODULES_REGEX, FONT_EXTENSIONS, HMR_SOCKET_PATH, WASM_DIST_DIR, VIDEO_EXTENSIONS, BROWSER_LOG_PREFIX, toPosixPath, TRACK_EXTENSIONS, IMAGE_DIST_DIR, RSBUILD_OUTPUTS_PATH, DEFAULT_STACK_TRACE, LOADER_PATH, ASSET_EXTENSIONS, SVG_DIST_DIR, isWindows, COMPILED_PATH, WORKER_QUERY_REGEX, TS_CONFIG_FILE, dedupeNestedPaths, CSS_REGEX, relativeWithin, LAZY_COMPILATION_IDENTIFIER, DEFAULT_BROWSERSLIST, JS_REGEX, MEDIA_DIST_DIR, SCRIPT_REGEX, DEFAULT_WEB_BROWSERSLIST, getCompiledPath, normalizeRuleConditionPath, getPathnameFromUrl, toRelativePath, isDeno, CSS_DIST_DIR, INLINE_QUERY_REGEX, STATIC_PATH, RAW_QUERY_REGEX, PLUGIN_SWC_NAME, CLIENT_PATH, getCommonParentPath, LOCALHOST, JS_DIST_DIR, URL_QUERY_REGEX } from "./1.js";
|
|
17
18
|
import { cachedImport as cachedImport_cachedImport, getTinyglobby } from "./r.js";
|
|
18
19
|
var superClass, superClass1, __rspack_import_meta_filename__ = __rspack_fileURLToPath(import.meta.url);
|
|
@@ -389,8 +390,8 @@ moduleFactories.add({
|
|
|
389
390
|
return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
|
|
390
391
|
}
|
|
391
392
|
},
|
|
392
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
393
|
-
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/
|
|
393
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/index.js" (module) {
|
|
394
|
+
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/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/options.js"), loadPlugins = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/plugins.js"), req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/req.js");
|
|
394
395
|
async function processResult(ctx, result) {
|
|
395
396
|
let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
|
|
396
397
|
default: obj
|
|
@@ -463,8 +464,8 @@ moduleFactories.add({
|
|
|
463
464
|
});
|
|
464
465
|
};
|
|
465
466
|
},
|
|
466
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
467
|
-
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
467
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/options.js" (module) {
|
|
468
|
+
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/req.js");
|
|
468
469
|
module.exports = async function options(config, file) {
|
|
469
470
|
if (config.parser && 'string' == typeof config.parser) try {
|
|
470
471
|
config.parser = await req(config.parser, file);
|
|
@@ -484,8 +485,8 @@ moduleFactories.add({
|
|
|
484
485
|
return config;
|
|
485
486
|
};
|
|
486
487
|
},
|
|
487
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
488
|
-
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
488
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/plugins.js" (module) {
|
|
489
|
+
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/req.js");
|
|
489
490
|
async function load(plugin, options, file) {
|
|
490
491
|
try {
|
|
491
492
|
if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
|
|
@@ -501,7 +502,7 @@ moduleFactories.add({
|
|
|
501
502
|
}), list;
|
|
502
503
|
};
|
|
503
504
|
},
|
|
504
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
505
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/req.js" (module) {
|
|
505
506
|
let tsx, jiti, { createRequire } = __rspack_createRequire_require("node:module"), { pathToFileURL } = __rspack_createRequire_require("node:url"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
|
|
506
507
|
module.exports = async function req(name, rootFile = __rspack_import_meta_filename__) {
|
|
507
508
|
let url = createRequire(rootFile).resolve(name);
|
|
@@ -720,14 +721,14 @@ function findAllBrackets(v) {
|
|
|
720
721
|
}
|
|
721
722
|
function getMriOptions(options) {
|
|
722
723
|
let result = {
|
|
723
|
-
alias:
|
|
724
|
+
alias: Object.create(null),
|
|
724
725
|
boolean: []
|
|
725
726
|
};
|
|
726
727
|
for (let [index, option] of options.entries())option.names.length > 1 && (result.alias[option.names[0]] = option.names.slice(1)), option.isBoolean && (option.negated && options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required) || result.boolean.push(option.names[0]));
|
|
727
728
|
return result;
|
|
728
729
|
}
|
|
729
730
|
function findLongest(arr) {
|
|
730
|
-
return arr.sort((a, b)=>
|
|
731
|
+
return arr.sort((a, b)=>b.length - a.length)[0];
|
|
731
732
|
}
|
|
732
733
|
function padRight(str, length) {
|
|
733
734
|
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
@@ -735,7 +736,13 @@ function padRight(str, length) {
|
|
|
735
736
|
function camelcase(input) {
|
|
736
737
|
return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
|
|
737
738
|
}
|
|
739
|
+
let UNSAFE_KEYS = new Set([
|
|
740
|
+
"__proto__",
|
|
741
|
+
"constructor",
|
|
742
|
+
"prototype"
|
|
743
|
+
]);
|
|
738
744
|
function setDotProp(obj, keys, val) {
|
|
745
|
+
if (keys.some((key)=>UNSAFE_KEYS.has(key))) return;
|
|
739
746
|
let current = obj;
|
|
740
747
|
for(let i = 0; i < keys.length; i++){
|
|
741
748
|
let key = keys[i];
|
|
@@ -751,12 +758,9 @@ function setDotProp(obj, keys, val) {
|
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
760
|
function setByType(obj, transforms) {
|
|
754
|
-
for (let key of Object.
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
obj[key]
|
|
758
|
-
].flat(), "function" == typeof transform.transformFunction && (obj[key] = obj[key].map(transform.transformFunction)));
|
|
759
|
-
}
|
|
761
|
+
for (let [key, transform] of Object.entries(transforms))transform.shouldTransform && (obj[key] = [
|
|
762
|
+
obj[key]
|
|
763
|
+
].flat(), "function" == typeof transform.transformFunction && (obj[key] = obj[key].map(transform.transformFunction)));
|
|
760
764
|
}
|
|
761
765
|
function getFileName(input) {
|
|
762
766
|
let m = /([^\\/]+)$/.exec(input);
|
|
@@ -782,7 +786,7 @@ var CACError = class extends Error {
|
|
|
782
786
|
this.rawName = rawName, this.description = description, this.config = Object.assign({}, config), rawName = rawName.replaceAll(".*", ""), this.negated = !1, this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
783
787
|
let name = v.trim().replace(/^-{1,2}/, "");
|
|
784
788
|
return name.startsWith("no-") && (this.negated = !0, name = name.replace(/^no-/, "")), camelcaseOptionName(name);
|
|
785
|
-
}).sort((a, b)=>a.length
|
|
789
|
+
}).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;
|
|
786
790
|
}
|
|
787
791
|
};
|
|
788
792
|
if ("u" > typeof process) {
|
|
@@ -842,7 +846,7 @@ var Command = class {
|
|
|
842
846
|
return this instanceof GlobalCommand;
|
|
843
847
|
}
|
|
844
848
|
hasOption(name) {
|
|
845
|
-
return name = name.split(".")[0], this.options.find((option)=>option.names.includes(name));
|
|
849
|
+
return name = name.split(".", 1)[0], this.options.find((option)=>option.names.includes(name));
|
|
846
850
|
}
|
|
847
851
|
outputHelp() {
|
|
848
852
|
let { name, commands } = this.cli, { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand, sections = [
|
|
@@ -899,7 +903,7 @@ var Command = class {
|
|
|
899
903
|
...this.options
|
|
900
904
|
];
|
|
901
905
|
for (let option of options){
|
|
902
|
-
let value = parsedOptions[option.name.split(".")[0]];
|
|
906
|
+
let value = parsedOptions[option.name.split(".", 1)[0]];
|
|
903
907
|
if (option.required) {
|
|
904
908
|
let hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
905
909
|
if (!0 === value || !1 === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
@@ -1019,7 +1023,7 @@ var Command = class {
|
|
|
1019
1023
|
if (!ignoreDefault && void 0 !== cliOption.config.default) for (let name of cliOption.names)options[name] = cliOption.config.default;
|
|
1020
1024
|
Array.isArray(cliOption.config.type) && void 0 === transforms[cliOption.name] && (transforms[cliOption.name] = Object.create(null), transforms[cliOption.name].shouldTransform = !0, transforms[cliOption.name].transformFunction = cliOption.config.type[0]);
|
|
1021
1025
|
}
|
|
1022
|
-
for (let key of Object.
|
|
1026
|
+
for (let [key, value] of Object.entries(parsed))"_" !== key && (setDotProp(options, key.split("."), value), setByType(options, transforms));
|
|
1023
1027
|
return {
|
|
1024
1028
|
args,
|
|
1025
1029
|
options
|
|
@@ -2373,12 +2377,19 @@ function createEnvironmentAsyncHook() {
|
|
|
2373
2377
|
}
|
|
2374
2378
|
};
|
|
2375
2379
|
}
|
|
2380
|
+
let SKIP_CALLBACK = Symbol('skip callback');
|
|
2376
2381
|
function createAsyncHook() {
|
|
2377
|
-
let preGroup = [], postGroup = [], defaultGroup = []
|
|
2382
|
+
let preGroup = [], postGroup = [], defaultGroup = [], register = (cb, once)=>{
|
|
2383
|
+
let { handler, order } = isFunction(cb) ? {
|
|
2384
|
+
handler: cb
|
|
2385
|
+
} : cb, group = defaultGroup;
|
|
2386
|
+
if ('pre' === order ? group = preGroup : 'post' === order && (group = postGroup), !once) return void group.push(handler);
|
|
2387
|
+
let called = !1, onceCallback = (...args)=>called ? SKIP_CALLBACK : (called = !0, group.splice(group.indexOf(onceCallback), 1), handler(...args));
|
|
2388
|
+
group.push(onceCallback);
|
|
2389
|
+
};
|
|
2378
2390
|
return {
|
|
2379
|
-
tap: (cb)=>
|
|
2380
|
-
|
|
2381
|
-
},
|
|
2391
|
+
tap: (cb)=>register(cb, !1),
|
|
2392
|
+
tapOnce: (cb)=>register(cb, !0),
|
|
2382
2393
|
callChain: async (...params)=>{
|
|
2383
2394
|
for (let callback of [
|
|
2384
2395
|
...preGroup,
|
|
@@ -2386,7 +2397,7 @@ function createAsyncHook() {
|
|
|
2386
2397
|
...postGroup
|
|
2387
2398
|
]){
|
|
2388
2399
|
let result = await callback(...params);
|
|
2389
|
-
void 0 !== result && (params[0] = result);
|
|
2400
|
+
result !== SKIP_CALLBACK && void 0 !== result && (params[0] = result);
|
|
2390
2401
|
}
|
|
2391
2402
|
return params;
|
|
2392
2403
|
},
|
|
@@ -2398,7 +2409,7 @@ function createAsyncHook() {
|
|
|
2398
2409
|
], results = [];
|
|
2399
2410
|
for (let callback of callbacks){
|
|
2400
2411
|
let result = await callback(...params);
|
|
2401
|
-
results.push(result);
|
|
2412
|
+
result !== SKIP_CALLBACK && results.push(result);
|
|
2402
2413
|
}
|
|
2403
2414
|
return results;
|
|
2404
2415
|
}
|
|
@@ -2723,6 +2734,7 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2723
2734
|
server: {
|
|
2724
2735
|
port: 3000,
|
|
2725
2736
|
host: LOCALHOST,
|
|
2737
|
+
allowedHosts: !0,
|
|
2726
2738
|
open: !1,
|
|
2727
2739
|
base: '/',
|
|
2728
2740
|
htmlFallback: 'index',
|
|
@@ -3291,7 +3303,7 @@ function createPublicContext(context) {
|
|
|
3291
3303
|
async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
3292
3304
|
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, hooks = initHooks();
|
|
3293
3305
|
return {
|
|
3294
|
-
version: "2.2.
|
|
3306
|
+
version: "2.2.13",
|
|
3295
3307
|
rootPath,
|
|
3296
3308
|
configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
|
|
3297
3309
|
configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
|
|
@@ -4228,7 +4240,7 @@ function watchFilesForRestart({ watchFiles, context, restartContext }) {
|
|
|
4228
4240
|
} catch (error) {
|
|
4229
4241
|
logger.error(error);
|
|
4230
4242
|
}
|
|
4231
|
-
})), close = ()=>(closePromise || (closePromise = watchersPromise.then((watchers)=>Promise.all(watchers.map((watcher)=>watcher
|
|
4243
|
+
})), close = ()=>(closePromise || (closePromise = watchersPromise.then((watchers)=>Promise.all(watchers.filter((watcher)=>void 0 !== watcher).map((watcher)=>watcher.close()))).then(()=>{})), closePromise);
|
|
4232
4244
|
return {
|
|
4233
4245
|
close
|
|
4234
4246
|
};
|
|
@@ -4938,7 +4950,7 @@ function parseMinifyOptions(config) {
|
|
|
4938
4950
|
cssOptions: minify.cssOptions
|
|
4939
4951
|
};
|
|
4940
4952
|
}
|
|
4941
|
-
var postcss_load_config_src_default = compatGetDefaultExport(rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
4953
|
+
var postcss_load_config_src_default = compatGetDefaultExport(rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/baf07bf9099810ce2e0c00768f056c90b47d57b154f4b8912460449b9922899a/node_modules/postcss-load-config/src/index.js"));
|
|
4942
4954
|
async function getLightningCSSLoaderOptions(config, targets, minify) {
|
|
4943
4955
|
let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
|
|
4944
4956
|
targets,
|
|
@@ -5119,12 +5131,35 @@ function pluginExternals() {
|
|
|
5119
5131
|
...autoExternalRules
|
|
5120
5132
|
] : autoExternalRules : externals;
|
|
5121
5133
|
mergedExternals && chain.externals(mergedExternals);
|
|
5122
|
-
}), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
|
|
5123
|
-
for (let config of bundlerConfigs)(Array.isArray(config.target) ? config.target.includes('webworker') : 'webworker' === config.target) && !config.output?.module && config.externals && delete config.externals;
|
|
5124
5134
|
});
|
|
5125
5135
|
}
|
|
5126
5136
|
};
|
|
5127
5137
|
}
|
|
5138
|
+
function createAssetProcessor() {
|
|
5139
|
+
let failure, active = 0, waiting = [];
|
|
5140
|
+
return async (names, processAsset)=>{
|
|
5141
|
+
let cursor = 0, consume = async ()=>{
|
|
5142
|
+
for(; cursor < names.length && !failure;){
|
|
5143
|
+
let index = cursor++;
|
|
5144
|
+
active >= 16 ? await new Promise((resolve)=>waiting.push(resolve)) : active++;
|
|
5145
|
+
try {
|
|
5146
|
+
if (failure) return;
|
|
5147
|
+
await processAsset(names[index], index);
|
|
5148
|
+
} catch (error) {
|
|
5149
|
+
failure ??= {
|
|
5150
|
+
error
|
|
5151
|
+
};
|
|
5152
|
+
} finally{
|
|
5153
|
+
let next = waiting.shift();
|
|
5154
|
+
next ? next() : active--;
|
|
5155
|
+
}
|
|
5156
|
+
}
|
|
5157
|
+
};
|
|
5158
|
+
if (await Promise.all(Array.from({
|
|
5159
|
+
length: Math.min(16, names.length)
|
|
5160
|
+
}, consume)), failure) throw failure.error;
|
|
5161
|
+
};
|
|
5162
|
+
}
|
|
5128
5163
|
function getCompression(compressed) {
|
|
5129
5164
|
let { type = 'gzip', level = 6 } = 'object' == typeof compressed ? compressed : {};
|
|
5130
5165
|
return 'brotli' === type ? {
|
|
@@ -5143,19 +5178,19 @@ function getCompression(compressed) {
|
|
|
5143
5178
|
totalKey: 'totalGzipSize'
|
|
5144
5179
|
};
|
|
5145
5180
|
}
|
|
5146
|
-
|
|
5147
|
-
return
|
|
5148
|
-
let
|
|
5149
|
-
err ? reject(err) : resolve(result);
|
|
5150
|
-
};
|
|
5151
|
-
'brotli' === type ? node_zlib.brotliCompress(input, {
|
|
5181
|
+
function calcCompressedSize(input, type, level) {
|
|
5182
|
+
return new Promise((resolve, reject)=>{
|
|
5183
|
+
let stream = 'brotli' === type ? node_zlib.createBrotliCompress({
|
|
5152
5184
|
params: {
|
|
5153
5185
|
[node_zlib.constants.BROTLI_PARAM_QUALITY]: level
|
|
5154
5186
|
}
|
|
5155
|
-
}
|
|
5187
|
+
}) : node_zlib.createGzip({
|
|
5156
5188
|
level
|
|
5157
|
-
},
|
|
5158
|
-
|
|
5189
|
+
}), size = 0;
|
|
5190
|
+
stream.on('data', (chunk)=>{
|
|
5191
|
+
size += chunk.length;
|
|
5192
|
+
}), stream.on('error', reject), stream.on('end', ()=>resolve(size)), stream.end(input);
|
|
5193
|
+
});
|
|
5159
5194
|
}
|
|
5160
5195
|
function getSnapshotPath(dir, snapshotHash) {
|
|
5161
5196
|
return snapshotHash ? node_path.join(dir, `rsbuild/file-sizes-${snapshotHash}.json`) : node_path.join(dir, 'rsbuild/file-sizes.json');
|
|
@@ -5205,11 +5240,30 @@ function getHeader(maxFileLength, maxSizeLength, fileHeader, compressionHeader)
|
|
|
5205
5240
|
let calcFileSize = (len)=>{
|
|
5206
5241
|
let val = len / 1000;
|
|
5207
5242
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
5208
|
-
}, COMPRESSIBLE_REGEX = /\.(?:js|mjs|cjs|jsx|ts|tsx|mts|cts|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
};
|
|
5212
|
-
|
|
5243
|
+
}, COMPRESSIBLE_REGEX = /\.(?:js|mjs|cjs|jsx|ts|tsx|mts|cts|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
|
|
5244
|
+
async function getFileSizes(options, compilation, processAssets) {
|
|
5245
|
+
if (!1 === options.detail && !1 === options.total) return [];
|
|
5246
|
+
let { exclude, include } = options, compression = getCompression(options.compressed), fileSizes = [], compilationAssets = compilation.assets, names = Object.getOwnPropertyNames(compilationAssets);
|
|
5247
|
+
return await processAssets(names, async (assetName, index)=>{
|
|
5248
|
+
let queryIndex, filePath = -1 === (queryIndex = assetName.indexOf('?')) ? assetName : assetName.slice(0, queryIndex);
|
|
5249
|
+
if (!exclude && EXCLUDE_ASSET_REGEX.test(filePath)) return;
|
|
5250
|
+
let value = compilationAssets[assetName], content = options.compressed && COMPRESSIBLE_REGEX.test(filePath) ? value.buffer() : void 0, size = void 0 === content ? value.size() : content.length;
|
|
5251
|
+
if (exclude || include) {
|
|
5252
|
+
let publicAsset = {
|
|
5253
|
+
name: filePath,
|
|
5254
|
+
size
|
|
5255
|
+
};
|
|
5256
|
+
if (exclude?.(publicAsset) || include && !include(publicAsset)) return;
|
|
5257
|
+
}
|
|
5258
|
+
let compressedSize = void 0 === content ? null : await calcCompressedSize(content, compression.type, compression.level);
|
|
5259
|
+
fileSizes[index] = {
|
|
5260
|
+
filePath,
|
|
5261
|
+
size,
|
|
5262
|
+
compressedSize
|
|
5263
|
+
};
|
|
5264
|
+
}), fileSizes.filter(Boolean);
|
|
5265
|
+
}
|
|
5266
|
+
function printFileSizes(options, fileSizes, rootPath, distPath, environmentName, previousSizes, saveSnapshot) {
|
|
5213
5267
|
let logs = [], compression = getCompression(options.compressed), prev = previousSizes?.[environmentName], showDetail = !1 !== options.detail, showDiff = !1 !== options.diff && null !== previousSizes, prevType = prev?.compressionType ?? (!!prev?.totalGzipSize && 'gzip'), showCompressedDiff = showDiff && prevType === compression.type, showTotal = !1 !== options.total;
|
|
5214
5268
|
if (!showTotal && !showDetail) return {
|
|
5215
5269
|
logs
|
|
@@ -5219,52 +5273,45 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
5219
5273
|
totalSize: 0,
|
|
5220
5274
|
totalGzipSize: 0,
|
|
5221
5275
|
compressionType: !!options.compressed && compression.type
|
|
5222
|
-
} : null,
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
compressedSize,
|
|
5249
|
-
compressedSizeLabel
|
|
5250
|
-
};
|
|
5251
|
-
}, getAssets = async ()=>{
|
|
5252
|
-
let { exclude, include } = options, formattedAssets = [], compilationAssets = stats.compilation.assets;
|
|
5253
|
-
for (let assetName of Object.keys(compilationAssets)){
|
|
5254
|
-
let filePath = getFilePath(assetName);
|
|
5255
|
-
if (!exclude && EXCLUDE_ASSET_REGEX.test(filePath)) continue;
|
|
5256
|
-
let value = compilationAssets[assetName], content = options.compressed && isCompressible(filePath) ? value.source() : void 0, size = void 0 === content ? value.size() : Buffer.byteLength(content);
|
|
5257
|
-
if (exclude || include) {
|
|
5258
|
-
let publicAsset = {
|
|
5259
|
-
name: filePath,
|
|
5260
|
-
size
|
|
5261
|
-
};
|
|
5262
|
-
if (exclude?.(publicAsset) || include && !include(publicAsset)) continue;
|
|
5276
|
+
} : null, assets = fileSizes.map(({ filePath, size, compressedSize })=>((filePath, size, compressedSize)=>{
|
|
5277
|
+
let normalizedPath = '';
|
|
5278
|
+
if ((snapshot || showDetail && showDiff) && (normalizedPath = normalizeFilePath(filePath), snapshot && (snapshot.files[normalizedPath] = {
|
|
5279
|
+
size,
|
|
5280
|
+
[compression.sizeKey]: compressedSize ?? void 0
|
|
5281
|
+
})), !showDetail) return {
|
|
5282
|
+
filePath,
|
|
5283
|
+
filenameLabel: '',
|
|
5284
|
+
filenameLength: 0,
|
|
5285
|
+
size,
|
|
5286
|
+
sizeLabel: '',
|
|
5287
|
+
sizeLabelLength: 0,
|
|
5288
|
+
compressedSize,
|
|
5289
|
+
compressedSizeLabel: null
|
|
5290
|
+
};
|
|
5291
|
+
let sizeLabel = calcFileSize(size), sizeLabelLength = sizeLabel.length, compressedSizeLabel = compressedSize ? getAssetColor(compressedSize)(calcFileSize(compressedSize)) : null;
|
|
5292
|
+
if (showDiff) {
|
|
5293
|
+
let sizeData = prev?.files[normalizedPath], sizeDiff = size - (sizeData?.size ?? 0);
|
|
5294
|
+
if (isSignificantDiff(sizeDiff)) {
|
|
5295
|
+
let { label, length } = formatDiff(sizeDiff);
|
|
5296
|
+
sizeLabel += ` ${label}`, sizeLabelLength += length + 1;
|
|
5297
|
+
}
|
|
5298
|
+
if (null !== compressedSize && showCompressedDiff) {
|
|
5299
|
+
let compressedDiff = compressedSize - (sizeData?.[compression.sizeKey] ?? 0);
|
|
5300
|
+
isSignificantDiff(compressedDiff) && (compressedSizeLabel += ` ${formatDiff(compressedDiff).label}`);
|
|
5301
|
+
}
|
|
5263
5302
|
}
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5303
|
+
let separatorIndex = filePath.lastIndexOf('/'), folderLabel = -1 === separatorIndex ? rootFolderLabel : `${node_path.join(relativeDistPath, filePath.slice(0, separatorIndex))}${node_path.sep}`, filename = -1 === separatorIndex ? filePath : filePath.slice(separatorIndex + 1);
|
|
5304
|
+
return {
|
|
5305
|
+
filePath,
|
|
5306
|
+
filenameLabel: color.dim(folderLabel) + (JS_REGEX.test(filename) ? color.cyan(filename) : filename.endsWith('.css') ? color.yellow(filename) : filename.endsWith('.html') ? color.green(filename) : color.magenta(filename)),
|
|
5307
|
+
filenameLength: folderLabel.length + filename.length,
|
|
5308
|
+
size,
|
|
5309
|
+
sizeLabel,
|
|
5310
|
+
sizeLabelLength,
|
|
5311
|
+
compressedSize,
|
|
5312
|
+
compressedSizeLabel
|
|
5313
|
+
};
|
|
5314
|
+
})(filePath, size, compressedSize)).sort((a, b)=>a.size - b.size);
|
|
5268
5315
|
if (0 === assets.length) return {
|
|
5269
5316
|
logs
|
|
5270
5317
|
};
|
|
@@ -5348,7 +5395,18 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
5348
5395
|
snapshot
|
|
5349
5396
|
};
|
|
5350
5397
|
}
|
|
5351
|
-
let
|
|
5398
|
+
let fileSize_normalizeConfig = (config)=>{
|
|
5399
|
+
let { printFileSize } = config.performance, defaultConfig = {
|
|
5400
|
+
total: !0,
|
|
5401
|
+
detail: !0,
|
|
5402
|
+
diff: !1,
|
|
5403
|
+
compressed: 'node' !== config.output.target
|
|
5404
|
+
};
|
|
5405
|
+
return !0 === printFileSize ? defaultConfig : {
|
|
5406
|
+
...defaultConfig,
|
|
5407
|
+
...printFileSize
|
|
5408
|
+
};
|
|
5409
|
+
}, isNonceTag = (tag)=>"script" === tag.tag || 'style' === tag.tag || 'link' === tag.tag && tag.attrs?.rel === 'preload' && tag.attrs?.as === "script", entryNameSymbol = Symbol('entryName'), VOID_TAGS = [
|
|
5352
5410
|
'area',
|
|
5353
5411
|
'base',
|
|
5354
5412
|
'br',
|
|
@@ -5800,7 +5858,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5800
5858
|
});
|
|
5801
5859
|
});
|
|
5802
5860
|
} catch (e) {
|
|
5803
|
-
if ('EADDRINUSE' !== e.code) throw e;
|
|
5861
|
+
if (!(e instanceof Error) || !('code' in e) || 'EADDRINUSE' !== e.code) throw e;
|
|
5804
5862
|
port++, attempts++;
|
|
5805
5863
|
}
|
|
5806
5864
|
if (!found) throw Error(`${color.dim('[rsbuild:server]')} Failed to find an available port after ${tryLimits + 1} attempts, starting from ${color.yellow(original)}.`);
|
|
@@ -6000,7 +6058,7 @@ function doesChunkBelongToHtml({ chunk, htmlPluginData }) {
|
|
|
6000
6058
|
let { options } = htmlPluginData.plugin;
|
|
6001
6059
|
return recursiveChunkEntryNames(chunk).some((chunkName)=>isChunksFiltered(chunkName, options?.chunks, options?.excludeChunks));
|
|
6002
6060
|
}
|
|
6003
|
-
let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(rspackRequire.bind(rspackRequire, "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/rspack-manifest-plugin/5.2.2/
|
|
6061
|
+
let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(rspackRequire.bind(rspackRequire, "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/rspack-manifest-plugin/5.2.2/cbeeb1bf16831c5d12121244c2e0e825d7a61324a587214ca9e44e464c6b1496/node_modules/rspack-manifest-plugin/dist/index.js"))), isCSSPath = (filePath)=>filePath.endsWith('.css');
|
|
6004
6062
|
function normalizeManifestObjectConfig(manifest) {
|
|
6005
6063
|
let defaultOptions = {
|
|
6006
6064
|
prefix: !0,
|
|
@@ -6769,6 +6827,10 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6769
6827
|
}
|
|
6770
6828
|
-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]));
|
|
6771
6829
|
}
|
|
6830
|
+
if ('HEAD' === req.method) {
|
|
6831
|
+
res.setHeader('Content-Length', len), 404 === res.statusCode && (res.statusCode = 200), res.end();
|
|
6832
|
+
return;
|
|
6833
|
+
}
|
|
6772
6834
|
let [start, end] = calcStartAndEnd(offset, len);
|
|
6773
6835
|
try {
|
|
6774
6836
|
readStream = createReadStream(filename, outputFileSystem, start, end);
|
|
@@ -6776,10 +6838,7 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6776
6838
|
await goNext();
|
|
6777
6839
|
return;
|
|
6778
6840
|
}
|
|
6779
|
-
|
|
6780
|
-
404 === res.statusCode && (res.statusCode = 200), res.end();
|
|
6781
|
-
return;
|
|
6782
|
-
}
|
|
6841
|
+
res.setHeader('Content-Length', len);
|
|
6783
6842
|
let cleanup = ()=>{
|
|
6784
6843
|
destroyStream(readStream, !0);
|
|
6785
6844
|
};
|
|
@@ -6797,38 +6856,41 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6797
6856
|
});
|
|
6798
6857
|
};
|
|
6799
6858
|
}
|
|
6800
|
-
async function setupOutputFileSystem(
|
|
6801
|
-
if (!
|
|
6859
|
+
async function setupOutputFileSystem(writeAllToDisk, compilers) {
|
|
6860
|
+
if (!writeAllToDisk) {
|
|
6802
6861
|
let { createMemoryFileSystem } = await import("./memfs.js"), outputFileSystem = createMemoryFileSystem();
|
|
6803
6862
|
for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
|
|
6804
6863
|
}
|
|
6805
6864
|
let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
|
|
6806
6865
|
return compiler?.outputFileSystem ?? node_fs;
|
|
6807
6866
|
}
|
|
6808
|
-
function setupWriteToDisk(compilers,
|
|
6809
|
-
for (let compiler of compilers
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
node_fs.writeFile(targetPath, content, (writeFileError)=>{
|
|
6823
|
-
if (writeFileError) {
|
|
6824
|
-
logger.error(`[rsbuild:middleware] ${name}Unable to write "${targetPath}" asset to disk:\n${writeFileError.message}`), callback(writeFileError);
|
|
6867
|
+
function setupWriteToDisk(compilers, writeToDiskList, logger) {
|
|
6868
|
+
for (let [index, compiler] of compilers.entries()){
|
|
6869
|
+
let writeToDisk = writeToDiskList[index];
|
|
6870
|
+
writeToDisk && compiler.hooks.emit.tap('DevMiddleware', ()=>{
|
|
6871
|
+
compiler.__hasRsbuildAssetEmittedCallback || (compiler.hooks.assetEmitted.tapAsync('DevMiddleware', (_file, info, callback)=>{
|
|
6872
|
+
if (compiler.outputFileSystem === node_fs) return void callback();
|
|
6873
|
+
let { targetPath } = info;
|
|
6874
|
+
if ('function' == typeof writeToDisk && !writeToDisk(targetPath)) return void callback();
|
|
6875
|
+
let { content } = info, dir = node_path.dirname(targetPath), name = compiler.options.name ? `Child "${compiler.options.name}": ` : '';
|
|
6876
|
+
node_fs.mkdir(dir, {
|
|
6877
|
+
recursive: !0
|
|
6878
|
+
}, (mkdirError)=>{
|
|
6879
|
+
if (mkdirError) {
|
|
6880
|
+
logger.error(`[rsbuild:middleware] ${name}Unable to write "${dir}" directory to disk:\n${mkdirError.message}`), callback(mkdirError);
|
|
6825
6881
|
return;
|
|
6826
6882
|
}
|
|
6827
|
-
|
|
6883
|
+
node_fs.writeFile(targetPath, content, (writeFileError)=>{
|
|
6884
|
+
if (writeFileError) {
|
|
6885
|
+
logger.error(`[rsbuild:middleware] ${name}Unable to write "${targetPath}" asset to disk:\n${writeFileError.message}`), callback(writeFileError);
|
|
6886
|
+
return;
|
|
6887
|
+
}
|
|
6888
|
+
callback();
|
|
6889
|
+
});
|
|
6828
6890
|
});
|
|
6829
|
-
});
|
|
6830
|
-
})
|
|
6831
|
-
}
|
|
6891
|
+
}), compiler.__hasRsbuildAssetEmittedCallback = !0);
|
|
6892
|
+
});
|
|
6893
|
+
}
|
|
6832
6894
|
}
|
|
6833
6895
|
let noop = ()=>{}, normalizeLiveReload = (liveReload)=>'boolean' == typeof liveReload ? {
|
|
6834
6896
|
enabled: liveReload,
|
|
@@ -6867,8 +6929,7 @@ init(
|
|
|
6867
6929
|
}).apply(compiler);
|
|
6868
6930
|
}
|
|
6869
6931
|
let assets_middleware_assetsMiddleware = async ({ config, compiler, context, socketServer, resolvedPort })=>{
|
|
6870
|
-
|
|
6871
|
-
let watching, writeToDiskValues, { logger } = context, resolvedHost = await resolveHostname(config.server.host), { environments, environmentList } = context;
|
|
6932
|
+
let watching, { logger } = context, resolvedHost = await resolveHostname(config.server.host), { environmentList } = context;
|
|
6872
6933
|
applyToCompiler(compiler, (compiler, index)=>{
|
|
6873
6934
|
let environment = environmentList[index];
|
|
6874
6935
|
if (!environment) return;
|
|
@@ -6932,14 +6993,11 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
|
|
|
6932
6993
|
'done' === context.buildState.status && flushCallbacks();
|
|
6933
6994
|
});
|
|
6934
6995
|
});
|
|
6935
|
-
let
|
|
6936
|
-
|
|
6937
|
-
return name && environments[name] && (writeToDisk = environments[name].config.dev.writeToDisk ?? writeToDisk), 'function' == typeof writeToDisk ? writeToDisk(filePath) : writeToDisk;
|
|
6938
|
-
});
|
|
6939
|
-
writeToDisk && setupWriteToDisk(compilers, writeToDisk, logger);
|
|
6996
|
+
let writeToDiskList = environmentList.map((environment)=>environment.config.dev.writeToDisk);
|
|
6997
|
+
writeToDiskList.some(Boolean) && setupWriteToDisk(compilers, writeToDiskList, logger);
|
|
6940
6998
|
let instance = createAssetsMiddleware(context, (callback)=>{
|
|
6941
6999
|
'done' === context.buildState.status || 'failed' === context.buildState.status ? callback() : callbacks.push(callback);
|
|
6942
|
-
}, await setupOutputFileSystem(writeToDisk, compilers));
|
|
7000
|
+
}, await setupOutputFileSystem(writeToDiskList.every((writeToDisk)=>!0 === writeToDisk), compilers));
|
|
6943
7001
|
return instance.watch = ()=>{
|
|
6944
7002
|
if (compiler.watching) watching = compiler.watching;
|
|
6945
7003
|
else {
|
|
@@ -7505,14 +7563,17 @@ function gzipMiddleware_gzipMiddleware({ filter, level = node_zlib.constants.Z_B
|
|
|
7505
7563
|
if (!CONTENT_TYPE_REGEX.test(contentTypeValue) || 'text/event-stream' === contentTypeValue.split(';', 1)[0].trim().toLowerCase()) return !1;
|
|
7506
7564
|
let size = res.getHeader('Content-Length');
|
|
7507
7565
|
return void 0 === size || Number(size) > 1024;
|
|
7508
|
-
})(res))
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7566
|
+
})(res)) {
|
|
7567
|
+
let contentLength = Number(res.getHeader('Content-Length'));
|
|
7568
|
+
for (let listener of (res.setHeader('Content-Encoding', 'gzip'), res.removeHeader('Content-Length'), (gzip = node_zlib.createGzip({
|
|
7569
|
+
level,
|
|
7570
|
+
chunkSize: contentLength > 524288 ? 65536 : void 0
|
|
7571
|
+
})).on('data', (chunk)=>{
|
|
7572
|
+
write(chunk) || gzip.pause();
|
|
7573
|
+
}), on('drain', ()=>gzip.resume()), on('close', ()=>gzip.destroy()), gzip.on('end', ()=>{
|
|
7574
|
+
end();
|
|
7575
|
+
}), listeners))gzip.on(...listener);
|
|
7576
|
+
} else for (let listener of listeners)on.apply(res, listener);
|
|
7516
7577
|
let statusCode = writeHeadStatus ?? res.statusCode;
|
|
7517
7578
|
void 0 !== writeHeadMessage ? writeHead(statusCode, writeHeadMessage) : writeHead(statusCode);
|
|
7518
7579
|
};
|
|
@@ -7617,7 +7678,17 @@ let faviconFallbackMiddleware = (req, res, next)=>{
|
|
|
7617
7678
|
resolve(!!stats?.isFile());
|
|
7618
7679
|
});
|
|
7619
7680
|
}), isFileExistsInDistPaths = async (distPaths, filename, outputFileSystem)=>{
|
|
7620
|
-
|
|
7681
|
+
let decodedFilename;
|
|
7682
|
+
try {
|
|
7683
|
+
decodedFilename = decodeURIComponent(filename);
|
|
7684
|
+
} catch {
|
|
7685
|
+
return !1;
|
|
7686
|
+
}
|
|
7687
|
+
if (decodedFilename.includes('\0') || UP_PATH_REGEXP.test(decodedFilename) && UP_PATH_REGEXP.test(node_path.normalize(`./${decodedFilename}`))) return !1;
|
|
7688
|
+
for (let distPath of distPaths){
|
|
7689
|
+
let filePath = node_path.join(distPath, decodedFilename);
|
|
7690
|
+
if (await middlewares_isFileExists(filePath, outputFileSystem)) return !0;
|
|
7691
|
+
}
|
|
7621
7692
|
return !1;
|
|
7622
7693
|
}, maybeHTMLRequest = (req)=>{
|
|
7623
7694
|
if (!req.url || !req.headers || 'GET' !== req.method && 'HEAD' !== req.method) return !1;
|
|
@@ -7675,14 +7746,14 @@ function formatProxyOptions(proxyOptions, logger) {
|
|
|
7675
7746
|
let logPrefix = color.dim('[http-proxy-middleware]: '), defaultOptions = {
|
|
7676
7747
|
changeOrigin: !0,
|
|
7677
7748
|
logger: {
|
|
7678
|
-
info (msg) {
|
|
7679
|
-
logger.debug(logPrefix + msg);
|
|
7749
|
+
info (msg, ...args) {
|
|
7750
|
+
logger.debug(logPrefix + external_node_util_format(msg, ...args));
|
|
7680
7751
|
},
|
|
7681
|
-
warn: (msg)=>{
|
|
7682
|
-
logger.warn(logPrefix + msg);
|
|
7752
|
+
warn: (msg, ...args)=>{
|
|
7753
|
+
logger.warn(logPrefix + external_node_util_format(msg, ...args));
|
|
7683
7754
|
},
|
|
7684
|
-
error: (msg)=>{
|
|
7685
|
-
logger.error(logPrefix + msg);
|
|
7755
|
+
error: (msg, ...args)=>{
|
|
7756
|
+
logger.error(logPrefix + external_node_util_format(msg, ...args));
|
|
7686
7757
|
}
|
|
7687
7758
|
}
|
|
7688
7759
|
};
|
|
@@ -7700,7 +7771,10 @@ function formatProxyOptions(proxyOptions, logger) {
|
|
|
7700
7771
|
async function createProxyMiddleware(proxyOptions, logger) {
|
|
7701
7772
|
let formattedOptions = formatProxyOptions(proxyOptions, logger), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("./http-proxy-middleware.js");
|
|
7702
7773
|
for (let opts of formattedOptions){
|
|
7703
|
-
let proxyMiddleware = baseMiddleware(
|
|
7774
|
+
let proxyMiddleware = baseMiddleware({
|
|
7775
|
+
...opts,
|
|
7776
|
+
ws: !1
|
|
7777
|
+
}), middleware = async (req, res, next)=>{
|
|
7704
7778
|
let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
|
|
7705
7779
|
!1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
|
|
7706
7780
|
};
|
|
@@ -7737,7 +7811,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
7737
7811
|
})), middlewares.use('/__open-in-editor', async (req, res, next)=>{
|
|
7738
7812
|
try {
|
|
7739
7813
|
(await (launchEditorHandlerPromise ??= (async ()=>{
|
|
7740
|
-
let { default: launchEditorMiddleware } = await import("./launch-editor-middleware.js").then(createFakeNamespaceObject.bind(rspackRequire, "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/launch-editor-middleware/2.14.
|
|
7814
|
+
let { default: launchEditorMiddleware } = await import("./launch-editor-middleware.js").then(createFakeNamespaceObject.bind(rspackRequire, "../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/launch-editor-middleware/2.14.2/46c81dbb0ad4cd8f776539a7cfaa5ea6144007363b919f05970ca6624282dcce/node_modules/launch-editor-middleware/index.js", 23));
|
|
7741
7815
|
return launchEditorMiddleware();
|
|
7742
7816
|
})()))(req, res, next);
|
|
7743
7817
|
} catch (err) {
|
|
@@ -8152,7 +8226,44 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
8152
8226
|
}
|
|
8153
8227
|
let { createServer } = await import("node:http");
|
|
8154
8228
|
return createServer(middlewares);
|
|
8155
|
-
},
|
|
8229
|
+
}, HOST_CHECK_ERROR = 'Blocked request: disallowed or invalid Host header. To allow a trusted hostname, add it to server.allowedHosts.';
|
|
8230
|
+
function createHostCheckMiddleware(allowedHosts) {
|
|
8231
|
+
return (req, res, next)=>{
|
|
8232
|
+
isRequestHostAllowed(req.headers, allowedHosts) ? next() : (res.writeHead(403, {
|
|
8233
|
+
'Content-Type': 'text/plain; charset=utf-8'
|
|
8234
|
+
}), res.end(HOST_CHECK_ERROR));
|
|
8235
|
+
};
|
|
8236
|
+
}
|
|
8237
|
+
function withHostCheck(onUpgrade, allowedHosts) {
|
|
8238
|
+
return (req, socket, head)=>{
|
|
8239
|
+
if (!isRequestHostAllowed(req.headers, allowedHosts)) {
|
|
8240
|
+
socket.end(`HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Length: ${Buffer.byteLength(HOST_CHECK_ERROR)}\r\n\r\n` + HOST_CHECK_ERROR), socket.destroySoon();
|
|
8241
|
+
return;
|
|
8242
|
+
}
|
|
8243
|
+
onUpgrade(req, socket, head);
|
|
8244
|
+
};
|
|
8245
|
+
}
|
|
8246
|
+
function isRequestHostAllowed(headers, allowedHosts) {
|
|
8247
|
+
let { host, ':authority': authority } = headers;
|
|
8248
|
+
if (void 0 !== authority && void 0 !== host && authority !== host) return !1;
|
|
8249
|
+
let hostHeader = authority ?? host;
|
|
8250
|
+
return 'string' == typeof hostHeader && isHostAllowed(hostHeader, allowedHosts);
|
|
8251
|
+
}
|
|
8252
|
+
let normalizeHostname = (hostname)=>hostname.toLowerCase().replace(/\.$/, '');
|
|
8253
|
+
function isHostAllowed(hostHeader, allowedHosts) {
|
|
8254
|
+
let hostname;
|
|
8255
|
+
if (!hostHeader || /[\s/@\\?#%]/.test(hostHeader)) return !1;
|
|
8256
|
+
try {
|
|
8257
|
+
hostname = normalizeHostname(new URL(`http://${hostHeader}`).hostname);
|
|
8258
|
+
} catch {
|
|
8259
|
+
return !1;
|
|
8260
|
+
}
|
|
8261
|
+
return !!(hostname.startsWith('[') || isIP(hostname) || 'localhost' === hostname || hostname.endsWith('.localhost')) || allowedHosts.some((allowedHost)=>{
|
|
8262
|
+
let normalized = normalizeHostname(allowedHost);
|
|
8263
|
+
return hostname === normalized || normalized.startsWith('.') && (hostname === normalized.slice(1) || hostname.endsWith(normalized));
|
|
8264
|
+
});
|
|
8265
|
+
}
|
|
8266
|
+
let getPublicPathname = (publicPath)=>'auto' === publicPath || '' === publicPath ? '' : getPathnameFromUrl(publicPath.endsWith('/') ? publicPath : `${publicPath}/`), getPublicPathnames = (publicPaths, base)=>publicPaths.map(getPublicPathname).map((prefix)=>base && '/' !== base ? removeBasePath(prefix, base) : prefix);
|
|
8156
8267
|
async function applyServerSetup(setup, context) {
|
|
8157
8268
|
let postCallbacks = [];
|
|
8158
8269
|
for (let handler of helpers_castArray(setup || [])){
|
|
@@ -8291,7 +8402,7 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8291
8402
|
customShortcuts: shortcutsOptions.custom,
|
|
8292
8403
|
logger
|
|
8293
8404
|
});
|
|
8294
|
-
context.hooks.onCloseDevServer.
|
|
8405
|
+
context.hooks.onCloseDevServer.tapOnce(cleanup);
|
|
8295
8406
|
}
|
|
8296
8407
|
!getPortSilently && portTip && logger.info(portTip);
|
|
8297
8408
|
}, cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>((entryName, utils)=>{
|
|
@@ -8338,7 +8449,12 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8338
8449
|
}
|
|
8339
8450
|
};
|
|
8340
8451
|
});
|
|
8341
|
-
let { connect } = await import("./connect-next.js"), middlewares = connect(),
|
|
8452
|
+
let { connect } = await import("./connect-next.js"), middlewares = connect(), allowedHosts = !0 === config.server.allowedHosts ? void 0 : [
|
|
8453
|
+
...config.server.allowedHosts,
|
|
8454
|
+
host
|
|
8455
|
+
];
|
|
8456
|
+
allowedHosts && middlewares.use(createHostCheckMiddleware(allowedHosts));
|
|
8457
|
+
let httpServer = middlewareMode ? null : await createHttpServer({
|
|
8342
8458
|
serverConfig: config.server,
|
|
8343
8459
|
middlewares
|
|
8344
8460
|
}), devServer = {
|
|
@@ -8350,12 +8466,12 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8350
8466
|
listen: async ()=>{
|
|
8351
8467
|
if (!httpServer) throw Error(`${color.dim('[rsbuild:server]')} Can not listen dev server as ${color.yellow('server.middlewareMode')} is enabled.`);
|
|
8352
8468
|
let serverTerminator = getServerTerminator(httpServer);
|
|
8353
|
-
logger.debug('listen dev server'), context.hooks.onCloseDevServer.
|
|
8469
|
+
logger.debug('listen dev server'), context.hooks.onCloseDevServer.tapOnce(serverTerminator);
|
|
8354
8470
|
try {
|
|
8355
8471
|
return httpServer.listen({
|
|
8356
8472
|
host,
|
|
8357
8473
|
port
|
|
8358
|
-
}), await
|
|
8474
|
+
}), await external_node_events_once(httpServer, 'listening'), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), devServer.connectWebSocket({
|
|
8359
8475
|
server: httpServer
|
|
8360
8476
|
}), logger.debug('listen dev server done'), await devServer.afterListen(), {
|
|
8361
8477
|
port,
|
|
@@ -8395,7 +8511,7 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8395
8511
|
})).filter((item)=>'function' == typeof item),
|
|
8396
8512
|
...setupPostCallbacks
|
|
8397
8513
|
];
|
|
8398
|
-
return runCompile ? context.hooks.onBeforeCreateCompiler.
|
|
8514
|
+
return runCompile ? context.hooks.onBeforeCreateCompiler.tapOnce(beforeCreateCompiler) : await beforeCreateCompiler(), state.buildManager = runCompile ? await startCompile() : void 0, state.fileWatcher = await setupWatchFiles({
|
|
8399
8515
|
config,
|
|
8400
8516
|
buildManager: state.buildManager,
|
|
8401
8517
|
root: context.rootPath
|
|
@@ -8405,14 +8521,19 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8405
8521
|
devServer,
|
|
8406
8522
|
context,
|
|
8407
8523
|
postCallbacks
|
|
8408
|
-
}), state.buildManager?.watch(), unregisterRestart = context.restartManager.registerCleanup(closeServerResources), state.restartWatcher = watchFilesForRestart({
|
|
8524
|
+
}), allowedHosts && (state.devMiddlewares.onUpgrade = withHostCheck(state.devMiddlewares.onUpgrade, allowedHosts)), state.buildManager?.watch(), unregisterRestart = context.restartManager.registerCleanup(closeServerResources), state.restartWatcher = watchFilesForRestart({
|
|
8409
8525
|
watchFiles: config.dev.watchFiles,
|
|
8410
8526
|
context,
|
|
8411
8527
|
restartContext
|
|
8412
8528
|
}), logger.debug('create dev server done'), devServer;
|
|
8413
8529
|
}
|
|
8414
8530
|
async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
8415
|
-
let cleanupCliShortcuts, { logger } = context, { connect } = await import("./connect-next.js"), middlewares = connect(), { port, portTip } = await resolvePort(config), serverConfig = config.server, { host, headers, proxy, historyApiFallback, compress, base, cors } = serverConfig,
|
|
8531
|
+
let cleanupCliShortcuts, { logger } = context, { connect } = await import("./connect-next.js"), middlewares = connect(), { port, portTip } = await resolvePort(config), serverConfig = config.server, { host, headers, proxy, historyApiFallback, compress, base, cors } = serverConfig, allowedHosts = !0 === serverConfig.allowedHosts ? void 0 : [
|
|
8532
|
+
...serverConfig.allowedHosts,
|
|
8533
|
+
host
|
|
8534
|
+
];
|
|
8535
|
+
allowedHosts && middlewares.use(createHostCheckMiddleware(allowedHosts));
|
|
8536
|
+
let assetPrefixes = context.environmentList.map((environment)=>environment.config.output.assetPrefix);
|
|
8416
8537
|
context.publicPathnames = getPublicPathnames(assetPrefixes, base);
|
|
8417
8538
|
let protocol = serverConfig.https ? 'https' : 'http', routes = getRoutes(context), urls = await getAddressUrls({
|
|
8418
8539
|
protocol,
|
|
@@ -8471,7 +8592,7 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
|
8471
8592
|
}), proxy) {
|
|
8472
8593
|
let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(proxy, logger);
|
|
8473
8594
|
for (let middleware of proxyMiddlewares)middlewares.use(middleware);
|
|
8474
|
-
httpServer.on('upgrade', upgrade);
|
|
8595
|
+
httpServer.on('upgrade', allowedHosts ? withHostCheck(upgrade, allowedHosts) : upgrade);
|
|
8475
8596
|
}
|
|
8476
8597
|
for (let callback of (compress && middlewares.use(gzipMiddleware_gzipMiddleware({
|
|
8477
8598
|
level: external_node_zlib_constants.Z_DEFAULT_COMPRESSION,
|
|
@@ -8487,7 +8608,7 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
|
8487
8608
|
if (httpServer.listen({
|
|
8488
8609
|
host,
|
|
8489
8610
|
port
|
|
8490
|
-
}), await
|
|
8611
|
+
}), await external_node_events_once(httpServer, 'listening'), await context.hooks.onAfterStartPreviewServer.callBatch({
|
|
8491
8612
|
port,
|
|
8492
8613
|
routes,
|
|
8493
8614
|
environments: context.environments
|
|
@@ -8753,27 +8874,31 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8753
8874
|
{
|
|
8754
8875
|
name: 'rsbuild:file-size',
|
|
8755
8876
|
setup (api) {
|
|
8756
|
-
|
|
8877
|
+
let fileSizeResults, processAssets;
|
|
8878
|
+
api.onBeforeBuild(({ isFirstCompile })=>{
|
|
8879
|
+
fileSizeResults = isFirstCompile ? [] : void 0, processAssets = isFirstCompile ? createAssetProcessor() : void 0;
|
|
8880
|
+
}), api.onAfterCreateCompiler(({ compiler })=>{
|
|
8881
|
+
'build' === context.action && applyToCompiler(compiler, (compiler, index)=>{
|
|
8882
|
+
let { config } = context.environmentList[index];
|
|
8883
|
+
!1 !== config.performance.printFileSize && compiler.hooks.emit.tapPromise({
|
|
8884
|
+
name: 'rsbuild:file-size',
|
|
8885
|
+
stage: 1 / 0
|
|
8886
|
+
}, async (compilation)=>{
|
|
8887
|
+
fileSizeResults && processAssets && !compilation.errors.length && (fileSizeResults[index] = getFileSizes(fileSize_normalizeConfig(config), compilation, processAssets), await fileSizeResults[index].catch(()=>{}));
|
|
8888
|
+
});
|
|
8889
|
+
});
|
|
8890
|
+
}), api.onAfterBuild(async ({ stats, isFirstCompile })=>{
|
|
8891
|
+
let results = fileSizeResults;
|
|
8892
|
+
fileSizeResults = void 0, processAssets = void 0;
|
|
8757
8893
|
let { hasErrors } = context.buildState;
|
|
8758
|
-
if (!stats || hasErrors || !isFirstCompile) return;
|
|
8759
|
-
let environments = context.environmentList.filter(({
|
|
8894
|
+
if (!stats || hasErrors || !isFirstCompile || !results) return;
|
|
8895
|
+
let environments = context.environmentList.filter(({ index })=>void 0 !== results[index]);
|
|
8760
8896
|
if (!environments.length) return;
|
|
8761
8897
|
let showDiff = environments.some((environment)=>{
|
|
8762
8898
|
let { printFileSize } = environment.config.performance;
|
|
8763
8899
|
return 'object' == typeof printFileSize && !!printFileSize.diff;
|
|
8764
8900
|
}), { configFile } = api.context, snapshotHash = showDiff && configFile ? await helpers_hash(configFile) : '', snapshotPath = showDiff ? getSnapshotPath(api.context.cachePath, snapshotHash) : '', prevSnapshots = showDiff ? await loadPrevSnapshots(snapshotPath) : null, nextSnapshots = {}, logs = await Promise.all(environments.map(async ({ name, index, config, distPath })=>{
|
|
8765
|
-
let
|
|
8766
|
-
let { printFileSize } = config.performance, defaultConfig = {
|
|
8767
|
-
total: !0,
|
|
8768
|
-
detail: !0,
|
|
8769
|
-
diff: !1,
|
|
8770
|
-
compressed: 'node' !== config.output.target
|
|
8771
|
-
};
|
|
8772
|
-
return !0 === printFileSize ? defaultConfig : {
|
|
8773
|
-
...defaultConfig,
|
|
8774
|
-
...printFileSize
|
|
8775
|
-
};
|
|
8776
|
-
})(config), statsItem, api.context.rootPath, distPath, name, prevSnapshots, showDiff);
|
|
8901
|
+
let { logs: sizeLogs, snapshot } = printFileSizes(fileSize_normalizeConfig(config), await results[index], api.context.rootPath, distPath, name, prevSnapshots, showDiff);
|
|
8777
8902
|
return snapshot && (nextSnapshots[name] = snapshot), sizeLogs.join('\n');
|
|
8778
8903
|
})).catch((err)=>{
|
|
8779
8904
|
api.logger.warn('Failed to print file size.'), api.logger.warn(err);
|
|
@@ -9173,17 +9298,36 @@ try {
|
|
|
9173
9298
|
}, updateRules = async (callback, options = {})=>{
|
|
9174
9299
|
options.skipMain || await callback(mainRule, 'main'), await callback(inlineRule, 'inline'), await callback(urlRule, 'url');
|
|
9175
9300
|
}, cssLoaderPath = getCompiledPath('css-loader');
|
|
9176
|
-
|
|
9301
|
+
await updateRules((rule)=>{
|
|
9177
9302
|
rule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath);
|
|
9178
|
-
})
|
|
9303
|
+
});
|
|
9304
|
+
let cssUrlMinimized = !1;
|
|
9305
|
+
if (!1 !== config.tools.lightningcssLoader) {
|
|
9179
9306
|
emitCss && importLoaders.normal++, importLoaders.inline++;
|
|
9180
|
-
let minifyCss = parseMinifyOptions(config)
|
|
9307
|
+
let { minifyCss, cssOptions } = parseMinifyOptions(config), { browserslist } = environment;
|
|
9181
9308
|
if ('node' === target) {
|
|
9182
9309
|
let webEnvironment = Object.values(environments).find((env)=>'web' === env.config.output.target);
|
|
9183
|
-
|
|
9310
|
+
if (webEnvironment) {
|
|
9311
|
+
browserslist = webEnvironment.browserslist;
|
|
9312
|
+
let webMinifyOptions = parseMinifyOptions(webEnvironment.config);
|
|
9313
|
+
minifyCss = webMinifyOptions.minifyCss, cssOptions ??= webMinifyOptions.cssOptions;
|
|
9314
|
+
}
|
|
9184
9315
|
}
|
|
9316
|
+
let cssUrlMinimizerOptions = minifyCss ? ((cssOptions)=>{
|
|
9317
|
+
let options = helpers_castArray(cssOptions), { minimizerOptions, test, include, exclude } = options[0] ?? {};
|
|
9318
|
+
return !(options.length > 1 || [
|
|
9319
|
+
test,
|
|
9320
|
+
include,
|
|
9321
|
+
exclude
|
|
9322
|
+
].some((value)=>void 0 !== value)) && (minimizerOptions ?? {});
|
|
9323
|
+
})(cssOptions) : {};
|
|
9185
9324
|
await updateRules(async (rule, type)=>{
|
|
9186
9325
|
let minify = ('inline' === type || 'url' === type || config.output.injectStyles) && minifyCss, lightningcssOptions = await getLightningCSSLoaderOptions(config, browserslist, minify);
|
|
9326
|
+
if ('url' === type && !0 === lightningcssOptions.minify && !1 !== cssUrlMinimizerOptions) {
|
|
9327
|
+
var loaderOptions;
|
|
9328
|
+
let options;
|
|
9329
|
+
loaderOptions = lightningcssOptions, options = cjs_0_default()(loaderOptions, cssUrlMinimizerOptions), isPlainObject(cssUrlMinimizerOptions.targets) && (options.targets = cssUrlMinimizerOptions.targets), lightningcssOptions = options, cssUrlMinimized = !0;
|
|
9330
|
+
}
|
|
9187
9331
|
rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
|
|
9188
9332
|
}, {
|
|
9189
9333
|
skipMain: !emitCss
|
|
@@ -9225,7 +9369,8 @@ try {
|
|
|
9225
9369
|
let cssUrlFilename = getFilename(config, 'css', isProd), cssUrlPath = config.output.distPath.css;
|
|
9226
9370
|
urlRule.use(CHAIN_ID.USE.CSS_URL).options({
|
|
9227
9371
|
filename: 'function' == typeof cssUrlFilename ? (pathData, assetInfo)=>posix.join(cssUrlPath, cssUrlFilename(pathData, assetInfo)) : posix.join(cssUrlPath, cssUrlFilename),
|
|
9228
|
-
modules: cssLoaderOptions.modules
|
|
9372
|
+
modules: cssLoaderOptions.modules,
|
|
9373
|
+
minimized: cssUrlMinimized
|
|
9229
9374
|
});
|
|
9230
9375
|
let isStringExport = 'string' === cssLoaderOptions.exportType;
|
|
9231
9376
|
if (isStringExport && mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && mainRule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
|
|
@@ -10205,7 +10350,7 @@ let applyServerOptions = (command)=>{
|
|
|
10205
10350
|
};
|
|
10206
10351
|
function setupCommands(argv) {
|
|
10207
10352
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
10208
|
-
cli.version("2.2.
|
|
10353
|
+
cli.version("2.2.13"), 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)', {
|
|
10209
10354
|
default: 'auto'
|
|
10210
10355
|
}).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', {
|
|
10211
10356
|
type: [
|
|
@@ -10270,7 +10415,7 @@ function setupCommands(argv) {
|
|
|
10270
10415
|
}
|
|
10271
10416
|
function showGreeting() {
|
|
10272
10417
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10273
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.2.
|
|
10418
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.2.13\n`);
|
|
10274
10419
|
}
|
|
10275
10420
|
function setupLogLevel(argv) {
|
|
10276
10421
|
if (argv.length <= 3) return;
|
|
@@ -10292,5 +10437,5 @@ function runCLI({ argv = process.argv } = {}) {
|
|
|
10292
10437
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10293
10438
|
}
|
|
10294
10439
|
}
|
|
10295
|
-
let src_version = "2.2.
|
|
10440
|
+
let src_version = "2.2.13";
|
|
10296
10441
|
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 };
|