@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.js
CHANGED
|
@@ -46,12 +46,12 @@ var __publicField = (obj, key, value) => {
|
|
|
46
46
|
return value;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.60.2_typescript@5.6.
|
|
49
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.60.2_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js
|
|
50
50
|
import path from "path";
|
|
51
51
|
import { fileURLToPath } from "url";
|
|
52
52
|
var getFilename, getDirname, __dirname, __filename;
|
|
53
53
|
var init_esm = __esm({
|
|
54
|
-
"../../node_modules/.pnpm/@modern-js+module-tools@2.60.2_typescript@5.6.
|
|
54
|
+
"../../node_modules/.pnpm/@modern-js+module-tools@2.60.2_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
55
55
|
"use strict";
|
|
56
56
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
57
57
|
getDirname = () => path.dirname(getFilename());
|
|
@@ -3868,9 +3868,8 @@ var init_helpers = __esm({
|
|
|
3868
3868
|
return DEFAULT_ASSET_PREFIX;
|
|
3869
3869
|
};
|
|
3870
3870
|
urlJoin = (base, path22) => {
|
|
3871
|
-
const
|
|
3872
|
-
|
|
3873
|
-
return fullUrl.toString();
|
|
3871
|
+
const [urlProtocol, baseUrl] = base.split("://");
|
|
3872
|
+
return `${urlProtocol}://${posix.join(baseUrl, path22)}`;
|
|
3874
3873
|
};
|
|
3875
3874
|
canParse = (url2) => {
|
|
3876
3875
|
try {
|
|
@@ -6054,7 +6053,7 @@ async function createContext(options, userConfig, bundlerType) {
|
|
|
6054
6053
|
const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
|
|
6055
6054
|
const cachePath = join6(rootPath, "node_modules", ".cache");
|
|
6056
6055
|
return {
|
|
6057
|
-
version: "1.0.
|
|
6056
|
+
version: "1.0.13",
|
|
6058
6057
|
rootPath,
|
|
6059
6058
|
distPath: "",
|
|
6060
6059
|
cachePath,
|
|
@@ -6512,6 +6511,7 @@ var init_configChain = __esm({
|
|
|
6512
6511
|
|
|
6513
6512
|
// src/provider/rspackConfig.ts
|
|
6514
6513
|
import { rspack as rspack2 } from "@rspack/core";
|
|
6514
|
+
import color7 from "../compiled/picocolors/index.js";
|
|
6515
6515
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
6516
6516
|
logger.debug("modify Rspack config");
|
|
6517
6517
|
let [modifiedConfig] = await context.hooks.modifyRspackConfig.callInEnvironment({
|
|
@@ -6616,6 +6616,16 @@ async function generateRspackConfig({
|
|
|
6616
6616
|
rspackConfig,
|
|
6617
6617
|
await getConfigUtils(rspackConfig, chainUtils)
|
|
6618
6618
|
);
|
|
6619
|
+
if (rspackConfig.plugins) {
|
|
6620
|
+
for (const plugin of rspackConfig.plugins) {
|
|
6621
|
+
if (plugin && plugin.apply === void 0 && "name" in plugin && "setup" in plugin) {
|
|
6622
|
+
const name = color7.bold(color7.yellow(plugin.name));
|
|
6623
|
+
throw new Error(
|
|
6624
|
+
`${name} appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`
|
|
6625
|
+
);
|
|
6626
|
+
}
|
|
6627
|
+
}
|
|
6628
|
+
}
|
|
6619
6629
|
return rspackConfig;
|
|
6620
6630
|
}
|
|
6621
6631
|
var init_rspackConfig = __esm({
|
|
@@ -6631,7 +6641,7 @@ var init_rspackConfig = __esm({
|
|
|
6631
6641
|
});
|
|
6632
6642
|
|
|
6633
6643
|
// src/provider/initConfigs.ts
|
|
6634
|
-
import
|
|
6644
|
+
import color8 from "../compiled/picocolors/index.js";
|
|
6635
6645
|
async function modifyRsbuildConfig(context) {
|
|
6636
6646
|
logger.debug("modify Rsbuild config");
|
|
6637
6647
|
const [modified] = await context.hooks.modifyRsbuildConfig.call(
|
|
@@ -6804,7 +6814,7 @@ var init_initConfigs = __esm({
|
|
|
6804
6814
|
);
|
|
6805
6815
|
if (!Object.keys(resolvedEnvironments).length) {
|
|
6806
6816
|
throw new Error(
|
|
6807
|
-
`The current build is specified to run only in the ${
|
|
6817
|
+
`The current build is specified to run only in the ${color8.yellow(specifiedEnvironments?.join(","))} environment, but the configuration of the specified environment was not found.`
|
|
6808
6818
|
);
|
|
6809
6819
|
}
|
|
6810
6820
|
return resolvedEnvironments;
|
|
@@ -6812,7 +6822,7 @@ var init_initConfigs = __esm({
|
|
|
6812
6822
|
const defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
|
|
6813
6823
|
if (!isEnvironmentEnabled(defaultEnvironmentName)) {
|
|
6814
6824
|
throw new Error(
|
|
6815
|
-
`The current build is specified to run only in the ${
|
|
6825
|
+
`The current build is specified to run only in the ${color8.yellow(specifiedEnvironments?.join(","))} environment, but the configuration of the specified environment was not found.`
|
|
6816
6826
|
);
|
|
6817
6827
|
}
|
|
6818
6828
|
return {
|
|
@@ -6831,7 +6841,7 @@ __export(createCompiler_exports, {
|
|
|
6831
6841
|
createCompiler: () => createCompiler
|
|
6832
6842
|
});
|
|
6833
6843
|
import { rspack as rspack3 } from "@rspack/core";
|
|
6834
|
-
import
|
|
6844
|
+
import color9 from "../compiled/picocolors/index.js";
|
|
6835
6845
|
async function createCompiler(options) {
|
|
6836
6846
|
logger.debug("create compiler");
|
|
6837
6847
|
const { context } = options;
|
|
@@ -6842,7 +6852,7 @@ async function createCompiler(options) {
|
|
|
6842
6852
|
});
|
|
6843
6853
|
if (!await isSatisfyRspackVersion(rspack3.rspackVersion)) {
|
|
6844
6854
|
throw new Error(
|
|
6845
|
-
`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${
|
|
6855
|
+
`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color9.green(
|
|
6846
6856
|
rspackMinVersion
|
|
6847
6857
|
)}`
|
|
6848
6858
|
);
|
|
@@ -6859,7 +6869,7 @@ async function createCompiler(options) {
|
|
|
6859
6869
|
compiler.hooks.watchRun.tap("rsbuild:compiling", () => {
|
|
6860
6870
|
logRspackVersion();
|
|
6861
6871
|
if (!isCompiling) {
|
|
6862
|
-
logger.start("
|
|
6872
|
+
logger.start("Building...");
|
|
6863
6873
|
}
|
|
6864
6874
|
isCompiling = true;
|
|
6865
6875
|
});
|
|
@@ -6879,8 +6889,8 @@ async function createCompiler(options) {
|
|
|
6879
6889
|
if (c.time) {
|
|
6880
6890
|
const time = prettyTime(c.time / 1e3);
|
|
6881
6891
|
const { name } = rspackConfigs[index];
|
|
6882
|
-
const suffix = name ?
|
|
6883
|
-
logger.ready(`
|
|
6892
|
+
const suffix = name ? color9.gray(` (${name})`) : "";
|
|
6893
|
+
logger.ready(`Built in ${time}${suffix}`);
|
|
6884
6894
|
}
|
|
6885
6895
|
};
|
|
6886
6896
|
const hasErrors = stats.hasErrors();
|
|
@@ -6939,7 +6949,7 @@ var init_createCompiler = __esm({
|
|
|
6939
6949
|
|
|
6940
6950
|
// src/server/cliShortcuts.ts
|
|
6941
6951
|
import readline from "readline";
|
|
6942
|
-
import
|
|
6952
|
+
import color10 from "../compiled/picocolors/index.js";
|
|
6943
6953
|
function setupCliShortcuts({
|
|
6944
6954
|
openPage,
|
|
6945
6955
|
closeServer,
|
|
@@ -6950,19 +6960,19 @@ function setupCliShortcuts({
|
|
|
6950
6960
|
let shortcuts = [
|
|
6951
6961
|
{
|
|
6952
6962
|
key: "c",
|
|
6953
|
-
description: `${
|
|
6963
|
+
description: `${color10.bold("c + enter")} ${color10.dim("clear console")}`,
|
|
6954
6964
|
action: () => {
|
|
6955
6965
|
console.clear();
|
|
6956
6966
|
}
|
|
6957
6967
|
},
|
|
6958
6968
|
{
|
|
6959
6969
|
key: "o",
|
|
6960
|
-
description: `${
|
|
6970
|
+
description: `${color10.bold("o + enter")} ${color10.dim("open in browser")}`,
|
|
6961
6971
|
action: openPage
|
|
6962
6972
|
},
|
|
6963
6973
|
{
|
|
6964
6974
|
key: "q",
|
|
6965
|
-
description: `${
|
|
6975
|
+
description: `${color10.bold("q + enter")} ${color10.dim("quit process")}`,
|
|
6966
6976
|
action: async () => {
|
|
6967
6977
|
try {
|
|
6968
6978
|
await closeServer();
|
|
@@ -6973,12 +6983,12 @@ function setupCliShortcuts({
|
|
|
6973
6983
|
},
|
|
6974
6984
|
restartServer ? {
|
|
6975
6985
|
key: "r",
|
|
6976
|
-
description: `${
|
|
6986
|
+
description: `${color10.bold("r + enter")} ${color10.dim("restart server")}`,
|
|
6977
6987
|
action: restartServer
|
|
6978
6988
|
} : null,
|
|
6979
6989
|
{
|
|
6980
6990
|
key: "u",
|
|
6981
|
-
description: `${
|
|
6991
|
+
description: `${color10.bold("u + enter")} ${color10.dim("show urls")}`,
|
|
6982
6992
|
action: printUrls
|
|
6983
6993
|
}
|
|
6984
6994
|
].filter(Boolean);
|
|
@@ -6989,7 +6999,7 @@ function setupCliShortcuts({
|
|
|
6989
6999
|
}
|
|
6990
7000
|
}
|
|
6991
7001
|
logger.log(
|
|
6992
|
-
` ➜ ${
|
|
7002
|
+
` ➜ ${color10.dim("press")} ${color10.bold("h + enter")} ${color10.dim("to show shortcuts")}
|
|
6993
7003
|
`
|
|
6994
7004
|
);
|
|
6995
7005
|
const rl = readline.createInterface({
|
|
@@ -6998,7 +7008,7 @@ function setupCliShortcuts({
|
|
|
6998
7008
|
rl.on("line", (input) => {
|
|
6999
7009
|
if (input === "h") {
|
|
7000
7010
|
let message = `
|
|
7001
|
-
${
|
|
7011
|
+
${color10.bold(color10.blue("Shortcuts:"))}
|
|
7002
7012
|
`;
|
|
7003
7013
|
for (const shortcut of shortcuts) {
|
|
7004
7014
|
message += ` ${shortcut.description}
|
|
@@ -7458,13 +7468,13 @@ var init_environment = __esm({
|
|
|
7458
7468
|
import net from "net";
|
|
7459
7469
|
import os from "os";
|
|
7460
7470
|
import { posix as posix3 } from "path";
|
|
7461
|
-
import
|
|
7471
|
+
import color11 from "../compiled/picocolors/index.js";
|
|
7462
7472
|
function getURLMessages(urls, routes) {
|
|
7463
7473
|
if (routes.length === 1) {
|
|
7464
7474
|
return urls.map(({ label, url: url2 }) => {
|
|
7465
7475
|
const pathname = normalizeUrl(`${url2}${routes[0].pathname}`);
|
|
7466
|
-
const prefix = `➜ ${
|
|
7467
|
-
return ` ${prefix}${
|
|
7476
|
+
const prefix = `➜ ${color11.dim(label.padEnd(10))}`;
|
|
7477
|
+
return ` ${prefix}${color11.cyan(pathname)}
|
|
7468
7478
|
`;
|
|
7469
7479
|
}).join("");
|
|
7470
7480
|
}
|
|
@@ -7477,9 +7487,9 @@ function getURLMessages(urls, routes) {
|
|
|
7477
7487
|
message += ` ${`➜ ${label}`}
|
|
7478
7488
|
`;
|
|
7479
7489
|
for (const r of routes) {
|
|
7480
|
-
message += ` ${
|
|
7490
|
+
message += ` ${color11.dim("-")} ${color11.dim(
|
|
7481
7491
|
r.entryName.padEnd(maxNameLength + 4)
|
|
7482
|
-
)}${
|
|
7492
|
+
)}${color11.cyan(normalizeUrl(`${url2}${r.pathname}`))}
|
|
7483
7493
|
`;
|
|
7484
7494
|
}
|
|
7485
7495
|
});
|
|
@@ -7667,7 +7677,7 @@ var init_helper = __esm({
|
|
|
7667
7677
|
strictPort: config.server.strictPort || false
|
|
7668
7678
|
});
|
|
7669
7679
|
const https = Boolean(config.server.https) || false;
|
|
7670
|
-
const portTip = port !== originalPort ? `Port ${originalPort} is in use, ${
|
|
7680
|
+
const portTip = port !== originalPort ? `Port ${originalPort} is in use, ${color11.yellow(`using port ${port}.`)}` : void 0;
|
|
7671
7681
|
return {
|
|
7672
7682
|
port,
|
|
7673
7683
|
host,
|
|
@@ -7767,7 +7777,7 @@ var init_helper = __esm({
|
|
|
7767
7777
|
|
|
7768
7778
|
// src/server/middlewares.ts
|
|
7769
7779
|
import path8 from "path";
|
|
7770
|
-
import
|
|
7780
|
+
import color12 from "../compiled/picocolors/index.js";
|
|
7771
7781
|
var faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, isFileExists2, maybeHTMLRequest, postfixRE, getUrlPathname, getHtmlCompletionMiddleware, getBaseMiddleware, getHtmlFallbackMiddleware;
|
|
7772
7782
|
var init_middlewares = __esm({
|
|
7773
7783
|
"src/server/middlewares.ts"() {
|
|
@@ -7786,16 +7796,16 @@ var init_middlewares = __esm({
|
|
|
7786
7796
|
};
|
|
7787
7797
|
getStatusCodeColor = (status) => {
|
|
7788
7798
|
if (status >= 500) {
|
|
7789
|
-
return
|
|
7799
|
+
return color12.red;
|
|
7790
7800
|
}
|
|
7791
7801
|
if (status >= 400) {
|
|
7792
|
-
return
|
|
7802
|
+
return color12.yellow;
|
|
7793
7803
|
}
|
|
7794
7804
|
if (status >= 300) {
|
|
7795
|
-
return
|
|
7805
|
+
return color12.cyan;
|
|
7796
7806
|
}
|
|
7797
7807
|
if (status >= 200) {
|
|
7798
|
-
return
|
|
7808
|
+
return color12.green;
|
|
7799
7809
|
}
|
|
7800
7810
|
return (res) => res;
|
|
7801
7811
|
};
|
|
@@ -7811,7 +7821,7 @@ var init_middlewares = __esm({
|
|
|
7811
7821
|
const endAt = process.hrtime();
|
|
7812
7822
|
const totalTime = (endAt[0] - _startAt[0]) * 1e3 + (endAt[1] - _startAt[1]) * 1e-6;
|
|
7813
7823
|
logger.debug(
|
|
7814
|
-
`${statusColor(status)} ${method} ${
|
|
7824
|
+
`${statusColor(status)} ${method} ${color12.gray(url2)} ${color12.gray(
|
|
7815
7825
|
`${totalTime.toFixed(3)} ms`
|
|
7816
7826
|
)}`
|
|
7817
7827
|
);
|
|
@@ -7919,8 +7929,8 @@ var init_middlewares = __esm({
|
|
|
7919
7929
|
const newUrl = "/index.html";
|
|
7920
7930
|
if (logger.level === "verbose") {
|
|
7921
7931
|
logger.debug(
|
|
7922
|
-
`${req.method} ${
|
|
7923
|
-
`${req.url} ${
|
|
7932
|
+
`${req.method} ${color12.gray(
|
|
7933
|
+
`${req.url} ${color12.yellow("fallback")} to ${newUrl}`
|
|
7924
7934
|
)}`
|
|
7925
7935
|
);
|
|
7926
7936
|
}
|
|
@@ -9408,7 +9418,7 @@ var entry_exports = {};
|
|
|
9408
9418
|
__export(entry_exports, {
|
|
9409
9419
|
pluginEntry: () => pluginEntry
|
|
9410
9420
|
});
|
|
9411
|
-
import
|
|
9421
|
+
import color13 from "../compiled/picocolors/index.js";
|
|
9412
9422
|
var pluginEntry;
|
|
9413
9423
|
var init_entry = __esm({
|
|
9414
9424
|
"src/plugins/entry.ts"() {
|
|
@@ -9442,9 +9452,9 @@ var init_entry = __esm({
|
|
|
9442
9452
|
api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
|
|
9443
9453
|
if (bundlerConfigs.every((config) => !config.entry)) {
|
|
9444
9454
|
throw new Error(
|
|
9445
|
-
`Could not find any entry module, please make sure that ${
|
|
9455
|
+
`Could not find any entry module, please make sure that ${color13.cyan(
|
|
9446
9456
|
"src/index.(ts|js|tsx|jsx|mjs|cjs)"
|
|
9447
|
-
)} exists, or customize entry through the ${
|
|
9457
|
+
)} exists, or customize entry through the ${color13.cyan(
|
|
9448
9458
|
"source.entry"
|
|
9449
9459
|
)} configuration.`
|
|
9450
9460
|
);
|
|
@@ -9682,7 +9692,7 @@ async function applyCSSRule({
|
|
|
9682
9692
|
rule.merge({ sideEffects: true });
|
|
9683
9693
|
rule.resolve.preferRelative(true);
|
|
9684
9694
|
}
|
|
9685
|
-
var import_deepmerge2, isUseCssExtract, getCSSModulesLocalIdentName, normalizeCssLoaderOptions, userPostcssrcCache, clonePostCSSConfig, getPostcssLoaderOptions, getCSSLoaderOptions, pluginCss;
|
|
9695
|
+
var import_deepmerge2, isUseCssExtract, getCSSModulesLocalIdentName, normalizeCssLoaderOptions, userPostcssrcCache, clonePostCSSConfig, isPostcssPluginCreator, getPostcssLoaderOptions, getCSSLoaderOptions, pluginCss;
|
|
9686
9696
|
var init_css = __esm({
|
|
9687
9697
|
"src/plugins/css.ts"() {
|
|
9688
9698
|
"use strict";
|
|
@@ -9723,6 +9733,7 @@ var init_css = __esm({
|
|
|
9723
9733
|
...config,
|
|
9724
9734
|
plugins: config.plugins ? [...config.plugins] : void 0
|
|
9725
9735
|
});
|
|
9736
|
+
isPostcssPluginCreator = (plugin) => typeof plugin === "function" && plugin.postcss === true;
|
|
9726
9737
|
getPostcssLoaderOptions = async ({
|
|
9727
9738
|
config,
|
|
9728
9739
|
root
|
|
@@ -9744,17 +9755,21 @@ var init_css = __esm({
|
|
|
9744
9755
|
postcssOptions: userPostcssConfig,
|
|
9745
9756
|
sourceMap: config.output.sourceMap.css
|
|
9746
9757
|
};
|
|
9747
|
-
const
|
|
9758
|
+
const merged = reduceConfigsWithContext({
|
|
9748
9759
|
initial: defaultPostcssConfig,
|
|
9749
9760
|
config: config.tools.postcss,
|
|
9750
9761
|
ctx: utils
|
|
9751
9762
|
});
|
|
9763
|
+
merged.postcssOptions ||= {};
|
|
9764
|
+
merged.postcssOptions.plugins ||= [];
|
|
9752
9765
|
if (extraPlugins.length) {
|
|
9753
|
-
|
|
9766
|
+
merged.postcssOptions.plugins.push(...extraPlugins);
|
|
9754
9767
|
}
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9768
|
+
merged.postcssOptions.plugins = merged.postcssOptions.plugins.map(
|
|
9769
|
+
(plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
|
|
9770
|
+
);
|
|
9771
|
+
merged.postcssOptions.config = false;
|
|
9772
|
+
return merged;
|
|
9758
9773
|
};
|
|
9759
9774
|
getCSSLoaderOptions = ({
|
|
9760
9775
|
config,
|
|
@@ -10012,16 +10027,16 @@ import fs7 from "fs";
|
|
|
10012
10027
|
import path11 from "path";
|
|
10013
10028
|
import { promisify as promisify2 } from "util";
|
|
10014
10029
|
import zlib2 from "zlib";
|
|
10015
|
-
import
|
|
10030
|
+
import color14 from "../compiled/picocolors/index.js";
|
|
10016
10031
|
async function gzipSize(input) {
|
|
10017
10032
|
const data = await gzip(input);
|
|
10018
10033
|
return data.length;
|
|
10019
10034
|
}
|
|
10020
|
-
function getHeader(longestFileLength, longestLabelLength, options) {
|
|
10035
|
+
function getHeader(longestFileLength, longestLabelLength, options, environmentName) {
|
|
10021
10036
|
const longestLengths = [longestFileLength, longestLabelLength];
|
|
10022
|
-
const rowTypes = [
|
|
10037
|
+
const rowTypes = [`File (${environmentName})`, "Size"];
|
|
10023
10038
|
if (options.compressed) {
|
|
10024
|
-
rowTypes.push("
|
|
10039
|
+
rowTypes.push("Gzip");
|
|
10025
10040
|
}
|
|
10026
10041
|
const headerRow = rowTypes.reduce((prev, cur, index) => {
|
|
10027
10042
|
const length = longestLengths[index];
|
|
@@ -10031,9 +10046,9 @@ function getHeader(longestFileLength, longestLabelLength, options) {
|
|
|
10031
10046
|
}
|
|
10032
10047
|
return `${prev + curLabel} `;
|
|
10033
10048
|
}, " ");
|
|
10034
|
-
return
|
|
10049
|
+
return color14.blue(headerRow);
|
|
10035
10050
|
}
|
|
10036
|
-
async function printFileSizes(options, stats, rootPath) {
|
|
10051
|
+
async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
10037
10052
|
const logs = [];
|
|
10038
10053
|
if (options.detail === false && options.total === false) {
|
|
10039
10054
|
return logs;
|
|
@@ -10080,13 +10095,21 @@ async function printFileSizes(options, stats, rootPath) {
|
|
|
10080
10095
|
if (assets.length === 0) {
|
|
10081
10096
|
return logs;
|
|
10082
10097
|
}
|
|
10098
|
+
logs.push("");
|
|
10083
10099
|
assets.sort((a, b) => a.size - b.size);
|
|
10084
10100
|
const longestLabelLength = Math.max(...assets.map((a) => a.sizeLabel.length));
|
|
10085
10101
|
const longestFileLength = Math.max(
|
|
10086
10102
|
...assets.map((a) => (a.folder + path11.sep + a.name).length)
|
|
10087
10103
|
);
|
|
10088
10104
|
if (options.detail !== false) {
|
|
10089
|
-
logs.push(
|
|
10105
|
+
logs.push(
|
|
10106
|
+
getHeader(
|
|
10107
|
+
longestFileLength,
|
|
10108
|
+
longestLabelLength,
|
|
10109
|
+
options,
|
|
10110
|
+
environmentName
|
|
10111
|
+
)
|
|
10112
|
+
);
|
|
10090
10113
|
}
|
|
10091
10114
|
let totalSize = 0;
|
|
10092
10115
|
let totalGzipSize = 0;
|
|
@@ -10104,7 +10127,7 @@ async function printFileSizes(options, stats, rootPath) {
|
|
|
10104
10127
|
const rightPadding = " ".repeat(longestLabelLength - sizeLength);
|
|
10105
10128
|
sizeLabel += rightPadding;
|
|
10106
10129
|
}
|
|
10107
|
-
let fileNameLabel =
|
|
10130
|
+
let fileNameLabel = color14.dim(asset.folder + path11.sep) + coloringAssetName(asset.name);
|
|
10108
10131
|
if (fileNameLength < longestFileLength) {
|
|
10109
10132
|
const rightPadding = " ".repeat(longestFileLength - fileNameLength);
|
|
10110
10133
|
fileNameLabel += rightPadding;
|
|
@@ -10117,19 +10140,13 @@ async function printFileSizes(options, stats, rootPath) {
|
|
|
10117
10140
|
}
|
|
10118
10141
|
}
|
|
10119
10142
|
if (options.total !== false) {
|
|
10120
|
-
const totalSizeLabel = `${
|
|
10121
|
-
color13.blue("Total size:")
|
|
10122
|
-
)} ${calcFileSize(totalSize)}`;
|
|
10143
|
+
const totalSizeLabel = `${color14.blue("Total:")} ${calcFileSize(totalSize)}`;
|
|
10123
10144
|
let log = `
|
|
10124
|
-
${totalSizeLabel}
|
|
10125
|
-
`;
|
|
10145
|
+
${totalSizeLabel}`;
|
|
10126
10146
|
if (options.compressed) {
|
|
10127
|
-
|
|
10128
|
-
color13.blue("Gzipped size:")
|
|
10129
|
-
)} ${calcFileSize(totalGzipSize)}`;
|
|
10130
|
-
log += ` ${gzippedSizeLabel}
|
|
10131
|
-
`;
|
|
10147
|
+
log += color14.dim(` (gzip: ${calcFileSize(totalGzipSize)})`);
|
|
10132
10148
|
}
|
|
10149
|
+
log += "\n";
|
|
10133
10150
|
logs.push(log);
|
|
10134
10151
|
}
|
|
10135
10152
|
return logs;
|
|
@@ -10145,12 +10162,12 @@ var init_fileSize = __esm({
|
|
|
10145
10162
|
filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
|
|
10146
10163
|
getAssetColor = (size) => {
|
|
10147
10164
|
if (size > 300 * 1e3) {
|
|
10148
|
-
return
|
|
10165
|
+
return color14.red;
|
|
10149
10166
|
}
|
|
10150
10167
|
if (size > 100 * 1e3) {
|
|
10151
|
-
return
|
|
10168
|
+
return color14.yellow;
|
|
10152
10169
|
}
|
|
10153
|
-
return
|
|
10170
|
+
return color14.green;
|
|
10154
10171
|
};
|
|
10155
10172
|
calcFileSize = (len) => {
|
|
10156
10173
|
const val = len / 1e3;
|
|
@@ -10158,15 +10175,15 @@ var init_fileSize = __esm({
|
|
|
10158
10175
|
};
|
|
10159
10176
|
coloringAssetName = (assetName) => {
|
|
10160
10177
|
if (JS_REGEX.test(assetName)) {
|
|
10161
|
-
return
|
|
10178
|
+
return color14.cyan(assetName);
|
|
10162
10179
|
}
|
|
10163
10180
|
if (CSS_REGEX.test(assetName)) {
|
|
10164
|
-
return
|
|
10181
|
+
return color14.yellow(assetName);
|
|
10165
10182
|
}
|
|
10166
10183
|
if (HTML_REGEX.test(assetName)) {
|
|
10167
|
-
return
|
|
10184
|
+
return color14.green(assetName);
|
|
10168
10185
|
}
|
|
10169
|
-
return
|
|
10186
|
+
return color14.magenta(assetName);
|
|
10170
10187
|
};
|
|
10171
10188
|
pluginFileSize = () => ({
|
|
10172
10189
|
name: "rsbuild:file-size",
|
|
@@ -10175,6 +10192,7 @@ var init_fileSize = __esm({
|
|
|
10175
10192
|
if (!stats || stats.hasErrors() || !isFirstCompile) {
|
|
10176
10193
|
return;
|
|
10177
10194
|
}
|
|
10195
|
+
const logs = [];
|
|
10178
10196
|
await Promise.all(
|
|
10179
10197
|
Object.values(environments).map(async (environment, index) => {
|
|
10180
10198
|
const { printFileSize } = environment.config.performance;
|
|
@@ -10191,22 +10209,22 @@ var init_fileSize = __esm({
|
|
|
10191
10209
|
...defaultConfig,
|
|
10192
10210
|
...printFileSize
|
|
10193
10211
|
};
|
|
10194
|
-
const
|
|
10212
|
+
const statsLogs = await printFileSizes(
|
|
10195
10213
|
mergedConfig,
|
|
10196
10214
|
multiStats[index],
|
|
10197
|
-
api.context.rootPath
|
|
10215
|
+
api.context.rootPath,
|
|
10216
|
+
environment.name
|
|
10198
10217
|
);
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
`);
|
|
10202
|
-
for (const log of statsLog) {
|
|
10203
|
-
logger.log(log);
|
|
10218
|
+
if (logs.length) {
|
|
10219
|
+
logs.push(color14.dim(" -----"));
|
|
10204
10220
|
}
|
|
10221
|
+
logs.push(...statsLogs);
|
|
10205
10222
|
})
|
|
10206
10223
|
).catch((err) => {
|
|
10207
10224
|
logger.warn("Failed to print file size.");
|
|
10208
10225
|
logger.warn(err);
|
|
10209
10226
|
});
|
|
10227
|
+
logger.log(logs.join("\n"));
|
|
10210
10228
|
});
|
|
10211
10229
|
}
|
|
10212
10230
|
});
|
|
@@ -10220,7 +10238,7 @@ __export(cleanOutput_exports, {
|
|
|
10220
10238
|
pluginCleanOutput: () => pluginCleanOutput
|
|
10221
10239
|
});
|
|
10222
10240
|
import { join as join11, sep as sep2 } from "path";
|
|
10223
|
-
import
|
|
10241
|
+
import color15 from "../compiled/picocolors/index.js";
|
|
10224
10242
|
var addTrailingSep, isStrictSubdir, dedupeCleanPaths, pluginCleanOutput;
|
|
10225
10243
|
var init_cleanOutput = __esm({
|
|
10226
10244
|
"src/plugins/cleanOutput.ts"() {
|
|
@@ -10268,10 +10286,10 @@ var init_cleanOutput = __esm({
|
|
|
10268
10286
|
"The dist path is not a subdir of root path, Rsbuild will not empty it."
|
|
10269
10287
|
);
|
|
10270
10288
|
logger.warn(
|
|
10271
|
-
`Please set ${
|
|
10289
|
+
`Please set ${color15.yellow("`output.cleanDistPath`")} config manually.`
|
|
10272
10290
|
);
|
|
10273
|
-
logger.warn(`Current root path: ${
|
|
10274
|
-
logger.warn(`Current dist path: ${
|
|
10291
|
+
logger.warn(`Current root path: ${color15.dim(rootPath)}`);
|
|
10292
|
+
logger.warn(`Current dist path: ${color15.dim(distPath)}`);
|
|
10275
10293
|
}
|
|
10276
10294
|
}
|
|
10277
10295
|
if (cleanDistPath) {
|
|
@@ -10632,7 +10650,7 @@ __export(html_exports, {
|
|
|
10632
10650
|
});
|
|
10633
10651
|
import fs8 from "fs";
|
|
10634
10652
|
import path14, { isAbsolute as isAbsolute6 } from "path";
|
|
10635
|
-
import
|
|
10653
|
+
import color16 from "../compiled/picocolors/index.js";
|
|
10636
10654
|
function getTitle(entryName, config) {
|
|
10637
10655
|
return reduceConfigsMergeContext({
|
|
10638
10656
|
initial: "",
|
|
@@ -10663,7 +10681,7 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
10663
10681
|
if (!existTemplatePath.has(absolutePath)) {
|
|
10664
10682
|
if (!await isFileExists(absolutePath)) {
|
|
10665
10683
|
throw new Error(
|
|
10666
|
-
`Failed to resolve HTML template, please check if the file exists: ${
|
|
10684
|
+
`Failed to resolve HTML template, please check if the file exists: ${color16.cyan(
|
|
10667
10685
|
absolutePath
|
|
10668
10686
|
)}`
|
|
10669
10687
|
);
|
|
@@ -11964,7 +11982,7 @@ var rsdoctor_exports = {};
|
|
|
11964
11982
|
__export(rsdoctor_exports, {
|
|
11965
11983
|
pluginRsdoctor: () => pluginRsdoctor
|
|
11966
11984
|
});
|
|
11967
|
-
import
|
|
11985
|
+
import color17 from "../compiled/picocolors/index.js";
|
|
11968
11986
|
var pluginRsdoctor;
|
|
11969
11987
|
var init_rsdoctor = __esm({
|
|
11970
11988
|
"src/plugins/rsdoctor.ts"() {
|
|
@@ -11997,7 +12015,7 @@ var init_rsdoctor = __esm({
|
|
|
11997
12015
|
});
|
|
11998
12016
|
} catch (err) {
|
|
11999
12017
|
logger.warn(
|
|
12000
|
-
`\`process.env.RSDOCTOR\` enabled, please install ${
|
|
12018
|
+
`\`process.env.RSDOCTOR\` enabled, please install ${color17.bold(color17.yellow(packageName))} package.`
|
|
12001
12019
|
);
|
|
12002
12020
|
return;
|
|
12003
12021
|
}
|
|
@@ -12006,7 +12024,7 @@ var init_rsdoctor = __esm({
|
|
|
12006
12024
|
module = await import(packagePath);
|
|
12007
12025
|
} catch (err) {
|
|
12008
12026
|
logger.error(
|
|
12009
|
-
`\`process.env.RSDOCTOR\` enabled, but failed to load ${
|
|
12027
|
+
`\`process.env.RSDOCTOR\` enabled, but failed to load ${color17.bold(color17.yellow(packageName))} module.`
|
|
12010
12028
|
);
|
|
12011
12029
|
return;
|
|
12012
12030
|
}
|
|
@@ -12017,7 +12035,7 @@ var init_rsdoctor = __esm({
|
|
|
12017
12035
|
config.plugins ||= [];
|
|
12018
12036
|
config.plugins.push(new module[pluginName]());
|
|
12019
12037
|
}
|
|
12020
|
-
logger.info(`${
|
|
12038
|
+
logger.info(`${color17.bold(color17.yellow(packageName))} enabled.`);
|
|
12021
12039
|
});
|
|
12022
12040
|
}
|
|
12023
12041
|
});
|
|
@@ -13265,7 +13283,7 @@ var init_prodServer = __esm({
|
|
|
13265
13283
|
if (base && base !== "/") {
|
|
13266
13284
|
this.middlewares.use(getBaseMiddleware({ base }));
|
|
13267
13285
|
}
|
|
13268
|
-
this.applyStaticAssetMiddleware();
|
|
13286
|
+
await this.applyStaticAssetMiddleware();
|
|
13269
13287
|
if (historyApiFallback) {
|
|
13270
13288
|
const { default: connectHistoryApiFallback } = await import("../compiled/connect-history-api-fallback/index.js");
|
|
13271
13289
|
const historyApiFallbackMiddleware = connectHistoryApiFallback(
|
|
@@ -13315,7 +13333,7 @@ __export(createRsbuild_exports, {
|
|
|
13315
13333
|
});
|
|
13316
13334
|
import { existsSync } from "fs";
|
|
13317
13335
|
import { isPromise } from "util/types";
|
|
13318
|
-
import
|
|
13336
|
+
import color18 from "../compiled/picocolors/index.js";
|
|
13319
13337
|
async function applyDefaultPlugins(pluginManager, context) {
|
|
13320
13338
|
const plugins = await Promise.all([
|
|
13321
13339
|
Promise.resolve().then(() => (init_basic2(), basic_exports)).then(({ pluginBasic: pluginBasic2 }) => pluginBasic2()),
|
|
@@ -13421,14 +13439,14 @@ async function createRsbuild(options = {}) {
|
|
|
13421
13439
|
if (checkDistDir) {
|
|
13422
13440
|
if (!existsSync(distPath)) {
|
|
13423
13441
|
throw new Error(
|
|
13424
|
-
`The output directory ${
|
|
13442
|
+
`The output directory ${color18.yellow(
|
|
13425
13443
|
distPath
|
|
13426
13444
|
)} does not exist, please build the project before previewing.`
|
|
13427
13445
|
);
|
|
13428
13446
|
}
|
|
13429
13447
|
if (isEmptyDir(distPath)) {
|
|
13430
13448
|
throw new Error(
|
|
13431
|
-
`The output directory ${
|
|
13449
|
+
`The output directory ${color18.yellow(
|
|
13432
13450
|
distPath
|
|
13433
13451
|
)} is empty, please build the project before previewing.`
|
|
13434
13452
|
);
|
|
@@ -13641,7 +13659,7 @@ var init_init = __esm({
|
|
|
13641
13659
|
|
|
13642
13660
|
// src/cli/commands.ts
|
|
13643
13661
|
function runCli() {
|
|
13644
|
-
program.name("rsbuild").usage("<command> [options]").version("1.0.
|
|
13662
|
+
program.name("rsbuild").usage("<command> [options]").version("1.0.13");
|
|
13645
13663
|
const devCommand = program.command("dev");
|
|
13646
13664
|
const buildCommand = program.command("build");
|
|
13647
13665
|
const previewCommand = program.command("preview");
|
|
@@ -13752,7 +13770,7 @@ function prepareCli() {
|
|
|
13752
13770
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
13753
13771
|
console.log();
|
|
13754
13772
|
}
|
|
13755
|
-
logger.greet(` ${`Rsbuild v${"1.0.
|
|
13773
|
+
logger.greet(` ${`Rsbuild v${"1.0.13"}`}
|
|
13756
13774
|
`);
|
|
13757
13775
|
}
|
|
13758
13776
|
var init_prepare = __esm({
|
|
@@ -13823,7 +13841,7 @@ init_mergeConfig();
|
|
|
13823
13841
|
init_helpers();
|
|
13824
13842
|
init_constants();
|
|
13825
13843
|
import { rspack as rspack10 } from "@rspack/core";
|
|
13826
|
-
var version = "1.0.
|
|
13844
|
+
var version = "1.0.13";
|
|
13827
13845
|
export {
|
|
13828
13846
|
PLUGIN_CSS_NAME,
|
|
13829
13847
|
PLUGIN_SWC_NAME,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "~1.0.
|
|
49
|
+
"@rspack/core": "~1.0.10",
|
|
50
50
|
"@rspack/lite-tapable": "~1.0.1",
|
|
51
51
|
"@swc/helpers": "^0.5.13",
|
|
52
52
|
"core-js": "~3.38.1"
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"sirv": "^2.0.4",
|
|
89
89
|
"style-loader": "3.3.4",
|
|
90
90
|
"tsc-alias": "^1.8.10",
|
|
91
|
-
"typescript": "^5.6.
|
|
91
|
+
"typescript": "^5.6.3",
|
|
92
92
|
"webpack": "^5.95.0",
|
|
93
93
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
94
94
|
"webpack-merge": "6.0.1",
|