@rsbuild/core 1.0.11 → 1.0.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 +20 -20
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +8 -8
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/index.cjs +122 -104
- package/dist/index.js +112 -94
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3830,9 +3830,8 @@ var init_helpers = __esm({
|
|
|
3830
3830
|
return DEFAULT_ASSET_PREFIX;
|
|
3831
3831
|
};
|
|
3832
3832
|
urlJoin = (base, path21) => {
|
|
3833
|
-
const
|
|
3834
|
-
|
|
3835
|
-
return fullUrl.toString();
|
|
3833
|
+
const [urlProtocol, baseUrl] = base.split("://");
|
|
3834
|
+
return `${urlProtocol}://${import_node_path4.posix.join(baseUrl, path21)}`;
|
|
3836
3835
|
};
|
|
3837
3836
|
canParse = (url2) => {
|
|
3838
3837
|
try {
|
|
@@ -6005,7 +6004,7 @@ async function createContext(options, userConfig, bundlerType) {
|
|
|
6005
6004
|
const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
|
|
6006
6005
|
const cachePath = (0, import_node_path10.join)(rootPath, "node_modules", ".cache");
|
|
6007
6006
|
return {
|
|
6008
|
-
version: "1.0.
|
|
6007
|
+
version: "1.0.13",
|
|
6009
6008
|
rootPath,
|
|
6010
6009
|
distPath: "",
|
|
6011
6010
|
cachePath,
|
|
@@ -6562,13 +6561,24 @@ async function generateRspackConfig({
|
|
|
6562
6561
|
rspackConfig,
|
|
6563
6562
|
await getConfigUtils(rspackConfig, chainUtils)
|
|
6564
6563
|
);
|
|
6564
|
+
if (rspackConfig.plugins) {
|
|
6565
|
+
for (const plugin of rspackConfig.plugins) {
|
|
6566
|
+
if (plugin && plugin.apply === void 0 && "name" in plugin && "setup" in plugin) {
|
|
6567
|
+
const name = import_picocolors7.default.bold(import_picocolors7.default.yellow(plugin.name));
|
|
6568
|
+
throw new Error(
|
|
6569
|
+
`${name} appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`
|
|
6570
|
+
);
|
|
6571
|
+
}
|
|
6572
|
+
}
|
|
6573
|
+
}
|
|
6565
6574
|
return rspackConfig;
|
|
6566
6575
|
}
|
|
6567
|
-
var import_core2;
|
|
6576
|
+
var import_core2, import_picocolors7;
|
|
6568
6577
|
var init_rspackConfig = __esm({
|
|
6569
6578
|
"src/provider/rspackConfig.ts"() {
|
|
6570
6579
|
"use strict";
|
|
6571
6580
|
import_core2 = require("@rspack/core");
|
|
6581
|
+
import_picocolors7 = __toESM(require("../compiled/picocolors/index.js"));
|
|
6572
6582
|
init_dist2();
|
|
6573
6583
|
init_configChain();
|
|
6574
6584
|
init_helpers();
|
|
@@ -6694,11 +6704,11 @@ async function initConfigs({
|
|
|
6694
6704
|
rspackConfigs
|
|
6695
6705
|
};
|
|
6696
6706
|
}
|
|
6697
|
-
var
|
|
6707
|
+
var import_picocolors8, initEnvironmentConfigs;
|
|
6698
6708
|
var init_initConfigs = __esm({
|
|
6699
6709
|
"src/provider/initConfigs.ts"() {
|
|
6700
6710
|
"use strict";
|
|
6701
|
-
|
|
6711
|
+
import_picocolors8 = __toESM(require("../compiled/picocolors/index.js"));
|
|
6702
6712
|
init_config();
|
|
6703
6713
|
init_constants();
|
|
6704
6714
|
init_createContext();
|
|
@@ -6750,7 +6760,7 @@ var init_initConfigs = __esm({
|
|
|
6750
6760
|
);
|
|
6751
6761
|
if (!Object.keys(resolvedEnvironments).length) {
|
|
6752
6762
|
throw new Error(
|
|
6753
|
-
`The current build is specified to run only in the ${
|
|
6763
|
+
`The current build is specified to run only in the ${import_picocolors8.default.yellow(specifiedEnvironments?.join(","))} environment, but the configuration of the specified environment was not found.`
|
|
6754
6764
|
);
|
|
6755
6765
|
}
|
|
6756
6766
|
return resolvedEnvironments;
|
|
@@ -6758,7 +6768,7 @@ var init_initConfigs = __esm({
|
|
|
6758
6768
|
const defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
|
|
6759
6769
|
if (!isEnvironmentEnabled(defaultEnvironmentName)) {
|
|
6760
6770
|
throw new Error(
|
|
6761
|
-
`The current build is specified to run only in the ${
|
|
6771
|
+
`The current build is specified to run only in the ${import_picocolors8.default.yellow(specifiedEnvironments?.join(","))} environment, but the configuration of the specified environment was not found.`
|
|
6762
6772
|
);
|
|
6763
6773
|
}
|
|
6764
6774
|
return {
|
|
@@ -6786,7 +6796,7 @@ async function createCompiler(options) {
|
|
|
6786
6796
|
});
|
|
6787
6797
|
if (!await isSatisfyRspackVersion(import_core3.rspack.rspackVersion)) {
|
|
6788
6798
|
throw new Error(
|
|
6789
|
-
`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${
|
|
6799
|
+
`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${import_picocolors9.default.green(
|
|
6790
6800
|
rspackMinVersion
|
|
6791
6801
|
)}`
|
|
6792
6802
|
);
|
|
@@ -6803,7 +6813,7 @@ async function createCompiler(options) {
|
|
|
6803
6813
|
compiler.hooks.watchRun.tap("rsbuild:compiling", () => {
|
|
6804
6814
|
logRspackVersion();
|
|
6805
6815
|
if (!isCompiling) {
|
|
6806
|
-
import_rslog.logger.start("
|
|
6816
|
+
import_rslog.logger.start("Building...");
|
|
6807
6817
|
}
|
|
6808
6818
|
isCompiling = true;
|
|
6809
6819
|
});
|
|
@@ -6823,8 +6833,8 @@ async function createCompiler(options) {
|
|
|
6823
6833
|
if (c.time) {
|
|
6824
6834
|
const time = prettyTime(c.time / 1e3);
|
|
6825
6835
|
const { name } = rspackConfigs[index];
|
|
6826
|
-
const suffix = name ?
|
|
6827
|
-
import_rslog.logger.ready(`
|
|
6836
|
+
const suffix = name ? import_picocolors9.default.gray(` (${name})`) : "";
|
|
6837
|
+
import_rslog.logger.ready(`Built in ${time}${suffix}`);
|
|
6828
6838
|
}
|
|
6829
6839
|
};
|
|
6830
6840
|
const hasErrors = stats.hasErrors();
|
|
@@ -6870,12 +6880,12 @@ async function createCompiler(options) {
|
|
|
6870
6880
|
rspackConfigs
|
|
6871
6881
|
};
|
|
6872
6882
|
}
|
|
6873
|
-
var import_core3,
|
|
6883
|
+
var import_core3, import_picocolors9;
|
|
6874
6884
|
var init_createCompiler = __esm({
|
|
6875
6885
|
"src/provider/createCompiler.ts"() {
|
|
6876
6886
|
"use strict";
|
|
6877
6887
|
import_core3 = require("@rspack/core");
|
|
6878
|
-
|
|
6888
|
+
import_picocolors9 = __toESM(require("../compiled/picocolors/index.js"));
|
|
6879
6889
|
init_helpers();
|
|
6880
6890
|
init_hooks();
|
|
6881
6891
|
init_logger();
|
|
@@ -6894,19 +6904,19 @@ function setupCliShortcuts({
|
|
|
6894
6904
|
let shortcuts = [
|
|
6895
6905
|
{
|
|
6896
6906
|
key: "c",
|
|
6897
|
-
description: `${
|
|
6907
|
+
description: `${import_picocolors10.default.bold("c + enter")} ${import_picocolors10.default.dim("clear console")}`,
|
|
6898
6908
|
action: () => {
|
|
6899
6909
|
console.clear();
|
|
6900
6910
|
}
|
|
6901
6911
|
},
|
|
6902
6912
|
{
|
|
6903
6913
|
key: "o",
|
|
6904
|
-
description: `${
|
|
6914
|
+
description: `${import_picocolors10.default.bold("o + enter")} ${import_picocolors10.default.dim("open in browser")}`,
|
|
6905
6915
|
action: openPage
|
|
6906
6916
|
},
|
|
6907
6917
|
{
|
|
6908
6918
|
key: "q",
|
|
6909
|
-
description: `${
|
|
6919
|
+
description: `${import_picocolors10.default.bold("q + enter")} ${import_picocolors10.default.dim("quit process")}`,
|
|
6910
6920
|
action: async () => {
|
|
6911
6921
|
try {
|
|
6912
6922
|
await closeServer();
|
|
@@ -6917,12 +6927,12 @@ function setupCliShortcuts({
|
|
|
6917
6927
|
},
|
|
6918
6928
|
restartServer ? {
|
|
6919
6929
|
key: "r",
|
|
6920
|
-
description: `${
|
|
6930
|
+
description: `${import_picocolors10.default.bold("r + enter")} ${import_picocolors10.default.dim("restart server")}`,
|
|
6921
6931
|
action: restartServer
|
|
6922
6932
|
} : null,
|
|
6923
6933
|
{
|
|
6924
6934
|
key: "u",
|
|
6925
|
-
description: `${
|
|
6935
|
+
description: `${import_picocolors10.default.bold("u + enter")} ${import_picocolors10.default.dim("show urls")}`,
|
|
6926
6936
|
action: printUrls
|
|
6927
6937
|
}
|
|
6928
6938
|
].filter(Boolean);
|
|
@@ -6933,7 +6943,7 @@ function setupCliShortcuts({
|
|
|
6933
6943
|
}
|
|
6934
6944
|
}
|
|
6935
6945
|
import_rslog.logger.log(
|
|
6936
|
-
` ➜ ${
|
|
6946
|
+
` ➜ ${import_picocolors10.default.dim("press")} ${import_picocolors10.default.bold("h + enter")} ${import_picocolors10.default.dim("to show shortcuts")}
|
|
6937
6947
|
`
|
|
6938
6948
|
);
|
|
6939
6949
|
const rl = import_node_readline.default.createInterface({
|
|
@@ -6942,7 +6952,7 @@ function setupCliShortcuts({
|
|
|
6942
6952
|
rl.on("line", (input) => {
|
|
6943
6953
|
if (input === "h") {
|
|
6944
6954
|
let message = `
|
|
6945
|
-
${
|
|
6955
|
+
${import_picocolors10.default.bold(import_picocolors10.default.blue("Shortcuts:"))}
|
|
6946
6956
|
`;
|
|
6947
6957
|
for (const shortcut of shortcuts) {
|
|
6948
6958
|
message += ` ${shortcut.description}
|
|
@@ -6961,12 +6971,12 @@ function setupCliShortcuts({
|
|
|
6961
6971
|
rl.close();
|
|
6962
6972
|
});
|
|
6963
6973
|
}
|
|
6964
|
-
var import_node_readline,
|
|
6974
|
+
var import_node_readline, import_picocolors10, isCliShortcutsEnabled;
|
|
6965
6975
|
var init_cliShortcuts = __esm({
|
|
6966
6976
|
"src/server/cliShortcuts.ts"() {
|
|
6967
6977
|
"use strict";
|
|
6968
6978
|
import_node_readline = __toESM(require("readline"));
|
|
6969
|
-
|
|
6979
|
+
import_picocolors10 = __toESM(require("../compiled/picocolors/index.js"));
|
|
6970
6980
|
init_logger();
|
|
6971
6981
|
init_restart();
|
|
6972
6982
|
isCliShortcutsEnabled = (devConfig) => devConfig.cliShortcuts && process.stdin.isTTY && !process.env.CI;
|
|
@@ -7397,8 +7407,8 @@ function getURLMessages(urls, routes) {
|
|
|
7397
7407
|
if (routes.length === 1) {
|
|
7398
7408
|
return urls.map(({ label, url: url2 }) => {
|
|
7399
7409
|
const pathname = normalizeUrl(`${url2}${routes[0].pathname}`);
|
|
7400
|
-
const prefix = `➜ ${
|
|
7401
|
-
return ` ${prefix}${
|
|
7410
|
+
const prefix = `➜ ${import_picocolors11.default.dim(label.padEnd(10))}`;
|
|
7411
|
+
return ` ${prefix}${import_picocolors11.default.cyan(pathname)}
|
|
7402
7412
|
`;
|
|
7403
7413
|
}).join("");
|
|
7404
7414
|
}
|
|
@@ -7411,9 +7421,9 @@ function getURLMessages(urls, routes) {
|
|
|
7411
7421
|
message += ` ${`➜ ${label}`}
|
|
7412
7422
|
`;
|
|
7413
7423
|
for (const r of routes) {
|
|
7414
|
-
message += ` ${
|
|
7424
|
+
message += ` ${import_picocolors11.default.dim("-")} ${import_picocolors11.default.dim(
|
|
7415
7425
|
r.entryName.padEnd(maxNameLength + 4)
|
|
7416
|
-
)}${
|
|
7426
|
+
)}${import_picocolors11.default.cyan(normalizeUrl(`${url2}${r.pathname}`))}
|
|
7417
7427
|
`;
|
|
7418
7428
|
}
|
|
7419
7429
|
});
|
|
@@ -7486,14 +7496,14 @@ function getServerTerminator(server) {
|
|
|
7486
7496
|
}
|
|
7487
7497
|
});
|
|
7488
7498
|
}
|
|
7489
|
-
var import_node_net, import_node_os, import_node_path16,
|
|
7499
|
+
var import_node_net, import_node_os, import_node_path16, import_picocolors11, normalizeUrl, formatPrefix, joinUrlSegments, stripBase, getRoutes, formatRoutes, getPort, getServerConfig, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls, COMPILATION_ID_REGEX, getCompilationId;
|
|
7490
7500
|
var init_helper = __esm({
|
|
7491
7501
|
"src/server/helper.ts"() {
|
|
7492
7502
|
"use strict";
|
|
7493
7503
|
import_node_net = __toESM(require("net"));
|
|
7494
7504
|
import_node_os = __toESM(require("os"));
|
|
7495
7505
|
import_node_path16 = require("path");
|
|
7496
|
-
|
|
7506
|
+
import_picocolors11 = __toESM(require("../compiled/picocolors/index.js"));
|
|
7497
7507
|
init_constants();
|
|
7498
7508
|
init_helpers();
|
|
7499
7509
|
init_logger();
|
|
@@ -7604,7 +7614,7 @@ var init_helper = __esm({
|
|
|
7604
7614
|
strictPort: config.server.strictPort || false
|
|
7605
7615
|
});
|
|
7606
7616
|
const https = Boolean(config.server.https) || false;
|
|
7607
|
-
const portTip = port !== originalPort ? `Port ${originalPort} is in use, ${
|
|
7617
|
+
const portTip = port !== originalPort ? `Port ${originalPort} is in use, ${import_picocolors11.default.yellow(`using port ${port}.`)}` : void 0;
|
|
7608
7618
|
return {
|
|
7609
7619
|
port,
|
|
7610
7620
|
host,
|
|
@@ -7703,12 +7713,12 @@ var init_helper = __esm({
|
|
|
7703
7713
|
});
|
|
7704
7714
|
|
|
7705
7715
|
// src/server/middlewares.ts
|
|
7706
|
-
var import_node_path17,
|
|
7716
|
+
var import_node_path17, import_picocolors12, faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, isFileExists2, maybeHTMLRequest, postfixRE, getUrlPathname, getHtmlCompletionMiddleware, getBaseMiddleware, getHtmlFallbackMiddleware;
|
|
7707
7717
|
var init_middlewares = __esm({
|
|
7708
7718
|
"src/server/middlewares.ts"() {
|
|
7709
7719
|
"use strict";
|
|
7710
7720
|
import_node_path17 = __toESM(require("path"));
|
|
7711
|
-
|
|
7721
|
+
import_picocolors12 = __toESM(require("../compiled/picocolors/index.js"));
|
|
7712
7722
|
init_helpers();
|
|
7713
7723
|
init_logger();
|
|
7714
7724
|
init_helper();
|
|
@@ -7722,16 +7732,16 @@ var init_middlewares = __esm({
|
|
|
7722
7732
|
};
|
|
7723
7733
|
getStatusCodeColor = (status) => {
|
|
7724
7734
|
if (status >= 500) {
|
|
7725
|
-
return
|
|
7735
|
+
return import_picocolors12.default.red;
|
|
7726
7736
|
}
|
|
7727
7737
|
if (status >= 400) {
|
|
7728
|
-
return
|
|
7738
|
+
return import_picocolors12.default.yellow;
|
|
7729
7739
|
}
|
|
7730
7740
|
if (status >= 300) {
|
|
7731
|
-
return
|
|
7741
|
+
return import_picocolors12.default.cyan;
|
|
7732
7742
|
}
|
|
7733
7743
|
if (status >= 200) {
|
|
7734
|
-
return
|
|
7744
|
+
return import_picocolors12.default.green;
|
|
7735
7745
|
}
|
|
7736
7746
|
return (res) => res;
|
|
7737
7747
|
};
|
|
@@ -7747,7 +7757,7 @@ var init_middlewares = __esm({
|
|
|
7747
7757
|
const endAt = process.hrtime();
|
|
7748
7758
|
const totalTime = (endAt[0] - _startAt[0]) * 1e3 + (endAt[1] - _startAt[1]) * 1e-6;
|
|
7749
7759
|
import_rslog.logger.debug(
|
|
7750
|
-
`${statusColor(status)} ${method} ${
|
|
7760
|
+
`${statusColor(status)} ${method} ${import_picocolors12.default.gray(url2)} ${import_picocolors12.default.gray(
|
|
7751
7761
|
`${totalTime.toFixed(3)} ms`
|
|
7752
7762
|
)}`
|
|
7753
7763
|
);
|
|
@@ -7855,8 +7865,8 @@ var init_middlewares = __esm({
|
|
|
7855
7865
|
const newUrl = "/index.html";
|
|
7856
7866
|
if (import_rslog.logger.level === "verbose") {
|
|
7857
7867
|
import_rslog.logger.debug(
|
|
7858
|
-
`${req.method} ${
|
|
7859
|
-
`${req.url} ${
|
|
7868
|
+
`${req.method} ${import_picocolors12.default.gray(
|
|
7869
|
+
`${req.url} ${import_picocolors12.default.yellow("fallback")} to ${newUrl}`
|
|
7860
7870
|
)}`
|
|
7861
7871
|
);
|
|
7862
7872
|
}
|
|
@@ -9331,11 +9341,11 @@ var entry_exports = {};
|
|
|
9331
9341
|
__export(entry_exports, {
|
|
9332
9342
|
pluginEntry: () => pluginEntry
|
|
9333
9343
|
});
|
|
9334
|
-
var
|
|
9344
|
+
var import_picocolors13, pluginEntry;
|
|
9335
9345
|
var init_entry = __esm({
|
|
9336
9346
|
"src/plugins/entry.ts"() {
|
|
9337
9347
|
"use strict";
|
|
9338
|
-
|
|
9348
|
+
import_picocolors13 = __toESM(require("../compiled/picocolors/index.js"));
|
|
9339
9349
|
init_helpers();
|
|
9340
9350
|
pluginEntry = () => ({
|
|
9341
9351
|
name: "rsbuild:entry",
|
|
@@ -9364,9 +9374,9 @@ var init_entry = __esm({
|
|
|
9364
9374
|
api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
|
|
9365
9375
|
if (bundlerConfigs.every((config) => !config.entry)) {
|
|
9366
9376
|
throw new Error(
|
|
9367
|
-
`Could not find any entry module, please make sure that ${
|
|
9377
|
+
`Could not find any entry module, please make sure that ${import_picocolors13.default.cyan(
|
|
9368
9378
|
"src/index.(ts|js|tsx|jsx|mjs|cjs)"
|
|
9369
|
-
)} exists, or customize entry through the ${
|
|
9379
|
+
)} exists, or customize entry through the ${import_picocolors13.default.cyan(
|
|
9370
9380
|
"source.entry"
|
|
9371
9381
|
)} configuration.`
|
|
9372
9382
|
);
|
|
@@ -9601,7 +9611,7 @@ async function applyCSSRule({
|
|
|
9601
9611
|
rule.merge({ sideEffects: true });
|
|
9602
9612
|
rule.resolve.preferRelative(true);
|
|
9603
9613
|
}
|
|
9604
|
-
var import_node_path21, import_deepmerge2, isUseCssExtract, getCSSModulesLocalIdentName, normalizeCssLoaderOptions, userPostcssrcCache, clonePostCSSConfig, getPostcssLoaderOptions, getCSSLoaderOptions, pluginCss;
|
|
9614
|
+
var import_node_path21, import_deepmerge2, isUseCssExtract, getCSSModulesLocalIdentName, normalizeCssLoaderOptions, userPostcssrcCache, clonePostCSSConfig, isPostcssPluginCreator, getPostcssLoaderOptions, getCSSLoaderOptions, pluginCss;
|
|
9605
9615
|
var init_css = __esm({
|
|
9606
9616
|
"src/plugins/css.ts"() {
|
|
9607
9617
|
"use strict";
|
|
@@ -9642,6 +9652,7 @@ var init_css = __esm({
|
|
|
9642
9652
|
...config,
|
|
9643
9653
|
plugins: config.plugins ? [...config.plugins] : void 0
|
|
9644
9654
|
});
|
|
9655
|
+
isPostcssPluginCreator = (plugin) => typeof plugin === "function" && plugin.postcss === true;
|
|
9645
9656
|
getPostcssLoaderOptions = async ({
|
|
9646
9657
|
config,
|
|
9647
9658
|
root
|
|
@@ -9663,17 +9674,21 @@ var init_css = __esm({
|
|
|
9663
9674
|
postcssOptions: userPostcssConfig,
|
|
9664
9675
|
sourceMap: config.output.sourceMap.css
|
|
9665
9676
|
};
|
|
9666
|
-
const
|
|
9677
|
+
const merged = reduceConfigsWithContext({
|
|
9667
9678
|
initial: defaultPostcssConfig,
|
|
9668
9679
|
config: config.tools.postcss,
|
|
9669
9680
|
ctx: utils
|
|
9670
9681
|
});
|
|
9682
|
+
merged.postcssOptions ||= {};
|
|
9683
|
+
merged.postcssOptions.plugins ||= [];
|
|
9671
9684
|
if (extraPlugins.length) {
|
|
9672
|
-
|
|
9685
|
+
merged.postcssOptions.plugins.push(...extraPlugins);
|
|
9673
9686
|
}
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9687
|
+
merged.postcssOptions.plugins = merged.postcssOptions.plugins.map(
|
|
9688
|
+
(plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
|
|
9689
|
+
);
|
|
9690
|
+
merged.postcssOptions.config = false;
|
|
9691
|
+
return merged;
|
|
9677
9692
|
};
|
|
9678
9693
|
getCSSLoaderOptions = ({
|
|
9679
9694
|
config,
|
|
@@ -9929,11 +9944,11 @@ async function gzipSize(input) {
|
|
|
9929
9944
|
const data = await gzip(input);
|
|
9930
9945
|
return data.length;
|
|
9931
9946
|
}
|
|
9932
|
-
function getHeader(longestFileLength, longestLabelLength, options) {
|
|
9947
|
+
function getHeader(longestFileLength, longestLabelLength, options, environmentName) {
|
|
9933
9948
|
const longestLengths = [longestFileLength, longestLabelLength];
|
|
9934
|
-
const rowTypes = [
|
|
9949
|
+
const rowTypes = [`File (${environmentName})`, "Size"];
|
|
9935
9950
|
if (options.compressed) {
|
|
9936
|
-
rowTypes.push("
|
|
9951
|
+
rowTypes.push("Gzip");
|
|
9937
9952
|
}
|
|
9938
9953
|
const headerRow = rowTypes.reduce((prev, cur, index) => {
|
|
9939
9954
|
const length = longestLengths[index];
|
|
@@ -9943,9 +9958,9 @@ function getHeader(longestFileLength, longestLabelLength, options) {
|
|
|
9943
9958
|
}
|
|
9944
9959
|
return `${prev + curLabel} `;
|
|
9945
9960
|
}, " ");
|
|
9946
|
-
return
|
|
9961
|
+
return import_picocolors14.default.blue(headerRow);
|
|
9947
9962
|
}
|
|
9948
|
-
async function printFileSizes(options, stats, rootPath) {
|
|
9963
|
+
async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
9949
9964
|
const logs = [];
|
|
9950
9965
|
if (options.detail === false && options.total === false) {
|
|
9951
9966
|
return logs;
|
|
@@ -9992,13 +10007,21 @@ async function printFileSizes(options, stats, rootPath) {
|
|
|
9992
10007
|
if (assets.length === 0) {
|
|
9993
10008
|
return logs;
|
|
9994
10009
|
}
|
|
10010
|
+
logs.push("");
|
|
9995
10011
|
assets.sort((a, b) => a.size - b.size);
|
|
9996
10012
|
const longestLabelLength = Math.max(...assets.map((a) => a.sizeLabel.length));
|
|
9997
10013
|
const longestFileLength = Math.max(
|
|
9998
10014
|
...assets.map((a) => (a.folder + import_node_path23.default.sep + a.name).length)
|
|
9999
10015
|
);
|
|
10000
10016
|
if (options.detail !== false) {
|
|
10001
|
-
logs.push(
|
|
10017
|
+
logs.push(
|
|
10018
|
+
getHeader(
|
|
10019
|
+
longestFileLength,
|
|
10020
|
+
longestLabelLength,
|
|
10021
|
+
options,
|
|
10022
|
+
environmentName
|
|
10023
|
+
)
|
|
10024
|
+
);
|
|
10002
10025
|
}
|
|
10003
10026
|
let totalSize = 0;
|
|
10004
10027
|
let totalGzipSize = 0;
|
|
@@ -10016,7 +10039,7 @@ async function printFileSizes(options, stats, rootPath) {
|
|
|
10016
10039
|
const rightPadding = " ".repeat(longestLabelLength - sizeLength);
|
|
10017
10040
|
sizeLabel += rightPadding;
|
|
10018
10041
|
}
|
|
10019
|
-
let fileNameLabel =
|
|
10042
|
+
let fileNameLabel = import_picocolors14.default.dim(asset.folder + import_node_path23.default.sep) + coloringAssetName(asset.name);
|
|
10020
10043
|
if (fileNameLength < longestFileLength) {
|
|
10021
10044
|
const rightPadding = " ".repeat(longestFileLength - fileNameLength);
|
|
10022
10045
|
fileNameLabel += rightPadding;
|
|
@@ -10029,24 +10052,18 @@ async function printFileSizes(options, stats, rootPath) {
|
|
|
10029
10052
|
}
|
|
10030
10053
|
}
|
|
10031
10054
|
if (options.total !== false) {
|
|
10032
|
-
const totalSizeLabel = `${
|
|
10033
|
-
import_picocolors13.default.blue("Total size:")
|
|
10034
|
-
)} ${calcFileSize(totalSize)}`;
|
|
10055
|
+
const totalSizeLabel = `${import_picocolors14.default.blue("Total:")} ${calcFileSize(totalSize)}`;
|
|
10035
10056
|
let log = `
|
|
10036
|
-
${totalSizeLabel}
|
|
10037
|
-
`;
|
|
10057
|
+
${totalSizeLabel}`;
|
|
10038
10058
|
if (options.compressed) {
|
|
10039
|
-
|
|
10040
|
-
import_picocolors13.default.blue("Gzipped size:")
|
|
10041
|
-
)} ${calcFileSize(totalGzipSize)}`;
|
|
10042
|
-
log += ` ${gzippedSizeLabel}
|
|
10043
|
-
`;
|
|
10059
|
+
log += import_picocolors14.default.dim(` (gzip: ${calcFileSize(totalGzipSize)})`);
|
|
10044
10060
|
}
|
|
10061
|
+
log += "\n";
|
|
10045
10062
|
logs.push(log);
|
|
10046
10063
|
}
|
|
10047
10064
|
return logs;
|
|
10048
10065
|
}
|
|
10049
|
-
var import_node_fs7, import_node_path23, import_node_util2, import_node_zlib2,
|
|
10066
|
+
var import_node_fs7, import_node_path23, import_node_util2, import_node_zlib2, import_picocolors14, gzip, filterAsset, getAssetColor, calcFileSize, coloringAssetName, pluginFileSize;
|
|
10050
10067
|
var init_fileSize = __esm({
|
|
10051
10068
|
"src/plugins/fileSize.ts"() {
|
|
10052
10069
|
"use strict";
|
|
@@ -10054,19 +10071,19 @@ var init_fileSize = __esm({
|
|
|
10054
10071
|
import_node_path23 = __toESM(require("path"));
|
|
10055
10072
|
import_node_util2 = require("util");
|
|
10056
10073
|
import_node_zlib2 = __toESM(require("zlib"));
|
|
10057
|
-
|
|
10074
|
+
import_picocolors14 = __toESM(require("../compiled/picocolors/index.js"));
|
|
10058
10075
|
init_constants();
|
|
10059
10076
|
init_logger();
|
|
10060
10077
|
gzip = (0, import_node_util2.promisify)(import_node_zlib2.default.gzip);
|
|
10061
10078
|
filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
|
|
10062
10079
|
getAssetColor = (size) => {
|
|
10063
10080
|
if (size > 300 * 1e3) {
|
|
10064
|
-
return
|
|
10081
|
+
return import_picocolors14.default.red;
|
|
10065
10082
|
}
|
|
10066
10083
|
if (size > 100 * 1e3) {
|
|
10067
|
-
return
|
|
10084
|
+
return import_picocolors14.default.yellow;
|
|
10068
10085
|
}
|
|
10069
|
-
return
|
|
10086
|
+
return import_picocolors14.default.green;
|
|
10070
10087
|
};
|
|
10071
10088
|
calcFileSize = (len) => {
|
|
10072
10089
|
const val = len / 1e3;
|
|
@@ -10074,15 +10091,15 @@ var init_fileSize = __esm({
|
|
|
10074
10091
|
};
|
|
10075
10092
|
coloringAssetName = (assetName) => {
|
|
10076
10093
|
if (JS_REGEX.test(assetName)) {
|
|
10077
|
-
return
|
|
10094
|
+
return import_picocolors14.default.cyan(assetName);
|
|
10078
10095
|
}
|
|
10079
10096
|
if (CSS_REGEX.test(assetName)) {
|
|
10080
|
-
return
|
|
10097
|
+
return import_picocolors14.default.yellow(assetName);
|
|
10081
10098
|
}
|
|
10082
10099
|
if (HTML_REGEX.test(assetName)) {
|
|
10083
|
-
return
|
|
10100
|
+
return import_picocolors14.default.green(assetName);
|
|
10084
10101
|
}
|
|
10085
|
-
return
|
|
10102
|
+
return import_picocolors14.default.magenta(assetName);
|
|
10086
10103
|
};
|
|
10087
10104
|
pluginFileSize = () => ({
|
|
10088
10105
|
name: "rsbuild:file-size",
|
|
@@ -10091,6 +10108,7 @@ var init_fileSize = __esm({
|
|
|
10091
10108
|
if (!stats || stats.hasErrors() || !isFirstCompile) {
|
|
10092
10109
|
return;
|
|
10093
10110
|
}
|
|
10111
|
+
const logs = [];
|
|
10094
10112
|
await Promise.all(
|
|
10095
10113
|
Object.values(environments).map(async (environment, index) => {
|
|
10096
10114
|
const { printFileSize } = environment.config.performance;
|
|
@@ -10107,22 +10125,22 @@ var init_fileSize = __esm({
|
|
|
10107
10125
|
...defaultConfig,
|
|
10108
10126
|
...printFileSize
|
|
10109
10127
|
};
|
|
10110
|
-
const
|
|
10128
|
+
const statsLogs = await printFileSizes(
|
|
10111
10129
|
mergedConfig,
|
|
10112
10130
|
multiStats[index],
|
|
10113
|
-
api.context.rootPath
|
|
10131
|
+
api.context.rootPath,
|
|
10132
|
+
environment.name
|
|
10114
10133
|
);
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
`);
|
|
10118
|
-
for (const log of statsLog) {
|
|
10119
|
-
import_rslog.logger.log(log);
|
|
10134
|
+
if (logs.length) {
|
|
10135
|
+
logs.push(import_picocolors14.default.dim(" -----"));
|
|
10120
10136
|
}
|
|
10137
|
+
logs.push(...statsLogs);
|
|
10121
10138
|
})
|
|
10122
10139
|
).catch((err) => {
|
|
10123
10140
|
import_rslog.logger.warn("Failed to print file size.");
|
|
10124
10141
|
import_rslog.logger.warn(err);
|
|
10125
10142
|
});
|
|
10143
|
+
import_rslog.logger.log(logs.join("\n"));
|
|
10126
10144
|
});
|
|
10127
10145
|
}
|
|
10128
10146
|
});
|
|
@@ -10135,12 +10153,12 @@ __export(cleanOutput_exports, {
|
|
|
10135
10153
|
dedupeCleanPaths: () => dedupeCleanPaths,
|
|
10136
10154
|
pluginCleanOutput: () => pluginCleanOutput
|
|
10137
10155
|
});
|
|
10138
|
-
var import_node_path24,
|
|
10156
|
+
var import_node_path24, import_picocolors15, addTrailingSep, isStrictSubdir, dedupeCleanPaths, pluginCleanOutput;
|
|
10139
10157
|
var init_cleanOutput = __esm({
|
|
10140
10158
|
"src/plugins/cleanOutput.ts"() {
|
|
10141
10159
|
"use strict";
|
|
10142
10160
|
import_node_path24 = require("path");
|
|
10143
|
-
|
|
10161
|
+
import_picocolors15 = __toESM(require("../compiled/picocolors/index.js"));
|
|
10144
10162
|
init_constants();
|
|
10145
10163
|
init_helpers();
|
|
10146
10164
|
init_logger();
|
|
@@ -10183,10 +10201,10 @@ var init_cleanOutput = __esm({
|
|
|
10183
10201
|
"The dist path is not a subdir of root path, Rsbuild will not empty it."
|
|
10184
10202
|
);
|
|
10185
10203
|
import_rslog.logger.warn(
|
|
10186
|
-
`Please set ${
|
|
10204
|
+
`Please set ${import_picocolors15.default.yellow("`output.cleanDistPath`")} config manually.`
|
|
10187
10205
|
);
|
|
10188
|
-
import_rslog.logger.warn(`Current root path: ${
|
|
10189
|
-
import_rslog.logger.warn(`Current dist path: ${
|
|
10206
|
+
import_rslog.logger.warn(`Current root path: ${import_picocolors15.default.dim(rootPath)}`);
|
|
10207
|
+
import_rslog.logger.warn(`Current dist path: ${import_picocolors15.default.dim(distPath)}`);
|
|
10190
10208
|
}
|
|
10191
10209
|
}
|
|
10192
10210
|
if (cleanDistPath) {
|
|
@@ -10573,7 +10591,7 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
10573
10591
|
if (!existTemplatePath.has(absolutePath)) {
|
|
10574
10592
|
if (!await isFileExists(absolutePath)) {
|
|
10575
10593
|
throw new Error(
|
|
10576
|
-
`Failed to resolve HTML template, please check if the file exists: ${
|
|
10594
|
+
`Failed to resolve HTML template, please check if the file exists: ${import_picocolors16.default.cyan(
|
|
10577
10595
|
absolutePath
|
|
10578
10596
|
)}`
|
|
10579
10597
|
);
|
|
@@ -10659,13 +10677,13 @@ function getChunks(entryName, entryValue) {
|
|
|
10659
10677
|
}
|
|
10660
10678
|
return chunks;
|
|
10661
10679
|
}
|
|
10662
|
-
var import_node_fs8, import_node_path27,
|
|
10680
|
+
var import_node_fs8, import_node_path27, import_picocolors16, getDefaultTemplateContent, existTemplatePath, getTagConfig, pluginHtml;
|
|
10663
10681
|
var init_html = __esm({
|
|
10664
10682
|
"src/plugins/html.ts"() {
|
|
10665
10683
|
"use strict";
|
|
10666
10684
|
import_node_fs8 = __toESM(require("fs"));
|
|
10667
10685
|
import_node_path27 = __toESM(require("path"));
|
|
10668
|
-
|
|
10686
|
+
import_picocolors16 = __toESM(require("../compiled/picocolors/index.js"));
|
|
10669
10687
|
init_dist2();
|
|
10670
10688
|
init_helpers();
|
|
10671
10689
|
getDefaultTemplateContent = (mountId) => `<!doctype html><html><head></head><body><div id="${mountId}"></div></body></html>`;
|
|
@@ -11865,11 +11883,11 @@ var rsdoctor_exports = {};
|
|
|
11865
11883
|
__export(rsdoctor_exports, {
|
|
11866
11884
|
pluginRsdoctor: () => pluginRsdoctor
|
|
11867
11885
|
});
|
|
11868
|
-
var
|
|
11886
|
+
var import_picocolors17, pluginRsdoctor;
|
|
11869
11887
|
var init_rsdoctor = __esm({
|
|
11870
11888
|
"src/plugins/rsdoctor.ts"() {
|
|
11871
11889
|
"use strict";
|
|
11872
|
-
|
|
11890
|
+
import_picocolors17 = __toESM(require("../compiled/picocolors/index.js"));
|
|
11873
11891
|
init_logger();
|
|
11874
11892
|
pluginRsdoctor = () => ({
|
|
11875
11893
|
name: "rsbuild:rsdoctor",
|
|
@@ -11897,7 +11915,7 @@ var init_rsdoctor = __esm({
|
|
|
11897
11915
|
});
|
|
11898
11916
|
} catch (err) {
|
|
11899
11917
|
import_rslog.logger.warn(
|
|
11900
|
-
`\`process.env.RSDOCTOR\` enabled, please install ${
|
|
11918
|
+
`\`process.env.RSDOCTOR\` enabled, please install ${import_picocolors17.default.bold(import_picocolors17.default.yellow(packageName))} package.`
|
|
11901
11919
|
);
|
|
11902
11920
|
return;
|
|
11903
11921
|
}
|
|
@@ -11906,7 +11924,7 @@ var init_rsdoctor = __esm({
|
|
|
11906
11924
|
module2 = await import(packagePath);
|
|
11907
11925
|
} catch (err) {
|
|
11908
11926
|
import_rslog.logger.error(
|
|
11909
|
-
`\`process.env.RSDOCTOR\` enabled, but failed to load ${
|
|
11927
|
+
`\`process.env.RSDOCTOR\` enabled, but failed to load ${import_picocolors17.default.bold(import_picocolors17.default.yellow(packageName))} module.`
|
|
11910
11928
|
);
|
|
11911
11929
|
return;
|
|
11912
11930
|
}
|
|
@@ -11917,7 +11935,7 @@ var init_rsdoctor = __esm({
|
|
|
11917
11935
|
config.plugins ||= [];
|
|
11918
11936
|
config.plugins.push(new module2[pluginName]());
|
|
11919
11937
|
}
|
|
11920
|
-
import_rslog.logger.info(`${
|
|
11938
|
+
import_rslog.logger.info(`${import_picocolors17.default.bold(import_picocolors17.default.yellow(packageName))} enabled.`);
|
|
11921
11939
|
});
|
|
11922
11940
|
}
|
|
11923
11941
|
});
|
|
@@ -13149,7 +13167,7 @@ var init_prodServer = __esm({
|
|
|
13149
13167
|
if (base && base !== "/") {
|
|
13150
13168
|
this.middlewares.use(getBaseMiddleware({ base }));
|
|
13151
13169
|
}
|
|
13152
|
-
this.applyStaticAssetMiddleware();
|
|
13170
|
+
await this.applyStaticAssetMiddleware();
|
|
13153
13171
|
if (historyApiFallback) {
|
|
13154
13172
|
const { default: connectHistoryApiFallback } = await import("../compiled/connect-history-api-fallback/index.js");
|
|
13155
13173
|
const historyApiFallbackMiddleware = connectHistoryApiFallback(
|
|
@@ -13302,14 +13320,14 @@ async function createRsbuild(options = {}) {
|
|
|
13302
13320
|
if (checkDistDir) {
|
|
13303
13321
|
if (!(0, import_node_fs12.existsSync)(distPath)) {
|
|
13304
13322
|
throw new Error(
|
|
13305
|
-
`The output directory ${
|
|
13323
|
+
`The output directory ${import_picocolors18.default.yellow(
|
|
13306
13324
|
distPath
|
|
13307
13325
|
)} does not exist, please build the project before previewing.`
|
|
13308
13326
|
);
|
|
13309
13327
|
}
|
|
13310
13328
|
if (isEmptyDir(distPath)) {
|
|
13311
13329
|
throw new Error(
|
|
13312
|
-
`The output directory ${
|
|
13330
|
+
`The output directory ${import_picocolors18.default.yellow(
|
|
13313
13331
|
distPath
|
|
13314
13332
|
)} is empty, please build the project before previewing.`
|
|
13315
13333
|
);
|
|
@@ -13397,13 +13415,13 @@ async function createRsbuild(options = {}) {
|
|
|
13397
13415
|
}
|
|
13398
13416
|
return rsbuild;
|
|
13399
13417
|
}
|
|
13400
|
-
var import_node_fs12, import_types3,
|
|
13418
|
+
var import_node_fs12, import_types3, import_picocolors18, getRspackProvider;
|
|
13401
13419
|
var init_createRsbuild = __esm({
|
|
13402
13420
|
"src/createRsbuild.ts"() {
|
|
13403
13421
|
"use strict";
|
|
13404
13422
|
import_node_fs12 = require("fs");
|
|
13405
13423
|
import_types3 = require("util/types");
|
|
13406
|
-
|
|
13424
|
+
import_picocolors18 = __toESM(require("../compiled/picocolors/index.js"));
|
|
13407
13425
|
init_createContext();
|
|
13408
13426
|
init_helpers();
|
|
13409
13427
|
init_initPlugins();
|
|
@@ -13523,7 +13541,7 @@ var init_init = __esm({
|
|
|
13523
13541
|
|
|
13524
13542
|
// src/cli/commands.ts
|
|
13525
13543
|
function runCli() {
|
|
13526
|
-
program.name("rsbuild").usage("<command> [options]").version("1.0.
|
|
13544
|
+
program.name("rsbuild").usage("<command> [options]").version("1.0.13");
|
|
13527
13545
|
const devCommand = program.command("dev");
|
|
13528
13546
|
const buildCommand = program.command("build");
|
|
13529
13547
|
const previewCommand = program.command("preview");
|
|
@@ -13632,7 +13650,7 @@ function prepareCli() {
|
|
|
13632
13650
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
13633
13651
|
console.log();
|
|
13634
13652
|
}
|
|
13635
|
-
import_rslog.logger.greet(` ${`Rsbuild v${"1.0.
|
|
13653
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"1.0.13"}`}
|
|
13636
13654
|
`);
|
|
13637
13655
|
}
|
|
13638
13656
|
var import_node_module;
|
|
@@ -13718,7 +13736,7 @@ init_logger();
|
|
|
13718
13736
|
init_mergeConfig();
|
|
13719
13737
|
init_helpers();
|
|
13720
13738
|
init_constants();
|
|
13721
|
-
var version = "1.0.
|
|
13739
|
+
var version = "1.0.13";
|
|
13722
13740
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13723
13741
|
0 && (module.exports = {
|
|
13724
13742
|
PLUGIN_CSS_NAME,
|