@rsbuild/core 0.7.0 → 0.7.2
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 +65 -45
- package/compiled/css-loader/package.json +1 -1
- package/compiled/postcss-loader/index.js +57 -50
- package/dist/client/hmr.js +2 -2
- package/dist/index.cjs +172 -84
- package/dist/index.js +152 -63
- package/dist-types/helpers.d.ts +1 -0
- package/dist-types/plugins/lazyCompilation.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -23,12 +23,12 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.
|
|
26
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
27
27
|
import { fileURLToPath } from "url";
|
|
28
28
|
import path from "path";
|
|
29
29
|
var getFilename, getDirname, __dirname, __filename;
|
|
30
30
|
var init_esm = __esm({
|
|
31
|
-
"../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.
|
|
31
|
+
"../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
32
32
|
"use strict";
|
|
33
33
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
34
34
|
getDirname = () => path.dirname(getFilename());
|
|
@@ -37,24 +37,6 @@ var init_esm = __esm({
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
// src/constants.ts
|
|
41
|
-
import { join } from "path";
|
|
42
|
-
var PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
|
|
43
|
-
var init_constants = __esm({
|
|
44
|
-
"src/constants.ts"() {
|
|
45
|
-
"use strict";
|
|
46
|
-
init_esm();
|
|
47
|
-
PLUGIN_SWC_NAME = "rsbuild:swc";
|
|
48
|
-
PLUGIN_CSS_NAME = "rsbuild:css";
|
|
49
|
-
LOADER_PATH = join(__dirname);
|
|
50
|
-
STATIC_PATH = join(__dirname, "../static");
|
|
51
|
-
COMPILED_PATH = join(__dirname, "../compiled");
|
|
52
|
-
TS_CONFIG_FILE = "tsconfig.json";
|
|
53
|
-
HTML_REGEX = /\.html$/;
|
|
54
|
-
CSS_REGEX = /\.css$/;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
40
|
// src/client/format.ts
|
|
59
41
|
function resolveFileName(stats) {
|
|
60
42
|
if (stats.moduleIdentifier) {
|
|
@@ -68,8 +50,8 @@ function resolveFileName(stats) {
|
|
|
68
50
|
}
|
|
69
51
|
}
|
|
70
52
|
}
|
|
71
|
-
return `File: ${stats.moduleName}
|
|
72
|
-
|
|
53
|
+
return stats.moduleName ? `File: ${stats.moduleName}
|
|
54
|
+
` : "";
|
|
73
55
|
}
|
|
74
56
|
function hintUnknownFiles(message) {
|
|
75
57
|
const hint = "You may need an appropriate loader to handle this file type.";
|
|
@@ -134,6 +116,24 @@ var init_format = __esm({
|
|
|
134
116
|
}
|
|
135
117
|
});
|
|
136
118
|
|
|
119
|
+
// src/constants.ts
|
|
120
|
+
import { join } from "path";
|
|
121
|
+
var PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
|
|
122
|
+
var init_constants = __esm({
|
|
123
|
+
"src/constants.ts"() {
|
|
124
|
+
"use strict";
|
|
125
|
+
init_esm();
|
|
126
|
+
PLUGIN_SWC_NAME = "rsbuild:swc";
|
|
127
|
+
PLUGIN_CSS_NAME = "rsbuild:css";
|
|
128
|
+
LOADER_PATH = join(__dirname);
|
|
129
|
+
STATIC_PATH = join(__dirname, "../static");
|
|
130
|
+
COMPILED_PATH = join(__dirname, "../compiled");
|
|
131
|
+
TS_CONFIG_FILE = "tsconfig.json";
|
|
132
|
+
HTML_REGEX = /\.html$/;
|
|
133
|
+
CSS_REGEX = /\.css$/;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
137
|
// src/helpers.ts
|
|
138
138
|
import path2 from "path";
|
|
139
139
|
import {
|
|
@@ -201,6 +201,10 @@ function formatStats(stats, options = {}) {
|
|
|
201
201
|
}
|
|
202
202
|
return {};
|
|
203
203
|
}
|
|
204
|
+
function isEmptyDir(path14) {
|
|
205
|
+
const files = fse.readdirSync(path14);
|
|
206
|
+
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
207
|
+
}
|
|
204
208
|
async function isFileExists(file) {
|
|
205
209
|
return fse.promises.access(file, fse.constants.F_OK).then(() => true).catch(() => false);
|
|
206
210
|
}
|
|
@@ -690,6 +694,7 @@ var init_config = __esm({
|
|
|
690
694
|
inlineStyles: false,
|
|
691
695
|
cssModules: {
|
|
692
696
|
auto: true,
|
|
697
|
+
namedExport: false,
|
|
693
698
|
exportGlobals: false,
|
|
694
699
|
exportLocalsConvention: "camelCase"
|
|
695
700
|
},
|
|
@@ -707,7 +712,7 @@ var init_config = __esm({
|
|
|
707
712
|
});
|
|
708
713
|
withDefaultConfig = async (rootPath, config) => {
|
|
709
714
|
const merged = mergeRsbuildConfig(createDefaultConfig(), config);
|
|
710
|
-
merged.source
|
|
715
|
+
merged.source ||= {};
|
|
711
716
|
if (!merged.source.entry) {
|
|
712
717
|
merged.source.entry = getDefaultEntry(rootPath);
|
|
713
718
|
}
|
|
@@ -962,7 +967,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
962
967
|
return {
|
|
963
968
|
entry: getEntryObject(config, "web"),
|
|
964
969
|
targets: config.output?.targets || [],
|
|
965
|
-
version: "0.7.
|
|
970
|
+
version: "0.7.2",
|
|
966
971
|
rootPath,
|
|
967
972
|
distPath,
|
|
968
973
|
cachePath,
|
|
@@ -1984,7 +1989,7 @@ function formatProxyOptions(proxyOptions) {
|
|
|
1984
1989
|
}
|
|
1985
1990
|
const handleError = (err) => logger7.error(err);
|
|
1986
1991
|
for (const opts of ret) {
|
|
1987
|
-
opts.onError
|
|
1992
|
+
opts.onError ??= handleError;
|
|
1988
1993
|
}
|
|
1989
1994
|
return ret;
|
|
1990
1995
|
}
|
|
@@ -3206,7 +3211,10 @@ var init_build = __esm({
|
|
|
3206
3211
|
const buildError = err || new Error("Rspack build failed!");
|
|
3207
3212
|
reject(buildError);
|
|
3208
3213
|
} else {
|
|
3209
|
-
compiler.close(() => {
|
|
3214
|
+
compiler.close((closeErr) => {
|
|
3215
|
+
if (closeErr) {
|
|
3216
|
+
logger10.error(closeErr);
|
|
3217
|
+
}
|
|
3210
3218
|
resolve({ stats });
|
|
3211
3219
|
});
|
|
3212
3220
|
}
|
|
@@ -3318,7 +3326,6 @@ var init_basic = __esm({
|
|
|
3318
3326
|
setup(api) {
|
|
3319
3327
|
api.modifyBundlerChain(
|
|
3320
3328
|
(chain, { env, isProd: isProd4, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
|
|
3321
|
-
var _a;
|
|
3322
3329
|
const config = api.getNormalizedConfig();
|
|
3323
3330
|
chain.name(TARGET_ID_MAP2[target]);
|
|
3324
3331
|
chain.devtool(getJsSourceMap(config));
|
|
@@ -3348,7 +3355,7 @@ var init_basic = __esm({
|
|
|
3348
3355
|
);
|
|
3349
3356
|
}
|
|
3350
3357
|
process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
|
|
3351
|
-
|
|
3358
|
+
process.env.WATCHPACK_WATCHER_LIMIT ||= "20";
|
|
3352
3359
|
}
|
|
3353
3360
|
);
|
|
3354
3361
|
}
|
|
@@ -3670,7 +3677,7 @@ var init_css = __esm({
|
|
|
3670
3677
|
if (extraPlugins.length) {
|
|
3671
3678
|
mergedConfig?.postcssOptions?.plugins.push(...extraPlugins);
|
|
3672
3679
|
}
|
|
3673
|
-
mergedConfig.postcssOptions
|
|
3680
|
+
mergedConfig.postcssOptions ||= {};
|
|
3674
3681
|
mergedConfig.postcssOptions.config = false;
|
|
3675
3682
|
return mergedConfig;
|
|
3676
3683
|
};
|
|
@@ -3684,10 +3691,7 @@ var init_css = __esm({
|
|
|
3684
3691
|
const defaultOptions2 = {
|
|
3685
3692
|
importLoaders,
|
|
3686
3693
|
modules: {
|
|
3687
|
-
|
|
3688
|
-
namedExport: false,
|
|
3689
|
-
exportGlobals: cssModules.exportGlobals,
|
|
3690
|
-
exportLocalsConvention: cssModules.exportLocalsConvention,
|
|
3694
|
+
...cssModules,
|
|
3691
3695
|
localIdentName
|
|
3692
3696
|
},
|
|
3693
3697
|
sourceMap: config.output.sourceMap.css
|
|
@@ -3721,7 +3725,7 @@ var init_css = __esm({
|
|
|
3721
3725
|
}
|
|
3722
3726
|
});
|
|
3723
3727
|
api.modifyRspackConfig(async (rspackConfig) => {
|
|
3724
|
-
rspackConfig.experiments
|
|
3728
|
+
rspackConfig.experiments ||= {};
|
|
3725
3729
|
rspackConfig.experiments.css = false;
|
|
3726
3730
|
});
|
|
3727
3731
|
}
|
|
@@ -3908,7 +3912,7 @@ var init_resolve = __esm({
|
|
|
3908
3912
|
api.modifyRspackConfig(async (rspackConfig) => {
|
|
3909
3913
|
const isTsProject = Boolean(api.context.tsconfigPath);
|
|
3910
3914
|
const config = api.getNormalizedConfig();
|
|
3911
|
-
rspackConfig.resolve
|
|
3915
|
+
rspackConfig.resolve ||= {};
|
|
3912
3916
|
if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
|
|
3913
3917
|
rspackConfig.resolve.tsConfigPath = api.context.tsconfigPath;
|
|
3914
3918
|
}
|
|
@@ -4263,7 +4267,7 @@ var init_minimize = __esm({
|
|
|
4263
4267
|
pure_funcs: pureFuncs
|
|
4264
4268
|
};
|
|
4265
4269
|
}
|
|
4266
|
-
options.format
|
|
4270
|
+
options.format ||= {};
|
|
4267
4271
|
switch (config.output.legalComments) {
|
|
4268
4272
|
case "inline":
|
|
4269
4273
|
options.format.comments = "some";
|
|
@@ -4954,7 +4958,6 @@ var init_html = __esm({
|
|
|
4954
4958
|
// ensure `crossorigin` and `nonce` can be applied to all tags
|
|
4955
4959
|
order: "post",
|
|
4956
4960
|
handler: ({ headTags, bodyTags }) => {
|
|
4957
|
-
var _a;
|
|
4958
4961
|
const config = api.getNormalizedConfig();
|
|
4959
4962
|
const { crossorigin } = config.html;
|
|
4960
4963
|
const { nonce } = config.security;
|
|
@@ -4963,15 +4966,15 @@ var init_html = __esm({
|
|
|
4963
4966
|
const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
|
|
4964
4967
|
for (const tag of allTags) {
|
|
4965
4968
|
if (tag.tag === "script" && tag.attrs?.src || tag.tag === "link" && tag.attrs?.rel === "stylesheet") {
|
|
4966
|
-
tag.attrs
|
|
4967
|
-
|
|
4969
|
+
tag.attrs ||= {};
|
|
4970
|
+
tag.attrs.crossorigin ??= formattedCrossorigin;
|
|
4968
4971
|
}
|
|
4969
4972
|
}
|
|
4970
4973
|
}
|
|
4971
4974
|
if (nonce) {
|
|
4972
4975
|
for (const tag of allTags) {
|
|
4973
4976
|
if (tag.tag === "script" || tag.tag === "style") {
|
|
4974
|
-
tag.attrs
|
|
4977
|
+
tag.attrs ??= {};
|
|
4975
4978
|
tag.attrs.nonce = nonce;
|
|
4976
4979
|
}
|
|
4977
4980
|
}
|
|
@@ -5219,17 +5222,15 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
|
|
|
5219
5222
|
});
|
|
5220
5223
|
}
|
|
5221
5224
|
function applyTransformImport(swcConfig, pluginImport) {
|
|
5222
|
-
var _a;
|
|
5223
5225
|
if (pluginImport !== false && pluginImport) {
|
|
5224
|
-
swcConfig.rspackExperiments
|
|
5225
|
-
|
|
5226
|
+
swcConfig.rspackExperiments ??= {};
|
|
5227
|
+
swcConfig.rspackExperiments.import ??= [];
|
|
5226
5228
|
swcConfig.rspackExperiments.import.push(...pluginImport);
|
|
5227
5229
|
}
|
|
5228
5230
|
}
|
|
5229
5231
|
function applySwcDecoratorConfig(swcConfig, config) {
|
|
5230
|
-
|
|
5231
|
-
swcConfig.jsc
|
|
5232
|
-
(_a = swcConfig.jsc).transform || (_a.transform = {});
|
|
5232
|
+
swcConfig.jsc ||= {};
|
|
5233
|
+
swcConfig.jsc.transform ||= {};
|
|
5233
5234
|
const { version: version2 } = config.source.decorators;
|
|
5234
5235
|
switch (version2) {
|
|
5235
5236
|
case "legacy":
|
|
@@ -5920,7 +5921,7 @@ function pluginBundleAnalyzer() {
|
|
|
5920
5921
|
if (isProd3() || !isUseAnalyzer(config)) {
|
|
5921
5922
|
return;
|
|
5922
5923
|
}
|
|
5923
|
-
config.dev
|
|
5924
|
+
config.dev ||= {};
|
|
5924
5925
|
config.dev.writeToDisk = true;
|
|
5925
5926
|
return config;
|
|
5926
5927
|
});
|
|
@@ -5995,7 +5996,7 @@ var init_rsdoctor = __esm({
|
|
|
5995
5996
|
if (registered) {
|
|
5996
5997
|
return;
|
|
5997
5998
|
}
|
|
5998
|
-
config.plugins
|
|
5999
|
+
config.plugins ||= [];
|
|
5999
6000
|
config.plugins.push(new module[pluginName]());
|
|
6000
6001
|
isAutoRegister = true;
|
|
6001
6002
|
}
|
|
@@ -6380,7 +6381,7 @@ var init_performance = __esm({
|
|
|
6380
6381
|
api.modifyRsbuildConfig((rsbuildConfig) => {
|
|
6381
6382
|
if (rsbuildConfig.performance?.profile) {
|
|
6382
6383
|
if (!rsbuildConfig.performance?.bundleAnalyze) {
|
|
6383
|
-
rsbuildConfig.performance
|
|
6384
|
+
rsbuildConfig.performance ??= {};
|
|
6384
6385
|
rsbuildConfig.performance.bundleAnalyze = {
|
|
6385
6386
|
analyzerMode: "disabled",
|
|
6386
6387
|
generateStatsFile: true
|
|
@@ -6767,6 +6768,81 @@ var init_rspackProfile = __esm({
|
|
|
6767
6768
|
}
|
|
6768
6769
|
});
|
|
6769
6770
|
|
|
6771
|
+
// src/plugins/lazyCompilation.ts
|
|
6772
|
+
var lazyCompilation_exports = {};
|
|
6773
|
+
__export(lazyCompilation_exports, {
|
|
6774
|
+
pluginLazyCompilation: () => pluginLazyCompilation
|
|
6775
|
+
});
|
|
6776
|
+
import { isRegExp } from "@rsbuild/shared";
|
|
6777
|
+
var pluginLazyCompilation;
|
|
6778
|
+
var init_lazyCompilation = __esm({
|
|
6779
|
+
"src/plugins/lazyCompilation.ts"() {
|
|
6780
|
+
"use strict";
|
|
6781
|
+
init_esm();
|
|
6782
|
+
pluginLazyCompilation = () => ({
|
|
6783
|
+
name: "rsbuild:lazy-compilation",
|
|
6784
|
+
setup(api) {
|
|
6785
|
+
api.modifyBundlerChain((chain, { isProd: isProd4, target }) => {
|
|
6786
|
+
if (isProd4 || target !== "web") {
|
|
6787
|
+
return;
|
|
6788
|
+
}
|
|
6789
|
+
const config = api.getNormalizedConfig();
|
|
6790
|
+
const options = config.dev?.lazyCompilation;
|
|
6791
|
+
if (!options) {
|
|
6792
|
+
return;
|
|
6793
|
+
}
|
|
6794
|
+
const clientRegExp = /[\\/]core[\\/]dist[\\/]client[\\/]/;
|
|
6795
|
+
const cssRegExp = /\.(?:css|less|sass|scss|styl|stylus)$/;
|
|
6796
|
+
const isExcludedModule = (name) => {
|
|
6797
|
+
return (
|
|
6798
|
+
// alway include Rsbuild client code, such as HMR
|
|
6799
|
+
clientRegExp.test(name) || // exclude CSS files because Rspack does not support it yet
|
|
6800
|
+
// TODO: remove this after Rspack supporting it
|
|
6801
|
+
cssRegExp.test(name)
|
|
6802
|
+
);
|
|
6803
|
+
};
|
|
6804
|
+
const defaultTest = (module) => {
|
|
6805
|
+
const name = module.nameForCondition();
|
|
6806
|
+
if (!name) {
|
|
6807
|
+
return false;
|
|
6808
|
+
}
|
|
6809
|
+
return !isExcludedModule(name);
|
|
6810
|
+
};
|
|
6811
|
+
const mergeOptions = () => {
|
|
6812
|
+
if (options === true) {
|
|
6813
|
+
return { test: defaultTest };
|
|
6814
|
+
}
|
|
6815
|
+
const { test } = options;
|
|
6816
|
+
if (!test) {
|
|
6817
|
+
return {
|
|
6818
|
+
...options,
|
|
6819
|
+
test: defaultTest
|
|
6820
|
+
};
|
|
6821
|
+
}
|
|
6822
|
+
return {
|
|
6823
|
+
...options,
|
|
6824
|
+
test(module) {
|
|
6825
|
+
const name = module.nameForCondition();
|
|
6826
|
+
if (!name || isExcludedModule(name)) {
|
|
6827
|
+
return false;
|
|
6828
|
+
}
|
|
6829
|
+
if (isRegExp(test)) {
|
|
6830
|
+
return name ? test.test(name) : false;
|
|
6831
|
+
}
|
|
6832
|
+
return test(module);
|
|
6833
|
+
}
|
|
6834
|
+
};
|
|
6835
|
+
};
|
|
6836
|
+
chain.experiments({
|
|
6837
|
+
...chain.get("experiments"),
|
|
6838
|
+
lazyCompilation: mergeOptions()
|
|
6839
|
+
});
|
|
6840
|
+
});
|
|
6841
|
+
}
|
|
6842
|
+
});
|
|
6843
|
+
}
|
|
6844
|
+
});
|
|
6845
|
+
|
|
6770
6846
|
// src/createRsbuild.ts
|
|
6771
6847
|
var createRsbuild_exports = {};
|
|
6772
6848
|
__export(createRsbuild_exports, {
|
|
@@ -6805,6 +6881,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6805
6881
|
const { pluginManifest: pluginManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
|
|
6806
6882
|
const { pluginModuleFederation: pluginModuleFederation2 } = await Promise.resolve().then(() => (init_moduleFederation(), moduleFederation_exports));
|
|
6807
6883
|
const { pluginRspackProfile: pluginRspackProfile2 } = await Promise.resolve().then(() => (init_rspackProfile(), rspackProfile_exports));
|
|
6884
|
+
const { pluginLazyCompilation: pluginLazyCompilation2 } = await Promise.resolve().then(() => (init_lazyCompilation(), lazyCompilation_exports));
|
|
6808
6885
|
pluginManager.addPlugins([
|
|
6809
6886
|
pluginBasic2(),
|
|
6810
6887
|
pluginEntry2(),
|
|
@@ -6839,7 +6916,8 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6839
6916
|
pluginServer2(),
|
|
6840
6917
|
pluginManifest2(),
|
|
6841
6918
|
pluginModuleFederation2(),
|
|
6842
|
-
pluginRspackProfile2()
|
|
6919
|
+
pluginRspackProfile2(),
|
|
6920
|
+
pluginLazyCompilation2()
|
|
6843
6921
|
]);
|
|
6844
6922
|
}
|
|
6845
6923
|
async function createRsbuild(options = {}) {
|
|
@@ -6970,21 +7048,21 @@ async function init({
|
|
|
6970
7048
|
watchFiles(files);
|
|
6971
7049
|
}
|
|
6972
7050
|
const { createRsbuild: createRsbuild2 } = await Promise.resolve().then(() => (init_createRsbuild(), createRsbuild_exports));
|
|
6973
|
-
config.source
|
|
7051
|
+
config.source ||= {};
|
|
6974
7052
|
config.source.define = {
|
|
6975
7053
|
...envs.publicVars,
|
|
6976
7054
|
...config.source.define
|
|
6977
7055
|
};
|
|
6978
7056
|
if (commonOpts.open && !config.dev?.startUrl) {
|
|
6979
|
-
config.dev
|
|
7057
|
+
config.dev ||= {};
|
|
6980
7058
|
config.dev.startUrl = commonOpts.open;
|
|
6981
7059
|
}
|
|
6982
7060
|
if (commonOpts.host) {
|
|
6983
|
-
config.server
|
|
7061
|
+
config.server ||= {};
|
|
6984
7062
|
config.server.host = commonOpts.host;
|
|
6985
7063
|
}
|
|
6986
7064
|
if (commonOpts.port) {
|
|
6987
|
-
config.server
|
|
7065
|
+
config.server ||= {};
|
|
6988
7066
|
config.server.port = commonOpts.port;
|
|
6989
7067
|
}
|
|
6990
7068
|
return createRsbuild2({
|
|
@@ -7039,6 +7117,7 @@ init_esm();
|
|
|
7039
7117
|
|
|
7040
7118
|
// src/cli/commands.ts
|
|
7041
7119
|
init_esm();
|
|
7120
|
+
init_helpers();
|
|
7042
7121
|
init_init();
|
|
7043
7122
|
import { existsSync } from "fs";
|
|
7044
7123
|
import { join as join12 } from "path";
|
|
@@ -7057,7 +7136,7 @@ var applyServerOptions = (command) => {
|
|
|
7057
7136
|
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");
|
|
7058
7137
|
};
|
|
7059
7138
|
function runCli() {
|
|
7060
|
-
program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
7139
|
+
program.name("rsbuild").usage("<command> [options]").version("0.7.2");
|
|
7061
7140
|
const devCommand = program.command("dev");
|
|
7062
7141
|
const buildCommand = program.command("build");
|
|
7063
7142
|
const previewCommand = program.command("preview");
|
|
@@ -7091,12 +7170,22 @@ function runCli() {
|
|
|
7091
7170
|
previewCommand.description("preview the production build locally").action(async (options) => {
|
|
7092
7171
|
try {
|
|
7093
7172
|
const rsbuild = await init({ cliOptions: options });
|
|
7094
|
-
if (rsbuild
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7173
|
+
if (rsbuild) {
|
|
7174
|
+
const { distPath } = rsbuild.context;
|
|
7175
|
+
if (!existsSync(distPath)) {
|
|
7176
|
+
throw new Error(
|
|
7177
|
+
`The output directory ${color13.yellow(
|
|
7178
|
+
distPath
|
|
7179
|
+
)} does not exist, please build the project before previewing.`
|
|
7180
|
+
);
|
|
7181
|
+
}
|
|
7182
|
+
if (isEmptyDir(distPath)) {
|
|
7183
|
+
throw new Error(
|
|
7184
|
+
`The output directory ${color13.yellow(
|
|
7185
|
+
distPath
|
|
7186
|
+
)} is empty, please build the project before previewing.`
|
|
7187
|
+
);
|
|
7188
|
+
}
|
|
7100
7189
|
}
|
|
7101
7190
|
await rsbuild?.preview();
|
|
7102
7191
|
} catch (err) {
|
|
@@ -7138,7 +7227,7 @@ function prepareCli() {
|
|
|
7138
7227
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
7139
7228
|
console.log();
|
|
7140
7229
|
}
|
|
7141
|
-
logger18.greet(` ${`Rsbuild v${"0.7.
|
|
7230
|
+
logger18.greet(` ${`Rsbuild v${"0.7.2"}`}
|
|
7142
7231
|
`);
|
|
7143
7232
|
}
|
|
7144
7233
|
|
|
@@ -7165,7 +7254,7 @@ init_config();
|
|
|
7165
7254
|
init_mergeConfig();
|
|
7166
7255
|
init_constants();
|
|
7167
7256
|
import { logger as logger19 } from "@rsbuild/shared";
|
|
7168
|
-
var version = "0.7.
|
|
7257
|
+
var version = "0.7.2";
|
|
7169
7258
|
export {
|
|
7170
7259
|
PLUGIN_CSS_NAME,
|
|
7171
7260
|
PLUGIN_SWC_NAME,
|
package/dist-types/helpers.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const getPublicPathFromChain: (chain: BundlerChain, withSlash?: b
|
|
|
23
23
|
*/
|
|
24
24
|
export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
|
|
25
25
|
export declare const isFileSync: (filePath: string) => boolean | undefined;
|
|
26
|
+
export declare function isEmptyDir(path: string): boolean;
|
|
26
27
|
/**
|
|
27
28
|
* Find first already exists file.
|
|
28
29
|
* @param files - Absolute file paths with extension.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -51,7 +51,7 @@
|
|
|
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.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"commander": "^12.1.0",
|
|
63
63
|
"connect": "3.7.0",
|
|
64
64
|
"connect-history-api-fallback": "^2.0.0",
|
|
65
|
-
"css-loader": "7.1.
|
|
65
|
+
"css-loader": "7.1.2",
|
|
66
66
|
"dotenv": "16.4.5",
|
|
67
67
|
"dotenv-expand": "11.0.6",
|
|
68
68
|
"fs-extra": "^11.2.0",
|