@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.cjs
CHANGED
|
@@ -35,23 +35,6 @@ var __publicField = (obj, key, value) => {
|
|
|
35
35
|
return value;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
// src/constants.ts
|
|
39
|
-
var import_node_path, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
|
|
40
|
-
var init_constants = __esm({
|
|
41
|
-
"src/constants.ts"() {
|
|
42
|
-
"use strict";
|
|
43
|
-
import_node_path = require("path");
|
|
44
|
-
PLUGIN_SWC_NAME = "rsbuild:swc";
|
|
45
|
-
PLUGIN_CSS_NAME = "rsbuild:css";
|
|
46
|
-
LOADER_PATH = (0, import_node_path.join)(__dirname);
|
|
47
|
-
STATIC_PATH = (0, import_node_path.join)(__dirname, "../static");
|
|
48
|
-
COMPILED_PATH = (0, import_node_path.join)(__dirname, "../compiled");
|
|
49
|
-
TS_CONFIG_FILE = "tsconfig.json";
|
|
50
|
-
HTML_REGEX = /\.html$/;
|
|
51
|
-
CSS_REGEX = /\.css$/;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
38
|
// src/client/format.ts
|
|
56
39
|
function resolveFileName(stats) {
|
|
57
40
|
if (stats.moduleIdentifier) {
|
|
@@ -65,8 +48,8 @@ function resolveFileName(stats) {
|
|
|
65
48
|
}
|
|
66
49
|
}
|
|
67
50
|
}
|
|
68
|
-
return `File: ${stats.moduleName}
|
|
69
|
-
|
|
51
|
+
return stats.moduleName ? `File: ${stats.moduleName}
|
|
52
|
+
` : "";
|
|
70
53
|
}
|
|
71
54
|
function hintUnknownFiles(message) {
|
|
72
55
|
const hint = "You may need an appropriate loader to handle this file type.";
|
|
@@ -130,6 +113,23 @@ var init_format = __esm({
|
|
|
130
113
|
}
|
|
131
114
|
});
|
|
132
115
|
|
|
116
|
+
// src/constants.ts
|
|
117
|
+
var import_node_path, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
|
|
118
|
+
var init_constants = __esm({
|
|
119
|
+
"src/constants.ts"() {
|
|
120
|
+
"use strict";
|
|
121
|
+
import_node_path = require("path");
|
|
122
|
+
PLUGIN_SWC_NAME = "rsbuild:swc";
|
|
123
|
+
PLUGIN_CSS_NAME = "rsbuild:css";
|
|
124
|
+
LOADER_PATH = (0, import_node_path.join)(__dirname);
|
|
125
|
+
STATIC_PATH = (0, import_node_path.join)(__dirname, "../static");
|
|
126
|
+
COMPILED_PATH = (0, import_node_path.join)(__dirname, "../compiled");
|
|
127
|
+
TS_CONFIG_FILE = "tsconfig.json";
|
|
128
|
+
HTML_REGEX = /\.html$/;
|
|
129
|
+
CSS_REGEX = /\.css$/;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
133
|
// src/helpers.ts
|
|
134
134
|
function formatErrorMessage(errors) {
|
|
135
135
|
const messages = errors.map((error) => hintNodePolyfill(error));
|
|
@@ -188,6 +188,10 @@ function formatStats(stats, options = {}) {
|
|
|
188
188
|
}
|
|
189
189
|
return {};
|
|
190
190
|
}
|
|
191
|
+
function isEmptyDir(path13) {
|
|
192
|
+
const files = import_shared2.fse.readdirSync(path13);
|
|
193
|
+
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
194
|
+
}
|
|
191
195
|
async function isFileExists(file) {
|
|
192
196
|
return import_shared2.fse.promises.access(file, import_shared2.fse.constants.F_OK).then(() => true).catch(() => false);
|
|
193
197
|
}
|
|
@@ -650,6 +654,7 @@ var init_config = __esm({
|
|
|
650
654
|
inlineStyles: false,
|
|
651
655
|
cssModules: {
|
|
652
656
|
auto: true,
|
|
657
|
+
namedExport: false,
|
|
653
658
|
exportGlobals: false,
|
|
654
659
|
exportLocalsConvention: "camelCase"
|
|
655
660
|
},
|
|
@@ -667,7 +672,7 @@ var init_config = __esm({
|
|
|
667
672
|
});
|
|
668
673
|
withDefaultConfig = async (rootPath, config) => {
|
|
669
674
|
const merged = mergeRsbuildConfig(createDefaultConfig(), config);
|
|
670
|
-
merged.source
|
|
675
|
+
merged.source ||= {};
|
|
671
676
|
if (!merged.source.entry) {
|
|
672
677
|
merged.source.entry = getDefaultEntry(rootPath);
|
|
673
678
|
}
|
|
@@ -911,7 +916,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
911
916
|
return {
|
|
912
917
|
entry: getEntryObject(config, "web"),
|
|
913
918
|
targets: config.output?.targets || [],
|
|
914
|
-
version: "0.7.
|
|
919
|
+
version: "0.7.2",
|
|
915
920
|
rootPath,
|
|
916
921
|
distPath,
|
|
917
922
|
cachePath,
|
|
@@ -1888,7 +1893,7 @@ function formatProxyOptions(proxyOptions) {
|
|
|
1888
1893
|
}
|
|
1889
1894
|
const handleError = (err) => import_shared18.logger.error(err);
|
|
1890
1895
|
for (const opts of ret) {
|
|
1891
|
-
opts.onError
|
|
1896
|
+
opts.onError ??= handleError;
|
|
1892
1897
|
}
|
|
1893
1898
|
return ret;
|
|
1894
1899
|
}
|
|
@@ -3083,7 +3088,10 @@ var init_build = __esm({
|
|
|
3083
3088
|
const buildError = err || new Error("Rspack build failed!");
|
|
3084
3089
|
reject(buildError);
|
|
3085
3090
|
} else {
|
|
3086
|
-
compiler.close(() => {
|
|
3091
|
+
compiler.close((closeErr) => {
|
|
3092
|
+
if (closeErr) {
|
|
3093
|
+
import_shared24.logger.error(closeErr);
|
|
3094
|
+
}
|
|
3087
3095
|
resolve({ stats });
|
|
3088
3096
|
});
|
|
3089
3097
|
}
|
|
@@ -3193,7 +3201,6 @@ var init_basic = __esm({
|
|
|
3193
3201
|
setup(api) {
|
|
3194
3202
|
api.modifyBundlerChain(
|
|
3195
3203
|
(chain, { env, isProd: isProd4, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
|
|
3196
|
-
var _a;
|
|
3197
3204
|
const config = api.getNormalizedConfig();
|
|
3198
3205
|
chain.name(import_shared25.TARGET_ID_MAP[target]);
|
|
3199
3206
|
chain.devtool((0, import_shared25.getJsSourceMap)(config));
|
|
@@ -3223,7 +3230,7 @@ var init_basic = __esm({
|
|
|
3223
3230
|
);
|
|
3224
3231
|
}
|
|
3225
3232
|
process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
|
|
3226
|
-
|
|
3233
|
+
process.env.WATCHPACK_WATCHER_LIMIT ||= "20";
|
|
3227
3234
|
}
|
|
3228
3235
|
);
|
|
3229
3236
|
}
|
|
@@ -3533,7 +3540,7 @@ var init_css = __esm({
|
|
|
3533
3540
|
if (extraPlugins.length) {
|
|
3534
3541
|
mergedConfig?.postcssOptions?.plugins.push(...extraPlugins);
|
|
3535
3542
|
}
|
|
3536
|
-
mergedConfig.postcssOptions
|
|
3543
|
+
mergedConfig.postcssOptions ||= {};
|
|
3537
3544
|
mergedConfig.postcssOptions.config = false;
|
|
3538
3545
|
return mergedConfig;
|
|
3539
3546
|
};
|
|
@@ -3547,10 +3554,7 @@ var init_css = __esm({
|
|
|
3547
3554
|
const defaultOptions2 = {
|
|
3548
3555
|
importLoaders,
|
|
3549
3556
|
modules: {
|
|
3550
|
-
|
|
3551
|
-
namedExport: false,
|
|
3552
|
-
exportGlobals: cssModules.exportGlobals,
|
|
3553
|
-
exportLocalsConvention: cssModules.exportLocalsConvention,
|
|
3557
|
+
...cssModules,
|
|
3554
3558
|
localIdentName
|
|
3555
3559
|
},
|
|
3556
3560
|
sourceMap: config.output.sourceMap.css
|
|
@@ -3584,7 +3588,7 @@ var init_css = __esm({
|
|
|
3584
3588
|
}
|
|
3585
3589
|
});
|
|
3586
3590
|
api.modifyRspackConfig(async (rspackConfig) => {
|
|
3587
|
-
rspackConfig.experiments
|
|
3591
|
+
rspackConfig.experiments ||= {};
|
|
3588
3592
|
rspackConfig.experiments.css = false;
|
|
3589
3593
|
});
|
|
3590
3594
|
}
|
|
@@ -3760,7 +3764,7 @@ var init_resolve = __esm({
|
|
|
3760
3764
|
api.modifyRspackConfig(async (rspackConfig) => {
|
|
3761
3765
|
const isTsProject = Boolean(api.context.tsconfigPath);
|
|
3762
3766
|
const config = api.getNormalizedConfig();
|
|
3763
|
-
rspackConfig.resolve
|
|
3767
|
+
rspackConfig.resolve ||= {};
|
|
3764
3768
|
if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
|
|
3765
3769
|
rspackConfig.resolve.tsConfigPath = api.context.tsconfigPath;
|
|
3766
3770
|
}
|
|
@@ -4100,7 +4104,7 @@ var init_minimize = __esm({
|
|
|
4100
4104
|
pure_funcs: pureFuncs
|
|
4101
4105
|
};
|
|
4102
4106
|
}
|
|
4103
|
-
options.format
|
|
4107
|
+
options.format ||= {};
|
|
4104
4108
|
switch (config.output.legalComments) {
|
|
4105
4109
|
case "inline":
|
|
4106
4110
|
options.format.comments = "some";
|
|
@@ -4771,7 +4775,6 @@ var init_html = __esm({
|
|
|
4771
4775
|
// ensure `crossorigin` and `nonce` can be applied to all tags
|
|
4772
4776
|
order: "post",
|
|
4773
4777
|
handler: ({ headTags, bodyTags }) => {
|
|
4774
|
-
var _a;
|
|
4775
4778
|
const config = api.getNormalizedConfig();
|
|
4776
4779
|
const { crossorigin } = config.html;
|
|
4777
4780
|
const { nonce } = config.security;
|
|
@@ -4780,15 +4783,15 @@ var init_html = __esm({
|
|
|
4780
4783
|
const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
|
|
4781
4784
|
for (const tag of allTags) {
|
|
4782
4785
|
if (tag.tag === "script" && tag.attrs?.src || tag.tag === "link" && tag.attrs?.rel === "stylesheet") {
|
|
4783
|
-
tag.attrs
|
|
4784
|
-
|
|
4786
|
+
tag.attrs ||= {};
|
|
4787
|
+
tag.attrs.crossorigin ??= formattedCrossorigin;
|
|
4785
4788
|
}
|
|
4786
4789
|
}
|
|
4787
4790
|
}
|
|
4788
4791
|
if (nonce) {
|
|
4789
4792
|
for (const tag of allTags) {
|
|
4790
4793
|
if (tag.tag === "script" || tag.tag === "style") {
|
|
4791
|
-
tag.attrs
|
|
4794
|
+
tag.attrs ??= {};
|
|
4792
4795
|
tag.attrs.nonce = nonce;
|
|
4793
4796
|
}
|
|
4794
4797
|
}
|
|
@@ -5020,17 +5023,15 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
|
|
|
5020
5023
|
});
|
|
5021
5024
|
}
|
|
5022
5025
|
function applyTransformImport(swcConfig, pluginImport) {
|
|
5023
|
-
var _a;
|
|
5024
5026
|
if (pluginImport !== false && pluginImport) {
|
|
5025
|
-
swcConfig.rspackExperiments
|
|
5026
|
-
|
|
5027
|
+
swcConfig.rspackExperiments ??= {};
|
|
5028
|
+
swcConfig.rspackExperiments.import ??= [];
|
|
5027
5029
|
swcConfig.rspackExperiments.import.push(...pluginImport);
|
|
5028
5030
|
}
|
|
5029
5031
|
}
|
|
5030
5032
|
function applySwcDecoratorConfig(swcConfig, config) {
|
|
5031
|
-
|
|
5032
|
-
swcConfig.jsc
|
|
5033
|
-
(_a = swcConfig.jsc).transform || (_a.transform = {});
|
|
5033
|
+
swcConfig.jsc ||= {};
|
|
5034
|
+
swcConfig.jsc.transform ||= {};
|
|
5034
5035
|
const { version: version2 } = config.source.decorators;
|
|
5035
5036
|
switch (version2) {
|
|
5036
5037
|
case "legacy":
|
|
@@ -5705,7 +5706,7 @@ function pluginBundleAnalyzer() {
|
|
|
5705
5706
|
if ((0, import_shared47.isProd)() || !isUseAnalyzer(config)) {
|
|
5706
5707
|
return;
|
|
5707
5708
|
}
|
|
5708
|
-
config.dev
|
|
5709
|
+
config.dev ||= {};
|
|
5709
5710
|
config.dev.writeToDisk = true;
|
|
5710
5711
|
return config;
|
|
5711
5712
|
});
|
|
@@ -5779,7 +5780,7 @@ var init_rsdoctor = __esm({
|
|
|
5779
5780
|
if (registered) {
|
|
5780
5781
|
return;
|
|
5781
5782
|
}
|
|
5782
|
-
config.plugins
|
|
5783
|
+
config.plugins ||= [];
|
|
5783
5784
|
config.plugins.push(new module2[pluginName]());
|
|
5784
5785
|
isAutoRegister = true;
|
|
5785
5786
|
}
|
|
@@ -6146,7 +6147,7 @@ var init_performance = __esm({
|
|
|
6146
6147
|
api.modifyRsbuildConfig((rsbuildConfig) => {
|
|
6147
6148
|
if (rsbuildConfig.performance?.profile) {
|
|
6148
6149
|
if (!rsbuildConfig.performance?.bundleAnalyze) {
|
|
6149
|
-
rsbuildConfig.performance
|
|
6150
|
+
rsbuildConfig.performance ??= {};
|
|
6150
6151
|
rsbuildConfig.performance.bundleAnalyze = {
|
|
6151
6152
|
analyzerMode: "disabled",
|
|
6152
6153
|
generateStatsFile: true
|
|
@@ -6527,6 +6528,80 @@ var init_rspackProfile = __esm({
|
|
|
6527
6528
|
}
|
|
6528
6529
|
});
|
|
6529
6530
|
|
|
6531
|
+
// src/plugins/lazyCompilation.ts
|
|
6532
|
+
var lazyCompilation_exports = {};
|
|
6533
|
+
__export(lazyCompilation_exports, {
|
|
6534
|
+
pluginLazyCompilation: () => pluginLazyCompilation
|
|
6535
|
+
});
|
|
6536
|
+
var import_shared56, pluginLazyCompilation;
|
|
6537
|
+
var init_lazyCompilation = __esm({
|
|
6538
|
+
"src/plugins/lazyCompilation.ts"() {
|
|
6539
|
+
"use strict";
|
|
6540
|
+
import_shared56 = require("@rsbuild/shared");
|
|
6541
|
+
pluginLazyCompilation = () => ({
|
|
6542
|
+
name: "rsbuild:lazy-compilation",
|
|
6543
|
+
setup(api) {
|
|
6544
|
+
api.modifyBundlerChain((chain, { isProd: isProd4, target }) => {
|
|
6545
|
+
if (isProd4 || target !== "web") {
|
|
6546
|
+
return;
|
|
6547
|
+
}
|
|
6548
|
+
const config = api.getNormalizedConfig();
|
|
6549
|
+
const options = config.dev?.lazyCompilation;
|
|
6550
|
+
if (!options) {
|
|
6551
|
+
return;
|
|
6552
|
+
}
|
|
6553
|
+
const clientRegExp = /[\\/]core[\\/]dist[\\/]client[\\/]/;
|
|
6554
|
+
const cssRegExp = /\.(?:css|less|sass|scss|styl|stylus)$/;
|
|
6555
|
+
const isExcludedModule = (name) => {
|
|
6556
|
+
return (
|
|
6557
|
+
// alway include Rsbuild client code, such as HMR
|
|
6558
|
+
clientRegExp.test(name) || // exclude CSS files because Rspack does not support it yet
|
|
6559
|
+
// TODO: remove this after Rspack supporting it
|
|
6560
|
+
cssRegExp.test(name)
|
|
6561
|
+
);
|
|
6562
|
+
};
|
|
6563
|
+
const defaultTest = (module2) => {
|
|
6564
|
+
const name = module2.nameForCondition();
|
|
6565
|
+
if (!name) {
|
|
6566
|
+
return false;
|
|
6567
|
+
}
|
|
6568
|
+
return !isExcludedModule(name);
|
|
6569
|
+
};
|
|
6570
|
+
const mergeOptions = () => {
|
|
6571
|
+
if (options === true) {
|
|
6572
|
+
return { test: defaultTest };
|
|
6573
|
+
}
|
|
6574
|
+
const { test } = options;
|
|
6575
|
+
if (!test) {
|
|
6576
|
+
return {
|
|
6577
|
+
...options,
|
|
6578
|
+
test: defaultTest
|
|
6579
|
+
};
|
|
6580
|
+
}
|
|
6581
|
+
return {
|
|
6582
|
+
...options,
|
|
6583
|
+
test(module2) {
|
|
6584
|
+
const name = module2.nameForCondition();
|
|
6585
|
+
if (!name || isExcludedModule(name)) {
|
|
6586
|
+
return false;
|
|
6587
|
+
}
|
|
6588
|
+
if ((0, import_shared56.isRegExp)(test)) {
|
|
6589
|
+
return name ? test.test(name) : false;
|
|
6590
|
+
}
|
|
6591
|
+
return test(module2);
|
|
6592
|
+
}
|
|
6593
|
+
};
|
|
6594
|
+
};
|
|
6595
|
+
chain.experiments({
|
|
6596
|
+
...chain.get("experiments"),
|
|
6597
|
+
lazyCompilation: mergeOptions()
|
|
6598
|
+
});
|
|
6599
|
+
});
|
|
6600
|
+
}
|
|
6601
|
+
});
|
|
6602
|
+
}
|
|
6603
|
+
});
|
|
6604
|
+
|
|
6530
6605
|
// src/createRsbuild.ts
|
|
6531
6606
|
var createRsbuild_exports = {};
|
|
6532
6607
|
__export(createRsbuild_exports, {
|
|
@@ -6564,6 +6639,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6564
6639
|
const { pluginManifest: pluginManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
|
|
6565
6640
|
const { pluginModuleFederation: pluginModuleFederation2 } = await Promise.resolve().then(() => (init_moduleFederation(), moduleFederation_exports));
|
|
6566
6641
|
const { pluginRspackProfile: pluginRspackProfile2 } = await Promise.resolve().then(() => (init_rspackProfile(), rspackProfile_exports));
|
|
6642
|
+
const { pluginLazyCompilation: pluginLazyCompilation2 } = await Promise.resolve().then(() => (init_lazyCompilation(), lazyCompilation_exports));
|
|
6567
6643
|
pluginManager.addPlugins([
|
|
6568
6644
|
pluginBasic2(),
|
|
6569
6645
|
pluginEntry2(),
|
|
@@ -6598,7 +6674,8 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6598
6674
|
pluginServer2(),
|
|
6599
6675
|
pluginManifest2(),
|
|
6600
6676
|
pluginModuleFederation2(),
|
|
6601
|
-
pluginRspackProfile2()
|
|
6677
|
+
pluginRspackProfile2(),
|
|
6678
|
+
pluginLazyCompilation2()
|
|
6602
6679
|
]);
|
|
6603
6680
|
}
|
|
6604
6681
|
async function createRsbuild(options = {}) {
|
|
@@ -6616,9 +6693,9 @@ async function createRsbuild(options = {}) {
|
|
|
6616
6693
|
);
|
|
6617
6694
|
const pluginAPI = getPluginAPI({ context, pluginManager });
|
|
6618
6695
|
context.pluginAPI = pluginAPI;
|
|
6619
|
-
(0,
|
|
6696
|
+
(0, import_shared57.debug)("add default plugins");
|
|
6620
6697
|
await applyDefaultPlugins(pluginManager, context);
|
|
6621
|
-
(0,
|
|
6698
|
+
(0, import_shared57.debug)("add default plugins done");
|
|
6622
6699
|
const provider = rsbuildConfig.provider || await getRspackProvider();
|
|
6623
6700
|
const providerInstance = await provider({
|
|
6624
6701
|
context,
|
|
@@ -6627,13 +6704,13 @@ async function createRsbuild(options = {}) {
|
|
|
6627
6704
|
setCssExtractPlugin
|
|
6628
6705
|
});
|
|
6629
6706
|
const rsbuild = {
|
|
6630
|
-
...(0,
|
|
6707
|
+
...(0, import_shared57.pick)(pluginManager, [
|
|
6631
6708
|
"addPlugins",
|
|
6632
6709
|
"getPlugins",
|
|
6633
6710
|
"removePlugins",
|
|
6634
6711
|
"isPluginExists"
|
|
6635
6712
|
]),
|
|
6636
|
-
...(0,
|
|
6713
|
+
...(0, import_shared57.pick)(pluginAPI, [
|
|
6637
6714
|
"onBeforeBuild",
|
|
6638
6715
|
"onBeforeCreateCompiler",
|
|
6639
6716
|
"onBeforeStartDevServer",
|
|
@@ -6649,7 +6726,7 @@ async function createRsbuild(options = {}) {
|
|
|
6649
6726
|
"getRsbuildConfig",
|
|
6650
6727
|
"getNormalizedConfig"
|
|
6651
6728
|
]),
|
|
6652
|
-
...(0,
|
|
6729
|
+
...(0, import_shared57.pick)(providerInstance, [
|
|
6653
6730
|
"build",
|
|
6654
6731
|
"preview",
|
|
6655
6732
|
"initConfigs",
|
|
@@ -6666,11 +6743,11 @@ async function createRsbuild(options = {}) {
|
|
|
6666
6743
|
}
|
|
6667
6744
|
return rsbuild;
|
|
6668
6745
|
}
|
|
6669
|
-
var
|
|
6746
|
+
var import_shared57, getRspackProvider, pickRsbuildConfig;
|
|
6670
6747
|
var init_createRsbuild = __esm({
|
|
6671
6748
|
"src/createRsbuild.ts"() {
|
|
6672
6749
|
"use strict";
|
|
6673
|
-
|
|
6750
|
+
import_shared57 = require("@rsbuild/shared");
|
|
6674
6751
|
init_createContext();
|
|
6675
6752
|
init_initPlugins();
|
|
6676
6753
|
init_pluginHelper();
|
|
@@ -6692,7 +6769,7 @@ var init_createRsbuild = __esm({
|
|
|
6692
6769
|
"moduleFederation",
|
|
6693
6770
|
"_privateMeta"
|
|
6694
6771
|
];
|
|
6695
|
-
return (0,
|
|
6772
|
+
return (0, import_shared57.pick)(rsbuildConfig, keys);
|
|
6696
6773
|
};
|
|
6697
6774
|
}
|
|
6698
6775
|
});
|
|
@@ -6711,7 +6788,7 @@ async function init({
|
|
|
6711
6788
|
cwd: root,
|
|
6712
6789
|
mode: cliOptions?.envMode
|
|
6713
6790
|
});
|
|
6714
|
-
if ((0,
|
|
6791
|
+
if ((0, import_shared58.isDev)()) {
|
|
6715
6792
|
onBeforeRestartServer(envs.cleanup);
|
|
6716
6793
|
}
|
|
6717
6794
|
const { content: config, filePath: configFilePath } = await loadConfig({
|
|
@@ -6728,21 +6805,21 @@ async function init({
|
|
|
6728
6805
|
watchFiles(files);
|
|
6729
6806
|
}
|
|
6730
6807
|
const { createRsbuild: createRsbuild2 } = await Promise.resolve().then(() => (init_createRsbuild(), createRsbuild_exports));
|
|
6731
|
-
config.source
|
|
6808
|
+
config.source ||= {};
|
|
6732
6809
|
config.source.define = {
|
|
6733
6810
|
...envs.publicVars,
|
|
6734
6811
|
...config.source.define
|
|
6735
6812
|
};
|
|
6736
6813
|
if (commonOpts.open && !config.dev?.startUrl) {
|
|
6737
|
-
config.dev
|
|
6814
|
+
config.dev ||= {};
|
|
6738
6815
|
config.dev.startUrl = commonOpts.open;
|
|
6739
6816
|
}
|
|
6740
6817
|
if (commonOpts.host) {
|
|
6741
|
-
config.server
|
|
6818
|
+
config.server ||= {};
|
|
6742
6819
|
config.server.host = commonOpts.host;
|
|
6743
6820
|
}
|
|
6744
6821
|
if (commonOpts.port) {
|
|
6745
|
-
config.server
|
|
6822
|
+
config.server ||= {};
|
|
6746
6823
|
config.server.port = commonOpts.port;
|
|
6747
6824
|
}
|
|
6748
6825
|
return createRsbuild2({
|
|
@@ -6751,17 +6828,17 @@ async function init({
|
|
|
6751
6828
|
});
|
|
6752
6829
|
} catch (err) {
|
|
6753
6830
|
if (isRestart) {
|
|
6754
|
-
|
|
6831
|
+
import_shared58.logger.error(err);
|
|
6755
6832
|
} else {
|
|
6756
6833
|
throw err;
|
|
6757
6834
|
}
|
|
6758
6835
|
}
|
|
6759
6836
|
}
|
|
6760
|
-
var
|
|
6837
|
+
var import_shared58, commonOpts;
|
|
6761
6838
|
var init_init = __esm({
|
|
6762
6839
|
"src/cli/init.ts"() {
|
|
6763
6840
|
"use strict";
|
|
6764
|
-
|
|
6841
|
+
import_shared58 = require("@rsbuild/shared");
|
|
6765
6842
|
init_config();
|
|
6766
6843
|
init_loadEnv();
|
|
6767
6844
|
init_restart();
|
|
@@ -6779,7 +6856,7 @@ __export(src_exports, {
|
|
|
6779
6856
|
defineConfig: () => defineConfig,
|
|
6780
6857
|
loadConfig: () => loadConfig,
|
|
6781
6858
|
loadEnv: () => loadEnv,
|
|
6782
|
-
logger: () =>
|
|
6859
|
+
logger: () => import_shared61.logger,
|
|
6783
6860
|
mergeRsbuildConfig: () => mergeRsbuildConfig,
|
|
6784
6861
|
rspack: () => import_core10.rspack,
|
|
6785
6862
|
version: () => version
|
|
@@ -6811,8 +6888,9 @@ __export(internal_exports, {
|
|
|
6811
6888
|
// src/cli/commands.ts
|
|
6812
6889
|
var import_node_fs5 = require("fs");
|
|
6813
6890
|
var import_node_path28 = require("path");
|
|
6814
|
-
var
|
|
6891
|
+
var import_shared59 = require("@rsbuild/shared");
|
|
6815
6892
|
var import_commander = require("../compiled/commander/index.js");
|
|
6893
|
+
init_helpers();
|
|
6816
6894
|
init_init();
|
|
6817
6895
|
var applyCommonOptions = (command) => {
|
|
6818
6896
|
command.option(
|
|
@@ -6827,7 +6905,7 @@ var applyServerOptions = (command) => {
|
|
|
6827
6905
|
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");
|
|
6828
6906
|
};
|
|
6829
6907
|
function runCli() {
|
|
6830
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
6908
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.2");
|
|
6831
6909
|
const devCommand = import_commander.program.command("dev");
|
|
6832
6910
|
const buildCommand = import_commander.program.command("build");
|
|
6833
6911
|
const previewCommand = import_commander.program.command("preview");
|
|
@@ -6841,8 +6919,8 @@ function runCli() {
|
|
|
6841
6919
|
const rsbuild = await init({ cliOptions: options });
|
|
6842
6920
|
await rsbuild?.startDevServer();
|
|
6843
6921
|
} catch (err) {
|
|
6844
|
-
|
|
6845
|
-
|
|
6922
|
+
import_shared59.logger.error("Failed to start dev server.");
|
|
6923
|
+
import_shared59.logger.error(err);
|
|
6846
6924
|
process.exit(1);
|
|
6847
6925
|
}
|
|
6848
6926
|
});
|
|
@@ -6853,25 +6931,35 @@ function runCli() {
|
|
|
6853
6931
|
watch: options.watch
|
|
6854
6932
|
});
|
|
6855
6933
|
} catch (err) {
|
|
6856
|
-
|
|
6857
|
-
|
|
6934
|
+
import_shared59.logger.error("Failed to build.");
|
|
6935
|
+
import_shared59.logger.error(err);
|
|
6858
6936
|
process.exit(1);
|
|
6859
6937
|
}
|
|
6860
6938
|
});
|
|
6861
6939
|
previewCommand.description("preview the production build locally").action(async (options) => {
|
|
6862
6940
|
try {
|
|
6863
6941
|
const rsbuild = await init({ cliOptions: options });
|
|
6864
|
-
if (rsbuild
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6942
|
+
if (rsbuild) {
|
|
6943
|
+
const { distPath } = rsbuild.context;
|
|
6944
|
+
if (!(0, import_node_fs5.existsSync)(distPath)) {
|
|
6945
|
+
throw new Error(
|
|
6946
|
+
`The output directory ${import_shared59.color.yellow(
|
|
6947
|
+
distPath
|
|
6948
|
+
)} does not exist, please build the project before previewing.`
|
|
6949
|
+
);
|
|
6950
|
+
}
|
|
6951
|
+
if (isEmptyDir(distPath)) {
|
|
6952
|
+
throw new Error(
|
|
6953
|
+
`The output directory ${import_shared59.color.yellow(
|
|
6954
|
+
distPath
|
|
6955
|
+
)} is empty, please build the project before previewing.`
|
|
6956
|
+
);
|
|
6957
|
+
}
|
|
6870
6958
|
}
|
|
6871
6959
|
await rsbuild?.preview();
|
|
6872
6960
|
} catch (err) {
|
|
6873
|
-
|
|
6874
|
-
|
|
6961
|
+
import_shared59.logger.error("Failed to start preview server.");
|
|
6962
|
+
import_shared59.logger.error(err);
|
|
6875
6963
|
process.exit(1);
|
|
6876
6964
|
}
|
|
6877
6965
|
});
|
|
@@ -6885,8 +6973,8 @@ function runCli() {
|
|
|
6885
6973
|
writeToDisk: true
|
|
6886
6974
|
});
|
|
6887
6975
|
} catch (err) {
|
|
6888
|
-
|
|
6889
|
-
|
|
6976
|
+
import_shared59.logger.error("Failed to inspect config.");
|
|
6977
|
+
import_shared59.logger.error(err);
|
|
6890
6978
|
process.exit(1);
|
|
6891
6979
|
}
|
|
6892
6980
|
});
|
|
@@ -6894,7 +6982,7 @@ function runCli() {
|
|
|
6894
6982
|
}
|
|
6895
6983
|
|
|
6896
6984
|
// src/cli/prepare.ts
|
|
6897
|
-
var
|
|
6985
|
+
var import_shared60 = require("@rsbuild/shared");
|
|
6898
6986
|
function initNodeEnv() {
|
|
6899
6987
|
if (!process.env.NODE_ENV) {
|
|
6900
6988
|
const command = process.argv[2];
|
|
@@ -6907,7 +6995,7 @@ function prepareCli() {
|
|
|
6907
6995
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
6908
6996
|
console.log();
|
|
6909
6997
|
}
|
|
6910
|
-
|
|
6998
|
+
import_shared60.logger.greet(` ${`Rsbuild v${"0.7.2"}`}
|
|
6911
6999
|
`);
|
|
6912
7000
|
}
|
|
6913
7001
|
|
|
@@ -6930,10 +7018,10 @@ init_prodServer();
|
|
|
6930
7018
|
init_loadEnv();
|
|
6931
7019
|
init_createRsbuild();
|
|
6932
7020
|
init_config();
|
|
6933
|
-
var
|
|
7021
|
+
var import_shared61 = require("@rsbuild/shared");
|
|
6934
7022
|
init_mergeConfig();
|
|
6935
7023
|
init_constants();
|
|
6936
|
-
var version = "0.7.
|
|
7024
|
+
var version = "0.7.2";
|
|
6937
7025
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6938
7026
|
0 && (module.exports = {
|
|
6939
7027
|
PLUGIN_CSS_NAME,
|