@rsbuild/core 0.7.6 → 0.7.7
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/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +15 -15
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/style-loader/index.js +10 -10
- package/compiled/webpack-dev-middleware/index.js +31 -31
- package/dist/client/hmr.js +10 -6
- package/dist/client/overlay.js +1 -1
- package/dist/index.cjs +100 -62
- package/dist/index.js +118 -78
- package/dist-types/client/format.d.ts +1 -1
- package/dist-types/config.d.ts +2 -1
- package/dist-types/index.d.ts +1 -1
- package/package.json +4 -4
- package/types.d.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -78,16 +78,16 @@ function hintUnknownFiles(message) {
|
|
|
78
78
|
}
|
|
79
79
|
return message;
|
|
80
80
|
}
|
|
81
|
-
function formatMessage(stats) {
|
|
81
|
+
function formatMessage(stats, verbose) {
|
|
82
82
|
let lines = [];
|
|
83
83
|
let message;
|
|
84
84
|
if (typeof stats === "object") {
|
|
85
85
|
const fileName = resolveFileName(stats);
|
|
86
86
|
const mainMessage = stats.message;
|
|
87
|
-
const details = stats.details ? `
|
|
87
|
+
const details = verbose && stats.details ? `
|
|
88
88
|
Details: ${stats.details}
|
|
89
89
|
` : "";
|
|
90
|
-
const stack = stats.stack ? `
|
|
90
|
+
const stack = verbose && stats.stack ? `
|
|
91
91
|
${stats.stack}` : "";
|
|
92
92
|
message = `${fileName}${mainMessage}${details}${stack}`;
|
|
93
93
|
} else {
|
|
@@ -99,11 +99,15 @@ ${stats.stack}` : "";
|
|
|
99
99
|
(line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
|
|
100
100
|
);
|
|
101
101
|
message = lines.join("\n");
|
|
102
|
+
const innerError = "-- inner error --";
|
|
103
|
+
if (!verbose && message.includes(innerError)) {
|
|
104
|
+
message = message.split(innerError)[0];
|
|
105
|
+
}
|
|
102
106
|
return message.trim();
|
|
103
107
|
}
|
|
104
|
-
function formatStatsMessages(stats) {
|
|
105
|
-
const formattedErrors = stats.errors?.map(formatMessage) || [];
|
|
106
|
-
const formattedWarnings = stats.warnings?.map(formatMessage) || [];
|
|
108
|
+
function formatStatsMessages(stats, verbose) {
|
|
109
|
+
const formattedErrors = stats.errors?.map((error) => formatMessage(error, verbose)) || [];
|
|
110
|
+
const formattedWarnings = stats.warnings?.map((warning) => formatMessage(warning, verbose)) || [];
|
|
107
111
|
return {
|
|
108
112
|
errors: formattedErrors,
|
|
109
113
|
warnings: formattedWarnings
|
|
@@ -174,7 +178,9 @@ import {
|
|
|
174
178
|
DEFAULT_ASSET_PREFIX,
|
|
175
179
|
addTrailingSlash,
|
|
176
180
|
color,
|
|
181
|
+
isDebug,
|
|
177
182
|
isMultiCompiler,
|
|
183
|
+
isProd,
|
|
178
184
|
removeTailingSlash
|
|
179
185
|
} from "@rsbuild/shared";
|
|
180
186
|
import { fse } from "@rsbuild/shared";
|
|
@@ -215,10 +221,14 @@ function formatStats(stats, options = {}) {
|
|
|
215
221
|
...options
|
|
216
222
|
} : options
|
|
217
223
|
);
|
|
218
|
-
const { errors, warnings } = formatStatsMessages(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
const { errors, warnings } = formatStatsMessages(
|
|
225
|
+
{
|
|
226
|
+
errors: getAllStatsErrors(statsData),
|
|
227
|
+
warnings: getAllStatsWarnings(statsData)
|
|
228
|
+
},
|
|
229
|
+
// display verbose messages in prod build or debug mode
|
|
230
|
+
isProd() || isDebug()
|
|
231
|
+
);
|
|
222
232
|
if (stats.hasErrors()) {
|
|
223
233
|
return {
|
|
224
234
|
message: formatErrorMessage(errors),
|
|
@@ -655,7 +665,7 @@ async function stringifyConfig(config, verbose) {
|
|
|
655
665
|
const stringify = RspackChain.toString;
|
|
656
666
|
return stringify(config, { verbose });
|
|
657
667
|
}
|
|
658
|
-
var getDefaultDevConfig, getDefaultServerConfig, getDefaultSourceConfig, getDefaultHtmlConfig, getDefaultSecurityConfig, getDefaultToolsConfig, getDefaultPerformanceConfig, getDefaultOutputConfig, createDefaultConfig, withDefaultConfig, normalizeConfig, resolveConfigPath;
|
|
668
|
+
var getDefaultDevConfig, getDefaultServerConfig, getDefaultSourceConfig, getDefaultHtmlConfig, getDefaultSecurityConfig, getDefaultToolsConfig, getDefaultPerformanceConfig, getDefaultOutputConfig, createDefaultConfig, withDefaultConfig, normalizeConfig, resolveConfigPath, normalizePublicDirs;
|
|
659
669
|
var init_config = __esm({
|
|
660
670
|
"src/config.ts"() {
|
|
661
671
|
"use strict";
|
|
@@ -680,12 +690,7 @@ var init_config = __esm({
|
|
|
680
690
|
htmlFallback: "index",
|
|
681
691
|
compress: true,
|
|
682
692
|
printUrls: true,
|
|
683
|
-
strictPort: false
|
|
684
|
-
publicDir: {
|
|
685
|
-
name: "public",
|
|
686
|
-
copyOnBuild: true,
|
|
687
|
-
watch: false
|
|
688
|
-
}
|
|
693
|
+
strictPort: false
|
|
689
694
|
});
|
|
690
695
|
getDefaultSourceConfig = () => ({
|
|
691
696
|
alias: {},
|
|
@@ -826,6 +831,31 @@ var init_config = __esm({
|
|
|
826
831
|
}
|
|
827
832
|
return null;
|
|
828
833
|
};
|
|
834
|
+
normalizePublicDirs = (publicDir) => {
|
|
835
|
+
if (publicDir === false) {
|
|
836
|
+
return [];
|
|
837
|
+
}
|
|
838
|
+
const defaultConfig = {
|
|
839
|
+
name: "public",
|
|
840
|
+
copyOnBuild: true,
|
|
841
|
+
watch: false
|
|
842
|
+
};
|
|
843
|
+
if (publicDir === void 0) {
|
|
844
|
+
return [defaultConfig];
|
|
845
|
+
}
|
|
846
|
+
if (Array.isArray(publicDir)) {
|
|
847
|
+
return publicDir.map((options) => ({
|
|
848
|
+
...defaultConfig,
|
|
849
|
+
...options
|
|
850
|
+
}));
|
|
851
|
+
}
|
|
852
|
+
return [
|
|
853
|
+
{
|
|
854
|
+
...defaultConfig,
|
|
855
|
+
...publicDir
|
|
856
|
+
}
|
|
857
|
+
];
|
|
858
|
+
};
|
|
829
859
|
}
|
|
830
860
|
});
|
|
831
861
|
|
|
@@ -861,6 +891,7 @@ function loadEnv({
|
|
|
861
891
|
for (const key of Object.keys(process.env)) {
|
|
862
892
|
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
|
863
893
|
const val = process.env[key];
|
|
894
|
+
publicVars[`import.meta.env.${key}`] = JSON.stringify(val);
|
|
864
895
|
publicVars[`process.env.${key}`] = JSON.stringify(val);
|
|
865
896
|
}
|
|
866
897
|
}
|
|
@@ -1042,7 +1073,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
1042
1073
|
return {
|
|
1043
1074
|
entry: getEntryObject(config, "web"),
|
|
1044
1075
|
targets: config.output?.targets || [],
|
|
1045
|
-
version: "0.7.
|
|
1076
|
+
version: "0.7.7",
|
|
1046
1077
|
rootPath,
|
|
1047
1078
|
distPath,
|
|
1048
1079
|
cachePath,
|
|
@@ -1632,7 +1663,7 @@ var init_rspackConfig = __esm({
|
|
|
1632
1663
|
// src/provider/initConfigs.ts
|
|
1633
1664
|
import {
|
|
1634
1665
|
debug as debug3,
|
|
1635
|
-
isDebug
|
|
1666
|
+
isDebug as isDebug2
|
|
1636
1667
|
} from "@rsbuild/shared";
|
|
1637
1668
|
async function modifyRsbuildConfig(context) {
|
|
1638
1669
|
debug3("modify Rsbuild config");
|
|
@@ -1669,7 +1700,7 @@ async function initConfigs({
|
|
|
1669
1700
|
const rspackConfigs = await Promise.all(
|
|
1670
1701
|
targets.map((target) => generateRspackConfig({ target, context }))
|
|
1671
1702
|
);
|
|
1672
|
-
if (
|
|
1703
|
+
if (isDebug2()) {
|
|
1673
1704
|
const inspect = () => {
|
|
1674
1705
|
const inspectOptions = {
|
|
1675
1706
|
verbose: true,
|
|
@@ -1780,7 +1811,7 @@ import {
|
|
|
1780
1811
|
color as color6,
|
|
1781
1812
|
debug as debug4,
|
|
1782
1813
|
isDev,
|
|
1783
|
-
isProd,
|
|
1814
|
+
isProd as isProd2,
|
|
1784
1815
|
logger as logger5,
|
|
1785
1816
|
onCompileDone,
|
|
1786
1817
|
prettyTime
|
|
@@ -1818,7 +1849,7 @@ async function createCompiler({
|
|
|
1818
1849
|
}
|
|
1819
1850
|
isCompiling = true;
|
|
1820
1851
|
});
|
|
1821
|
-
if (
|
|
1852
|
+
if (isProd2()) {
|
|
1822
1853
|
compiler.hooks.run.tap("rsbuild:run", logRspackVersion);
|
|
1823
1854
|
}
|
|
1824
1855
|
const done = async (stats) => {
|
|
@@ -1901,7 +1932,7 @@ import { parse as parse2 } from "url";
|
|
|
1901
1932
|
import {
|
|
1902
1933
|
color as color7,
|
|
1903
1934
|
debug as debug5,
|
|
1904
|
-
isDebug as
|
|
1935
|
+
isDebug as isDebug3,
|
|
1905
1936
|
logger as logger6
|
|
1906
1937
|
} from "@rsbuild/shared";
|
|
1907
1938
|
var faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, getHtmlFallbackMiddleware;
|
|
@@ -1986,7 +2017,7 @@ var init_middlewares = __esm({
|
|
|
1986
2017
|
});
|
|
1987
2018
|
};
|
|
1988
2019
|
const rewrite = (newUrl, isFallback = false) => {
|
|
1989
|
-
if (isFallback &&
|
|
2020
|
+
if (isFallback && isDebug3()) {
|
|
1990
2021
|
debug5(
|
|
1991
2022
|
`${req.method} ${color7.gray(
|
|
1992
2023
|
`${req.url} ${color7.yellow("fallback")} to ${newUrl}`
|
|
@@ -2113,12 +2144,13 @@ var init_proxy = __esm({
|
|
|
2113
2144
|
// src/server/getDevMiddlewares.ts
|
|
2114
2145
|
import { isAbsolute as isAbsolute4, join as join7 } from "path";
|
|
2115
2146
|
import url from "url";
|
|
2116
|
-
import { isDebug as
|
|
2147
|
+
import { isDebug as isDebug4 } from "@rsbuild/shared";
|
|
2117
2148
|
var applySetupMiddlewares, applyDefaultMiddlewares, getMiddlewares;
|
|
2118
2149
|
var init_getDevMiddlewares = __esm({
|
|
2119
2150
|
"src/server/getDevMiddlewares.ts"() {
|
|
2120
2151
|
"use strict";
|
|
2121
2152
|
init_esm();
|
|
2153
|
+
init_config();
|
|
2122
2154
|
init_middlewares();
|
|
2123
2155
|
applySetupMiddlewares = (dev, compileMiddlewareAPI) => {
|
|
2124
2156
|
const setupMiddlewares = dev.setupMiddlewares || [];
|
|
@@ -2196,11 +2228,12 @@ var init_getDevMiddlewares = __esm({
|
|
|
2196
2228
|
}
|
|
2197
2229
|
});
|
|
2198
2230
|
}
|
|
2199
|
-
|
|
2231
|
+
const publicDirs = normalizePublicDirs(server?.publicDir);
|
|
2232
|
+
for (const publicDir of publicDirs) {
|
|
2200
2233
|
const { default: sirv } = await import("../compiled/sirv/index.js");
|
|
2201
|
-
const { name } =
|
|
2202
|
-
const
|
|
2203
|
-
const assetMiddleware = sirv(
|
|
2234
|
+
const { name } = publicDir;
|
|
2235
|
+
const normalizedPath = isAbsolute4(name) ? name : join7(pwd, name);
|
|
2236
|
+
const assetMiddleware = sirv(normalizedPath, {
|
|
2204
2237
|
etag: true,
|
|
2205
2238
|
dev: true
|
|
2206
2239
|
});
|
|
@@ -2235,7 +2268,7 @@ var init_getDevMiddlewares = __esm({
|
|
|
2235
2268
|
getMiddlewares = async (options) => {
|
|
2236
2269
|
const middlewares = [];
|
|
2237
2270
|
const { compileMiddlewareAPI } = options;
|
|
2238
|
-
if (
|
|
2271
|
+
if (isDebug4()) {
|
|
2239
2272
|
middlewares.push(await getRequestLoggerMiddleware());
|
|
2240
2273
|
}
|
|
2241
2274
|
const { before, after } = applySetupMiddlewares(
|
|
@@ -2593,11 +2626,15 @@ async function watchDevFiles(devConfig, compileMiddlewareAPI) {
|
|
|
2593
2626
|
return startWatchFiles(watchOptions, compileMiddlewareAPI);
|
|
2594
2627
|
}
|
|
2595
2628
|
function watchServerFiles(serverConfig, compileMiddlewareAPI) {
|
|
2596
|
-
const
|
|
2597
|
-
if (!
|
|
2629
|
+
const publicDirs = normalizePublicDirs(serverConfig.publicDir);
|
|
2630
|
+
if (!publicDirs.length) {
|
|
2631
|
+
return;
|
|
2632
|
+
}
|
|
2633
|
+
const watchPaths = publicDirs.filter((item) => item.watch).map((item) => item.name);
|
|
2634
|
+
if (!watchPaths.length) {
|
|
2598
2635
|
return;
|
|
2599
2636
|
}
|
|
2600
|
-
const watchOptions = prepareWatchOptions(
|
|
2637
|
+
const watchOptions = prepareWatchOptions(watchPaths);
|
|
2601
2638
|
return startWatchFiles(watchOptions, compileMiddlewareAPI);
|
|
2602
2639
|
}
|
|
2603
2640
|
function prepareWatchOptions(paths, options = {}) {
|
|
@@ -2618,6 +2655,7 @@ var init_watchFiles = __esm({
|
|
|
2618
2655
|
"src/server/watchFiles.ts"() {
|
|
2619
2656
|
"use strict";
|
|
2620
2657
|
init_esm();
|
|
2658
|
+
init_config();
|
|
2621
2659
|
}
|
|
2622
2660
|
});
|
|
2623
2661
|
|
|
@@ -3056,7 +3094,7 @@ __export(prodServer_exports, {
|
|
|
3056
3094
|
import { join as join8 } from "path";
|
|
3057
3095
|
import {
|
|
3058
3096
|
getNodeEnv as getNodeEnv6,
|
|
3059
|
-
isDebug as
|
|
3097
|
+
isDebug as isDebug5,
|
|
3060
3098
|
setNodeEnv as setNodeEnv3
|
|
3061
3099
|
} from "@rsbuild/shared";
|
|
3062
3100
|
async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
@@ -3153,7 +3191,7 @@ var init_prodServer = __esm({
|
|
|
3153
3191
|
}
|
|
3154
3192
|
async applyDefaultMiddlewares() {
|
|
3155
3193
|
const { headers, proxy, historyApiFallback, compress } = this.options.serverConfig;
|
|
3156
|
-
if (
|
|
3194
|
+
if (isDebug5()) {
|
|
3157
3195
|
this.middlewares.use(await getRequestLoggerMiddleware());
|
|
3158
3196
|
}
|
|
3159
3197
|
if (compress) {
|
|
@@ -3398,12 +3436,12 @@ var init_basic = __esm({
|
|
|
3398
3436
|
name: "rsbuild:basic",
|
|
3399
3437
|
setup(api) {
|
|
3400
3438
|
api.modifyBundlerChain(
|
|
3401
|
-
(chain, { env, isProd:
|
|
3439
|
+
(chain, { env, isProd: isProd6, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
|
|
3402
3440
|
const config = api.getNormalizedConfig();
|
|
3403
3441
|
chain.name(TARGET_ID_MAP2[target]);
|
|
3404
3442
|
chain.devtool(getJsSourceMap(config));
|
|
3405
3443
|
chain.context(api.context.rootPath);
|
|
3406
|
-
chain.mode(
|
|
3444
|
+
chain.mode(isProd6 ? "production" : "development");
|
|
3407
3445
|
chain.merge({
|
|
3408
3446
|
infrastructureLogging: {
|
|
3409
3447
|
// Using `error` level to avoid `cache.PackFileCacheStrategy` logs
|
|
@@ -3416,9 +3454,9 @@ var init_basic = __esm({
|
|
|
3416
3454
|
exportsPresence: "error"
|
|
3417
3455
|
}
|
|
3418
3456
|
});
|
|
3419
|
-
const isMinimize =
|
|
3457
|
+
const isMinimize = isProd6 && config.output.minify !== false;
|
|
3420
3458
|
chain.optimization.minimize(isMinimize);
|
|
3421
|
-
const usingHMR = isUsingHMR(config, { target, isProd:
|
|
3459
|
+
const usingHMR = isUsingHMR(config, { target, isProd: isProd6 });
|
|
3422
3460
|
if (usingHMR) {
|
|
3423
3461
|
chain.plugin(CHAIN_ID3.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin);
|
|
3424
3462
|
}
|
|
@@ -3614,7 +3652,7 @@ async function applyCSSRule({
|
|
|
3614
3652
|
rule,
|
|
3615
3653
|
config,
|
|
3616
3654
|
context,
|
|
3617
|
-
utils: { target, isProd:
|
|
3655
|
+
utils: { target, isProd: isProd6, CHAIN_ID: CHAIN_ID3 },
|
|
3618
3656
|
importLoaders = 1
|
|
3619
3657
|
}) {
|
|
3620
3658
|
const browserslist = await getBrowserslistWithDefault2(
|
|
@@ -3623,7 +3661,7 @@ async function applyCSSRule({
|
|
|
3623
3661
|
target
|
|
3624
3662
|
);
|
|
3625
3663
|
const enableExtractCSS = isUseCssExtract(config, target);
|
|
3626
|
-
const localIdentName = getCSSModulesLocalIdentName(config,
|
|
3664
|
+
const localIdentName = getCSSModulesLocalIdentName(config, isProd6);
|
|
3627
3665
|
const cssLoaderOptions = getCSSLoaderOptions({
|
|
3628
3666
|
config,
|
|
3629
3667
|
importLoaders,
|
|
@@ -3665,8 +3703,8 @@ var init_css = __esm({
|
|
|
3665
3703
|
init_pluginHelper();
|
|
3666
3704
|
enableNativeCss = (config) => !config.output.injectStyles;
|
|
3667
3705
|
isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
|
|
3668
|
-
getCSSModulesLocalIdentName = (config,
|
|
3669
|
-
(
|
|
3706
|
+
getCSSModulesLocalIdentName = (config, isProd6) => config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
|
|
3707
|
+
(isProd6 ? "[local]-[hash:base64:6]" : "[path][name]__[local]-[hash:base64:6]");
|
|
3670
3708
|
normalizeCssLoaderOptions = (options, exportOnlyLocals) => {
|
|
3671
3709
|
if (options.modules && exportOnlyLocals) {
|
|
3672
3710
|
let { modules } = options;
|
|
@@ -3820,13 +3858,13 @@ import {
|
|
|
3820
3858
|
} from "@rsbuild/shared";
|
|
3821
3859
|
import { rspack as rspack5 } from "@rspack/core";
|
|
3822
3860
|
function getPublicPath({
|
|
3823
|
-
isProd:
|
|
3861
|
+
isProd: isProd6,
|
|
3824
3862
|
config,
|
|
3825
3863
|
context
|
|
3826
3864
|
}) {
|
|
3827
3865
|
const { dev, output } = config;
|
|
3828
3866
|
let publicPath = DEFAULT_ASSET_PREFIX3;
|
|
3829
|
-
if (
|
|
3867
|
+
if (isProd6) {
|
|
3830
3868
|
if (typeof output.assetPrefix === "string") {
|
|
3831
3869
|
publicPath = output.assetPrefix;
|
|
3832
3870
|
}
|
|
@@ -3858,16 +3896,16 @@ var init_output = __esm({
|
|
|
3858
3896
|
name: "rsbuild:output",
|
|
3859
3897
|
setup(api) {
|
|
3860
3898
|
api.modifyBundlerChain(
|
|
3861
|
-
async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd:
|
|
3899
|
+
async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd: isProd6, isServer, isServiceWorker }) => {
|
|
3862
3900
|
const config = api.getNormalizedConfig();
|
|
3863
3901
|
const publicPath = getPublicPath({
|
|
3864
3902
|
config,
|
|
3865
|
-
isProd:
|
|
3903
|
+
isProd: isProd6,
|
|
3866
3904
|
context: api.context
|
|
3867
3905
|
});
|
|
3868
3906
|
const jsPath = getDistPath3(config, "js");
|
|
3869
3907
|
const jsAsyncPath = getDistPath3(config, "jsAsync");
|
|
3870
|
-
const jsFilename = getFilename2(config, "js",
|
|
3908
|
+
const jsFilename = getFilename2(config, "js", isProd6);
|
|
3871
3909
|
const isJsFilenameFn = typeof jsFilename === "function";
|
|
3872
3910
|
chain.output.path(api.context.distPath).filename(
|
|
3873
3911
|
isJsFilenameFn ? (...args) => {
|
|
@@ -3900,7 +3938,7 @@ var init_output = __esm({
|
|
|
3900
3938
|
if (isUseCssExtract(config, target)) {
|
|
3901
3939
|
const extractPluginOptions = config.tools.cssExtract.pluginOptions;
|
|
3902
3940
|
const cssPath = getDistPath3(config, "css");
|
|
3903
|
-
const cssFilename = getFilename2(config, "css",
|
|
3941
|
+
const cssFilename = getFilename2(config, "css", isProd6);
|
|
3904
3942
|
const cssAsyncPath = getDistPath3(config, "cssAsync");
|
|
3905
3943
|
chain.plugin(CHAIN_ID3.PLUGIN.MINI_CSS_EXTRACT).use(getCssExtractPlugin(), [
|
|
3906
3944
|
{
|
|
@@ -4283,12 +4321,12 @@ var init_asset = __esm({
|
|
|
4283
4321
|
pluginAsset = () => ({
|
|
4284
4322
|
name: "rsbuild:asset",
|
|
4285
4323
|
setup(api) {
|
|
4286
|
-
api.modifyBundlerChain((chain, { isProd:
|
|
4324
|
+
api.modifyBundlerChain((chain, { isProd: isProd6, target }) => {
|
|
4287
4325
|
const config = api.getNormalizedConfig();
|
|
4288
4326
|
const createAssetRule = (assetType, exts, emit2) => {
|
|
4289
4327
|
const regExp = getRegExpForExts(exts);
|
|
4290
4328
|
const distDir = getDistPath4(config, assetType);
|
|
4291
|
-
const filename = getFilename3(config, assetType,
|
|
4329
|
+
const filename = getFilename3(config, assetType, isProd6);
|
|
4292
4330
|
const { dataUriLimit } = config.output;
|
|
4293
4331
|
const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit[assetType];
|
|
4294
4332
|
const rule = chain.module.rule(assetType).test(regExp);
|
|
@@ -4371,9 +4409,9 @@ var init_minimize = __esm({
|
|
|
4371
4409
|
}
|
|
4372
4410
|
return options;
|
|
4373
4411
|
};
|
|
4374
|
-
parseMinifyOptions = (config,
|
|
4412
|
+
parseMinifyOptions = (config, isProd6 = true) => {
|
|
4375
4413
|
const minify = config.output.minify;
|
|
4376
|
-
if (minify === false || !
|
|
4414
|
+
if (minify === false || !isProd6) {
|
|
4377
4415
|
return {
|
|
4378
4416
|
minifyJs: false,
|
|
4379
4417
|
minifyCss: false,
|
|
@@ -4405,9 +4443,9 @@ var init_minimize = __esm({
|
|
|
4405
4443
|
if (api.context.bundlerType === "webpack") {
|
|
4406
4444
|
return;
|
|
4407
4445
|
}
|
|
4408
|
-
api.modifyBundlerChain(async (chain, { isProd:
|
|
4446
|
+
api.modifyBundlerChain(async (chain, { isProd: isProd6 }) => {
|
|
4409
4447
|
const config = api.getNormalizedConfig();
|
|
4410
|
-
const isMinimize =
|
|
4448
|
+
const isMinimize = isProd6 && config.output.minify !== false;
|
|
4411
4449
|
if (!isMinimize) {
|
|
4412
4450
|
return;
|
|
4413
4451
|
}
|
|
@@ -4765,8 +4803,8 @@ function getTerserMinifyOptions(config) {
|
|
|
4765
4803
|
const finalOptions = applyRemoveConsole(options, config);
|
|
4766
4804
|
return finalOptions;
|
|
4767
4805
|
}
|
|
4768
|
-
async function getHtmlMinifyOptions(
|
|
4769
|
-
if (!
|
|
4806
|
+
async function getHtmlMinifyOptions(isProd6, config) {
|
|
4807
|
+
if (!isProd6 || !config.output.minify || !parseMinifyOptions(config).minifyHtml) {
|
|
4770
4808
|
return false;
|
|
4771
4809
|
}
|
|
4772
4810
|
const minifyJS = getTerserMinifyOptions(config);
|
|
@@ -4916,12 +4954,12 @@ var init_html = __esm({
|
|
|
4916
4954
|
name: "rsbuild:html",
|
|
4917
4955
|
setup(api) {
|
|
4918
4956
|
api.modifyBundlerChain(
|
|
4919
|
-
async (chain, { HtmlPlugin, isProd:
|
|
4957
|
+
async (chain, { HtmlPlugin, isProd: isProd6, CHAIN_ID: CHAIN_ID3, target }) => {
|
|
4920
4958
|
const config = api.getNormalizedConfig();
|
|
4921
4959
|
if (isHtmlDisabled(config, target)) {
|
|
4922
4960
|
return;
|
|
4923
4961
|
}
|
|
4924
|
-
const minify = await getHtmlMinifyOptions(
|
|
4962
|
+
const minify = await getHtmlMinifyOptions(isProd6, config);
|
|
4925
4963
|
const assetPrefix = getPublicPathFromChain(chain, false);
|
|
4926
4964
|
const entries = chain.entryPoints.entries() || {};
|
|
4927
4965
|
const entryNames = Object.keys(entries);
|
|
@@ -5180,7 +5218,7 @@ var progress_exports = {};
|
|
|
5180
5218
|
__export(progress_exports, {
|
|
5181
5219
|
pluginProgress: () => pluginProgress
|
|
5182
5220
|
});
|
|
5183
|
-
import { TARGET_ID_MAP as TARGET_ID_MAP3, isProd as
|
|
5221
|
+
import { TARGET_ID_MAP as TARGET_ID_MAP3, isProd as isProd3 } from "@rsbuild/shared";
|
|
5184
5222
|
import { rspack as rspack7 } from "@rspack/core";
|
|
5185
5223
|
var pluginProgress;
|
|
5186
5224
|
var init_progress = __esm({
|
|
@@ -5196,7 +5234,7 @@ var init_progress = __esm({
|
|
|
5196
5234
|
api.modifyBundlerChain(async (chain, { target, CHAIN_ID: CHAIN_ID3 }) => {
|
|
5197
5235
|
const config = api.getNormalizedConfig();
|
|
5198
5236
|
const options = config.dev.progressBar ?? // enable progress bar in production by default
|
|
5199
|
-
|
|
5237
|
+
isProd3();
|
|
5200
5238
|
if (!options) {
|
|
5201
5239
|
return;
|
|
5202
5240
|
}
|
|
@@ -5988,13 +6026,13 @@ var bundleAnalyzer_exports = {};
|
|
|
5988
6026
|
__export(bundleAnalyzer_exports, {
|
|
5989
6027
|
pluginBundleAnalyzer: () => pluginBundleAnalyzer
|
|
5990
6028
|
});
|
|
5991
|
-
import { isProd as
|
|
6029
|
+
import { isProd as isProd4 } from "@rsbuild/shared";
|
|
5992
6030
|
function pluginBundleAnalyzer() {
|
|
5993
6031
|
return {
|
|
5994
6032
|
name: "rsbuild:bundle-analyzer",
|
|
5995
6033
|
setup(api) {
|
|
5996
6034
|
api.modifyRsbuildConfig((config) => {
|
|
5997
|
-
if (
|
|
6035
|
+
if (isProd4() || !isUseAnalyzer(config)) {
|
|
5998
6036
|
return;
|
|
5999
6037
|
}
|
|
6000
6038
|
config.dev ||= {};
|
|
@@ -6490,28 +6528,30 @@ var init_server = __esm({
|
|
|
6490
6528
|
"src/plugins/server.ts"() {
|
|
6491
6529
|
"use strict";
|
|
6492
6530
|
init_esm();
|
|
6531
|
+
init_config();
|
|
6493
6532
|
pluginServer = () => ({
|
|
6494
6533
|
name: "rsbuild:server",
|
|
6495
6534
|
setup(api) {
|
|
6496
6535
|
api.onBeforeBuild(async () => {
|
|
6497
6536
|
const config = api.getNormalizedConfig();
|
|
6498
|
-
|
|
6499
|
-
|
|
6537
|
+
const publicDirs = normalizePublicDirs(config.server.publicDir);
|
|
6538
|
+
for (const publicDir of publicDirs) {
|
|
6539
|
+
const { name, copyOnBuild } = publicDir;
|
|
6500
6540
|
if (!copyOnBuild || !name) {
|
|
6501
|
-
|
|
6541
|
+
continue;
|
|
6502
6542
|
}
|
|
6503
|
-
const
|
|
6504
|
-
if (!fse7.existsSync(
|
|
6505
|
-
|
|
6543
|
+
const normalizedPath = isAbsolute7(name) ? name : join11(api.context.rootPath, name);
|
|
6544
|
+
if (!fse7.existsSync(normalizedPath)) {
|
|
6545
|
+
continue;
|
|
6506
6546
|
}
|
|
6507
6547
|
try {
|
|
6508
|
-
await fse7.copy(
|
|
6548
|
+
await fse7.copy(normalizedPath, api.context.distPath, {
|
|
6509
6549
|
// dereference symlinks
|
|
6510
6550
|
dereference: true
|
|
6511
6551
|
});
|
|
6512
6552
|
} catch (err) {
|
|
6513
6553
|
if (err instanceof Error) {
|
|
6514
|
-
err.message = `Copy public dir (${
|
|
6554
|
+
err.message = `Copy public dir (${normalizedPath}) to dist failed:
|
|
6515
6555
|
${err.message}`;
|
|
6516
6556
|
}
|
|
6517
6557
|
throw err;
|
|
@@ -6853,8 +6893,8 @@ var init_lazyCompilation = __esm({
|
|
|
6853
6893
|
pluginLazyCompilation = () => ({
|
|
6854
6894
|
name: "rsbuild:lazy-compilation",
|
|
6855
6895
|
setup(api) {
|
|
6856
|
-
api.modifyBundlerChain((chain, { isProd:
|
|
6857
|
-
if (
|
|
6896
|
+
api.modifyBundlerChain((chain, { isProd: isProd6, target }) => {
|
|
6897
|
+
if (isProd6 || target !== "web") {
|
|
6858
6898
|
return;
|
|
6859
6899
|
}
|
|
6860
6900
|
const config = api.getNormalizedConfig();
|
|
@@ -6920,7 +6960,7 @@ __export(sri_exports, {
|
|
|
6920
6960
|
import crypto2 from "crypto";
|
|
6921
6961
|
import {
|
|
6922
6962
|
isHtmlDisabled as isHtmlDisabled4,
|
|
6923
|
-
isProd as
|
|
6963
|
+
isProd as isProd5,
|
|
6924
6964
|
logger as logger16,
|
|
6925
6965
|
removeLeadingSlash as removeLeadingSlash2
|
|
6926
6966
|
} from "@rsbuild/shared";
|
|
@@ -6943,7 +6983,7 @@ var init_sri = __esm({
|
|
|
6943
6983
|
const getAlgorithm = () => {
|
|
6944
6984
|
const config = api.getNormalizedConfig();
|
|
6945
6985
|
const { sri } = config.security;
|
|
6946
|
-
const enable = sri.enable === "auto" ?
|
|
6986
|
+
const enable = sri.enable === "auto" ? isProd5() : sri.enable;
|
|
6947
6987
|
if (!enable) {
|
|
6948
6988
|
return null;
|
|
6949
6989
|
}
|
|
@@ -7434,7 +7474,7 @@ var applyServerOptions = (command) => {
|
|
|
7434
7474
|
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
7435
7475
|
};
|
|
7436
7476
|
function runCli() {
|
|
7437
|
-
program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
7477
|
+
program.name("rsbuild").usage("<command> [options]").version("0.7.7");
|
|
7438
7478
|
const devCommand = program.command("dev");
|
|
7439
7479
|
const buildCommand = program.command("build");
|
|
7440
7480
|
const previewCommand = program.command("preview");
|
|
@@ -7525,7 +7565,7 @@ function prepareCli() {
|
|
|
7525
7565
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
7526
7566
|
console.log();
|
|
7527
7567
|
}
|
|
7528
|
-
logger19.greet(` ${`Rsbuild v${"0.7.
|
|
7568
|
+
logger19.greet(` ${`Rsbuild v${"0.7.7"}`}
|
|
7529
7569
|
`);
|
|
7530
7570
|
}
|
|
7531
7571
|
|
|
@@ -7553,7 +7593,7 @@ init_config();
|
|
|
7553
7593
|
init_mergeConfig();
|
|
7554
7594
|
init_constants();
|
|
7555
7595
|
import { logger as logger20 } from "@rsbuild/shared";
|
|
7556
|
-
var version = "0.7.
|
|
7596
|
+
var version = "0.7.7";
|
|
7557
7597
|
export {
|
|
7558
7598
|
PLUGIN_CSS_NAME,
|
|
7559
7599
|
PLUGIN_SWC_NAME,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StatsCompilation } from '@rspack/core';
|
|
2
|
-
export declare function formatStatsMessages(stats: Pick<StatsCompilation, 'errors' | 'warnings'
|
|
2
|
+
export declare function formatStatsMessages(stats: Pick<StatsCompilation, 'errors' | 'warnings'>, verbose?: boolean): {
|
|
3
3
|
errors: string[];
|
|
4
4
|
warnings: string[];
|
|
5
5
|
};
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InspectConfigOptions, NormalizedConfig, RsbuildConfig } from '@rsbuild/shared';
|
|
1
|
+
import type { InspectConfigOptions, NormalizedConfig, PublicDir, PublicDirOptions, RsbuildConfig } from '@rsbuild/shared';
|
|
2
2
|
export declare const withDefaultConfig: (rootPath: string, config: RsbuildConfig) => Promise<RsbuildConfig>;
|
|
3
3
|
/** #__PURE__
|
|
4
4
|
* 1. May used by multiple plugins.
|
|
@@ -41,3 +41,4 @@ export declare function outputInspectConfigFiles({ rsbuildConfig, rawRsbuildConf
|
|
|
41
41
|
};
|
|
42
42
|
}): Promise<void>;
|
|
43
43
|
export declare function stringifyConfig(config: unknown, verbose?: boolean): Promise<string>;
|
|
44
|
+
export declare const normalizePublicDirs: (publicDir?: PublicDir) => Required<PublicDirOptions>[];
|
package/dist-types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { logger } from '@rsbuild/shared';
|
|
|
15
15
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
16
16
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME } from './constants';
|
|
17
17
|
export type { RsbuildConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, ServerConfig, OutputConfig, SecurityConfig, PerformanceConfig, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedServerConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig, NormalizedModuleFederationConfig, RsbuildPlugin, RsbuildPlugins, RsbuildPluginAPI, RsbuildInstance, RsbuildProvider, CreateRsbuildOptions, } from './types';
|
|
18
|
-
export type { RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildContext, InspectConfigResult, InspectConfigOptions, Minify, Polyfill, PrintUrls, PublicDir, Decorators, RspackRule, WatchFiles, CSSModules, CrossOrigin, ConsoleType, SplitChunks, RspackChain, ClientConfig, ScriptInject, ConfigChain, PostCSSPlugin, ScriptLoading, LegalComments, AliasStrategy, FilenameConfig, DistPathConfig, OutputStructure, ChainIdentifier, PreconnectOption, CSSLoaderOptions, ModifyChainUtils, StyleLoaderOptions, PostCSSLoaderOptions, ConfigChainWithContext, ModifyRspackConfigUtils, CSSModulesLocalsConvention, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnCloseDevServerFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyRsbuildConfigFn, TransformFn, TransformHandler, } from '@rsbuild/shared';
|
|
18
|
+
export type { RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildContext, InspectConfigResult, InspectConfigOptions, Minify, Polyfill, PrintUrls, PublicDir, Decorators, RspackRule, WatchFiles, CSSModules, CrossOrigin, ConsoleType, SplitChunks, RspackChain, ClientConfig, ScriptInject, ConfigChain, PostCSSPlugin, ScriptLoading, LegalComments, AliasStrategy, FilenameConfig, DistPathConfig, OutputStructure, ChainIdentifier, PublicDirOptions, PreconnectOption, CSSLoaderOptions, ModifyChainUtils, StyleLoaderOptions, PostCSSLoaderOptions, ConfigChainWithContext, ModifyRspackConfigUtils, CSSModulesLocalsConvention, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnCloseDevServerFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyRsbuildConfigFn, TransformFn, TransformHandler, } from '@rsbuild/shared';
|
|
19
19
|
export {
|
|
20
20
|
/**
|
|
21
21
|
* @private
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "0.7.
|
|
49
|
+
"@rspack/core": "0.7.3",
|
|
50
50
|
"@swc/helpers": "0.5.3",
|
|
51
51
|
"core-js": "~3.36.0",
|
|
52
52
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.7.2",
|
|
53
53
|
"postcss": "^8.4.38",
|
|
54
|
-
"@rsbuild/shared": "0.7.
|
|
54
|
+
"@rsbuild/shared": "0.7.7"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"style-loader": "3.3.4",
|
|
80
80
|
"tsc-alias": "^1.8.10",
|
|
81
81
|
"typescript": "^5.4.2",
|
|
82
|
-
"webpack": "^5.
|
|
82
|
+
"webpack": "^5.92.0",
|
|
83
83
|
"webpack-dev-middleware": "7.2.1",
|
|
84
84
|
"ws": "^8.17.0"
|
|
85
85
|
},
|
package/types.d.ts
CHANGED