@rsbuild/core 1.3.20 → 1.3.21
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 +18 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/client/hmr.js +15 -12
- package/dist/index.cjs +128 -117
- package/dist/index.js +124 -113
- package/dist-types/config.d.ts +1 -29
- package/dist-types/helpers/index.d.ts +7 -1
- package/dist-types/helpers/path.d.ts +2 -3
- package/dist-types/inspectConfig.d.ts +35 -0
- package/dist-types/provider/helpers.d.ts +1 -1
- package/dist-types/provider/initConfigs.d.ts +9 -0
- package/dist-types/types/config.d.ts +4 -3
- package/dist-types/types/context.d.ts +20 -1
- package/dist-types/types/utils.d.ts +7 -2
- package/package.json +4 -4
- package/dist-types/provider/inspectConfig.d.ts +0 -6
package/dist/index.cjs
CHANGED
|
@@ -1053,17 +1053,15 @@ for(var __webpack_i__ in (()=>{
|
|
|
1053
1053
|
getChainUtils: ()=>getChainUtils,
|
|
1054
1054
|
getConfigUtils: ()=>getConfigUtils,
|
|
1055
1055
|
getHTMLPlugin: ()=>getHTMLPlugin,
|
|
1056
|
-
getRsbuildInspectConfig: ()=>getRsbuildInspectConfig,
|
|
1057
1056
|
getStatsOptions: ()=>getStatsOptions,
|
|
1058
1057
|
initRsbuildConfig: ()=>initRsbuildConfig,
|
|
1058
|
+
inspectConfig: ()=>inspectConfig,
|
|
1059
1059
|
modifyBundlerChain: ()=>modifyBundlerChain,
|
|
1060
|
-
outputInspectConfigFiles: ()=>outputInspectConfigFiles,
|
|
1061
1060
|
prettyTime: ()=>prettyTime,
|
|
1062
1061
|
registerBuildHook: ()=>registerBuildHook,
|
|
1063
1062
|
registerDevHook: ()=>registerDevHook,
|
|
1064
1063
|
setCssExtractPlugin: ()=>setCssExtractPlugin,
|
|
1065
|
-
setHTMLPlugin: ()=>setHTMLPlugin
|
|
1066
|
-
stringifyConfig: ()=>stringifyConfig
|
|
1064
|
+
setHTMLPlugin: ()=>setHTMLPlugin
|
|
1067
1065
|
});
|
|
1068
1066
|
let core_namespaceObject = require("@rspack/core");
|
|
1069
1067
|
var core_default = __webpack_require__.n(core_namespaceObject);
|
|
@@ -1071,6 +1069,8 @@ for(var __webpack_i__ in (()=>{
|
|
|
1071
1069
|
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
1072
1070
|
let external_node_path_namespaceObject = require("node:path");
|
|
1073
1071
|
var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject), main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.2/node_modules/dotenv-expand/lib/main.js");
|
|
1072
|
+
let external_node_crypto_namespaceObject = require("node:crypto");
|
|
1073
|
+
var external_node_crypto_default = __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
1074
1074
|
let external_node_url_namespaceObject = require("node:url");
|
|
1075
1075
|
var cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
|
|
1076
1076
|
let index_js_namespaceObject = require("../compiled/picocolors/index.js");
|
|
@@ -1130,9 +1130,6 @@ for(var __webpack_i__ in (()=>{
|
|
|
1130
1130
|
'*'
|
|
1131
1131
|
].some((key)=>values.includes(key));
|
|
1132
1132
|
};
|
|
1133
|
-
function getAbsolutePath(base, filepath) {
|
|
1134
|
-
return (0, external_node_path_namespaceObject.isAbsolute)(filepath) ? filepath : (0, external_node_path_namespaceObject.join)(base, filepath);
|
|
1135
|
-
}
|
|
1136
1133
|
isDebug() && (rslog_index_js_namespaceObject.logger.level = 'verbose'), rslog_index_js_namespaceObject.logger.override({
|
|
1137
1134
|
debug: (message, ...args)=>{
|
|
1138
1135
|
if ('verbose' !== rslog_index_js_namespaceObject.logger.level) return;
|
|
@@ -1143,7 +1140,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1143
1140
|
console.log(` ${index_js_default().magenta('rsbuild')} ${time} ${message}`, ...args);
|
|
1144
1141
|
}
|
|
1145
1142
|
});
|
|
1146
|
-
let getCompiledPath = (packageName)=>(0, external_node_path_namespaceObject.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, external_node_path_namespaceObject.isAbsolute)(filePath) ? filePath : (0, external_node_path_namespaceObject.
|
|
1143
|
+
let getCompiledPath = (packageName)=>(0, external_node_path_namespaceObject.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, external_node_path_namespaceObject.isAbsolute)(filePath) ? filePath : (0, external_node_path_namespaceObject.join)(base, filePath), getPathnameFromUrl = (publicPath)=>{
|
|
1147
1144
|
try {
|
|
1148
1145
|
return publicPath ? new URL(publicPath).pathname : publicPath;
|
|
1149
1146
|
} catch (err) {
|
|
@@ -1361,7 +1358,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1361
1358
|
}
|
|
1362
1359
|
return {};
|
|
1363
1360
|
}
|
|
1364
|
-
let rspackMinVersion = '1.
|
|
1361
|
+
let rspackMinVersion = '1.2.4', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
|
|
1365
1362
|
process.env.NODE_ENV = env;
|
|
1366
1363
|
}, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype, castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
|
|
1367
1364
|
arr
|
|
@@ -1535,9 +1532,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1535
1532
|
if (void 0 !== result) return result;
|
|
1536
1533
|
}while (loc !== (loc = external_node_path_namespaceObject.dirname(loc)));
|
|
1537
1534
|
}
|
|
1538
|
-
let configCache = {}, external_node_module_namespaceObject = require("node:module"),
|
|
1539
|
-
var rspack_chain_index_js_default = __webpack_require__.n(rspack_chain_index_js_namespaceObject);
|
|
1540
|
-
let OVERRIDE_PATHS = [
|
|
1535
|
+
let configCache = {}, external_node_module_namespaceObject = require("node:module"), OVERRIDE_PATHS = [
|
|
1541
1536
|
'performance.removeConsole',
|
|
1542
1537
|
'output.inlineScripts',
|
|
1543
1538
|
'output.inlineStyles',
|
|
@@ -1584,6 +1579,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
1584
1579
|
}, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), config_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), getDefaultDevConfig = ()=>({
|
|
1585
1580
|
hmr: !0,
|
|
1586
1581
|
liveReload: !0,
|
|
1582
|
+
watchFiles: [],
|
|
1587
1583
|
assetPrefix: DEFAULT_ASSET_PREFIX,
|
|
1588
1584
|
writeToDisk: !1,
|
|
1589
1585
|
cliShortcuts: !1,
|
|
@@ -1722,14 +1718,19 @@ for(var __webpack_i__ in (()=>{
|
|
|
1722
1718
|
await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
|
|
1723
1719
|
}
|
|
1724
1720
|
return merged;
|
|
1725
|
-
}, normalizeConfig = (config)=>
|
|
1721
|
+
}, normalizeConfig = (config)=>{
|
|
1722
|
+
let mergedConfig = mergeRsbuildConfig({
|
|
1726
1723
|
...createDefaultConfig(),
|
|
1727
1724
|
mode: (()=>{
|
|
1728
1725
|
if (config.mode) return config.mode;
|
|
1729
1726
|
let nodeEnv = getNodeEnv();
|
|
1730
1727
|
return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
|
|
1731
1728
|
})()
|
|
1732
|
-
}, config);
|
|
1729
|
+
}, config), { watchFiles } = mergedConfig.dev;
|
|
1730
|
+
return Array.isArray(watchFiles) || (mergedConfig.dev.watchFiles = [
|
|
1731
|
+
watchFiles
|
|
1732
|
+
]), mergedConfig;
|
|
1733
|
+
};
|
|
1733
1734
|
function defineConfig(config) {
|
|
1734
1735
|
return config;
|
|
1735
1736
|
}
|
|
@@ -1804,71 +1805,6 @@ for(var __webpack_i__ in (()=>{
|
|
|
1804
1805
|
filePath: configFilePath
|
|
1805
1806
|
};
|
|
1806
1807
|
}
|
|
1807
|
-
let normalizePluginObject = (plugin)=>{
|
|
1808
|
-
let { setup: _, ...rest } = plugin;
|
|
1809
|
-
return {
|
|
1810
|
-
...rest,
|
|
1811
|
-
setup () {}
|
|
1812
|
-
};
|
|
1813
|
-
}, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
|
|
1814
|
-
let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
|
|
1815
|
-
...rsbuildConfig,
|
|
1816
|
-
plugins: pluginManager.getPlugins().map(normalizePluginObject)
|
|
1817
|
-
}, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
|
|
1818
|
-
for (let [name, config] of Object.entries(environments)){
|
|
1819
|
-
let debugConfig = {
|
|
1820
|
-
...config,
|
|
1821
|
-
plugins: pluginManager.getPlugins({
|
|
1822
|
-
environment: name
|
|
1823
|
-
}).map(normalizePluginObject)
|
|
1824
|
-
};
|
|
1825
|
-
rawEnvironmentConfigs.push({
|
|
1826
|
-
name,
|
|
1827
|
-
content: stringifyConfig(debugConfig, inspectOptions.verbose)
|
|
1828
|
-
}), environmentConfigs[name] = debugConfig;
|
|
1829
|
-
}
|
|
1830
|
-
return {
|
|
1831
|
-
rsbuildConfig,
|
|
1832
|
-
rawRsbuildConfig,
|
|
1833
|
-
environmentConfigs: environments,
|
|
1834
|
-
rawEnvironmentConfigs
|
|
1835
|
-
};
|
|
1836
|
-
};
|
|
1837
|
-
async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
|
|
1838
|
-
let { outputPath } = inspectOptions, files = [
|
|
1839
|
-
...rawEnvironmentConfigs.map(({ name, content })=>{
|
|
1840
|
-
if (1 === rawEnvironmentConfigs.length) return {
|
|
1841
|
-
path: (0, external_node_path_namespaceObject.join)(outputPath, 'rsbuild.config.mjs'),
|
|
1842
|
-
label: 'Rsbuild config',
|
|
1843
|
-
content
|
|
1844
|
-
};
|
|
1845
|
-
let outputFile = `rsbuild.config.${name}.mjs`;
|
|
1846
|
-
return {
|
|
1847
|
-
path: (0, external_node_path_namespaceObject.join)(outputPath, outputFile),
|
|
1848
|
-
label: `Rsbuild config (${name})`,
|
|
1849
|
-
content
|
|
1850
|
-
};
|
|
1851
|
-
}),
|
|
1852
|
-
...rawBundlerConfigs.map(({ name, content })=>{
|
|
1853
|
-
let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, external_node_path_namespaceObject.join)(outputPath, outputFile);
|
|
1854
|
-
return external_node_fs_default().existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
|
|
1855
|
-
path: outputFilePath,
|
|
1856
|
-
label: `${upperFirst(configType)} Config (${name})`,
|
|
1857
|
-
content
|
|
1858
|
-
};
|
|
1859
|
-
})
|
|
1860
|
-
];
|
|
1861
|
-
await external_node_fs_default().promises.mkdir(outputPath, {
|
|
1862
|
-
recursive: !0
|
|
1863
|
-
}), await Promise.all(files.map(async (item)=>external_node_fs_default().promises.writeFile(item.path, `export default ${item.content}`)));
|
|
1864
|
-
let fileInfos = files.map((item)=>` - ${index_js_default().bold(index_js_default().yellow(item.label))}: ${index_js_default().underline(item.path)}`).join('\n');
|
|
1865
|
-
rslog_index_js_namespaceObject.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
1866
|
-
}
|
|
1867
|
-
function stringifyConfig(config, verbose) {
|
|
1868
|
-
return (0, rspack_chain_index_js_default().toString)(config, {
|
|
1869
|
-
verbose
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
1808
|
let normalizePublicDirs = (publicDir)=>{
|
|
1873
1809
|
if (!1 === publicDir) return [];
|
|
1874
1810
|
let defaultConfig = {
|
|
@@ -2237,12 +2173,12 @@ for(var __webpack_i__ in (()=>{
|
|
|
2237
2173
|
}, {});
|
|
2238
2174
|
async function updateEnvironmentContext(context, configs) {
|
|
2239
2175
|
for (let [index, [name, config]] of (context.environments ||= {}, Object.entries(configs).entries())){
|
|
2240
|
-
let
|
|
2176
|
+
let browserslist = await getBrowserslistByEnvironment(context.rootPath, config), { entry = {}, tsconfigPath } = config.source, htmlPaths = getEnvironmentHTMLPaths(entry, config), environmentContext = {
|
|
2241
2177
|
index,
|
|
2242
2178
|
name,
|
|
2243
2179
|
distPath: function(cwd, config) {
|
|
2244
2180
|
var _config_output_distPath, _config_output;
|
|
2245
|
-
return
|
|
2181
|
+
return ensureAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
|
|
2246
2182
|
}(context.rootPath, config),
|
|
2247
2183
|
entry,
|
|
2248
2184
|
browserslist,
|
|
@@ -2257,9 +2193,9 @@ for(var __webpack_i__ in (()=>{
|
|
|
2257
2193
|
}
|
|
2258
2194
|
}
|
|
2259
2195
|
async function createContext(options, userConfig) {
|
|
2260
|
-
let { cwd } = options, rootPath = userConfig.root ?
|
|
2196
|
+
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
|
|
2261
2197
|
return {
|
|
2262
|
-
version: "1.3.
|
|
2198
|
+
version: "1.3.21",
|
|
2263
2199
|
rootPath,
|
|
2264
2200
|
distPath: '',
|
|
2265
2201
|
cachePath,
|
|
@@ -2396,7 +2332,8 @@ for(var __webpack_i__ in (()=>{
|
|
|
2396
2332
|
};
|
|
2397
2333
|
api.onCloseDevServer(clean), api.onCloseBuild(clean);
|
|
2398
2334
|
}
|
|
2399
|
-
});
|
|
2335
|
+
}), rspack_chain_index_js_namespaceObject = require("../compiled/rspack-chain/index.js");
|
|
2336
|
+
var rspack_chain_index_js_default = __webpack_require__.n(rspack_chain_index_js_namespaceObject);
|
|
2400
2337
|
async function modifyBundlerChain(context, utils) {
|
|
2401
2338
|
var _utils_environment_config_tools;
|
|
2402
2339
|
rslog_index_js_namespaceObject.logger.debug('modify bundler chain');
|
|
@@ -2582,8 +2519,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2582
2519
|
}), isUseAnalyzer = (config)=>{
|
|
2583
2520
|
var _config_performance;
|
|
2584
2521
|
return process.env.BUNDLE_ANALYZE || (null == (_config_performance = config.performance) ? void 0 : _config_performance.bundleAnalyze);
|
|
2585
|
-
}
|
|
2586
|
-
var external_node_crypto_default = __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
2522
|
+
};
|
|
2587
2523
|
async function validateWebpackCache(cacheDirectory, buildDependencies) {
|
|
2588
2524
|
let configFile = (0, external_node_path_namespaceObject.join)(cacheDirectory, 'buildDependencies.json');
|
|
2589
2525
|
if (await isFileExists(configFile)) {
|
|
@@ -2635,7 +2571,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2635
2571
|
setup (api) {
|
|
2636
2572
|
let cacheEnabled = !1;
|
|
2637
2573
|
api.modifyBundlerChain(async (chain, { environment, env })=>{
|
|
2638
|
-
var
|
|
2574
|
+
var data;
|
|
2639
2575
|
let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
|
|
2640
2576
|
if (!1 === buildCache) return;
|
|
2641
2577
|
cacheEnabled = !0;
|
|
@@ -2645,7 +2581,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
2645
2581
|
userBuildDependencies: cacheConfig.buildDependencies
|
|
2646
2582
|
} : {});
|
|
2647
2583
|
'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
|
|
2648
|
-
let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${
|
|
2584
|
+
let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${data = JSON.stringify(cacheConfig.cacheDigest), external_node_crypto_default().hash ? external_node_crypto_default().hash('sha256', data, 'hex').slice(0, 16) : external_node_crypto_default().createHash('sha256').update(data).digest('hex').slice(0, 16)}` : `${environment.name}-${env}`;
|
|
2649
2585
|
'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
|
|
2650
2586
|
...chain.get('experiments'),
|
|
2651
2587
|
cache: {
|
|
@@ -4785,14 +4721,75 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4785
4721
|
});
|
|
4786
4722
|
});
|
|
4787
4723
|
}
|
|
4788
|
-
}),
|
|
4789
|
-
|
|
4724
|
+
}), normalizePluginObject = (plugin)=>{
|
|
4725
|
+
let { setup: _, ...rest } = plugin;
|
|
4726
|
+
return {
|
|
4727
|
+
...rest,
|
|
4728
|
+
setup () {}
|
|
4729
|
+
};
|
|
4730
|
+
}, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
|
|
4731
|
+
let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
|
|
4732
|
+
...rsbuildConfig,
|
|
4733
|
+
plugins: pluginManager.getPlugins().map(normalizePluginObject)
|
|
4734
|
+
}, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
|
|
4735
|
+
for (let [name, config] of Object.entries(environments)){
|
|
4736
|
+
let debugConfig = {
|
|
4737
|
+
...config,
|
|
4738
|
+
plugins: pluginManager.getPlugins({
|
|
4739
|
+
environment: name
|
|
4740
|
+
}).map(normalizePluginObject)
|
|
4741
|
+
};
|
|
4742
|
+
rawEnvironmentConfigs.push({
|
|
4743
|
+
name,
|
|
4744
|
+
content: stringifyConfig(debugConfig, inspectOptions.verbose)
|
|
4745
|
+
}), environmentConfigs[name] = debugConfig;
|
|
4746
|
+
}
|
|
4747
|
+
return {
|
|
4748
|
+
rsbuildConfig,
|
|
4749
|
+
rawRsbuildConfig,
|
|
4750
|
+
environmentConfigs: environments,
|
|
4751
|
+
rawEnvironmentConfigs
|
|
4752
|
+
};
|
|
4753
|
+
};
|
|
4754
|
+
async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
|
|
4755
|
+
let { outputPath } = inspectOptions, files = [
|
|
4756
|
+
...rawEnvironmentConfigs.map(({ name, content })=>{
|
|
4757
|
+
if (1 === rawEnvironmentConfigs.length) return {
|
|
4758
|
+
path: (0, external_node_path_namespaceObject.join)(outputPath, 'rsbuild.config.mjs'),
|
|
4759
|
+
label: 'Rsbuild config',
|
|
4760
|
+
content
|
|
4761
|
+
};
|
|
4762
|
+
let outputFile = `rsbuild.config.${name}.mjs`;
|
|
4763
|
+
return {
|
|
4764
|
+
path: (0, external_node_path_namespaceObject.join)(outputPath, outputFile),
|
|
4765
|
+
label: `Rsbuild config (${name})`,
|
|
4766
|
+
content
|
|
4767
|
+
};
|
|
4768
|
+
}),
|
|
4769
|
+
...rawBundlerConfigs.map(({ name, content })=>{
|
|
4770
|
+
let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, external_node_path_namespaceObject.join)(outputPath, outputFile);
|
|
4771
|
+
return external_node_fs_default().existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
|
|
4772
|
+
path: outputFilePath,
|
|
4773
|
+
label: `${upperFirst(configType)} Config (${name})`,
|
|
4774
|
+
content
|
|
4775
|
+
};
|
|
4776
|
+
})
|
|
4777
|
+
];
|
|
4778
|
+
await external_node_fs_default().promises.mkdir(outputPath, {
|
|
4779
|
+
recursive: !0
|
|
4780
|
+
}), await Promise.all(files.map(async (item)=>external_node_fs_default().promises.writeFile(item.path, `export default ${item.content}`)));
|
|
4781
|
+
let fileInfos = files.map((item)=>` - ${index_js_default().bold(index_js_default().yellow(item.label))}: ${index_js_default().underline(item.path)}`).join('\n');
|
|
4782
|
+
rslog_index_js_namespaceObject.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
4783
|
+
}
|
|
4784
|
+
function stringifyConfig(config, verbose) {
|
|
4785
|
+
return (0, rspack_chain_index_js_default().toString)(config, {
|
|
4786
|
+
verbose
|
|
4787
|
+
});
|
|
4788
|
+
}
|
|
4789
|
+
let getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath) : (0, external_node_path_namespaceObject.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
|
|
4790
|
+
async function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions = {}, bundler = 'rspack' }) {
|
|
4790
4791
|
inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : getNodeEnv() || setNodeEnv('development');
|
|
4791
|
-
let
|
|
4792
|
-
context,
|
|
4793
|
-
pluginManager,
|
|
4794
|
-
rsbuildOptions
|
|
4795
|
-
})).rspackConfigs, rawBundlerConfigs = rspackConfigs.map((config, index)=>({
|
|
4792
|
+
let rawBundlerConfigs = bundlerConfigs.map((config, index)=>({
|
|
4796
4793
|
name: config.name || String(index),
|
|
4797
4794
|
content: stringifyConfig(config, inspectOptions.verbose)
|
|
4798
4795
|
})), { rsbuildConfig, rawRsbuildConfig, environmentConfigs, rawEnvironmentConfigs } = getRsbuildInspectConfig({
|
|
@@ -4807,7 +4804,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4807
4804
|
...inspectOptions,
|
|
4808
4805
|
outputPath
|
|
4809
4806
|
},
|
|
4810
|
-
configType:
|
|
4807
|
+
configType: bundler
|
|
4811
4808
|
}), {
|
|
4812
4809
|
rsbuildConfig: rawRsbuildConfig,
|
|
4813
4810
|
environmentConfigs: rawEnvironmentConfigs.map((r)=>r.content),
|
|
@@ -4815,7 +4812,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4815
4812
|
origin: {
|
|
4816
4813
|
rsbuildConfig,
|
|
4817
4814
|
environmentConfigs,
|
|
4818
|
-
bundlerConfigs
|
|
4815
|
+
bundlerConfigs
|
|
4819
4816
|
}
|
|
4820
4817
|
};
|
|
4821
4818
|
}
|
|
@@ -4988,19 +4985,26 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4988
4985
|
getPluginAPI: context.getPluginAPI,
|
|
4989
4986
|
pluginManager
|
|
4990
4987
|
}), await modifyRsbuildConfig(context);
|
|
4991
|
-
let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
|
|
4988
|
+
let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig, tsconfigPaths = new Set();
|
|
4992
4989
|
for (let [name, config] of Object.entries(mergedEnvironments)){
|
|
4993
|
-
let environmentConfig = await modifyEnvironmentConfig(context, config, name)
|
|
4994
|
-
environments[name] = {
|
|
4990
|
+
let environmentConfig = await modifyEnvironmentConfig(context, config, name), normalizedEnvironmentConfig = {
|
|
4995
4991
|
...environmentConfig,
|
|
4996
4992
|
dev: {
|
|
4997
4993
|
...environmentConfig.dev,
|
|
4998
4994
|
...rsbuildSharedDev
|
|
4999
4995
|
},
|
|
5000
4996
|
server
|
|
5001
|
-
};
|
|
4997
|
+
}, { tsconfigPath } = normalizedEnvironmentConfig.source;
|
|
4998
|
+
if (tsconfigPath) {
|
|
4999
|
+
let absoluteTsconfigPath = ensureAbsolutePath(context.rootPath, tsconfigPath);
|
|
5000
|
+
normalizedEnvironmentConfig.source.tsconfigPath = absoluteTsconfigPath, tsconfigPaths.add(absoluteTsconfigPath);
|
|
5001
|
+
}
|
|
5002
|
+
environments[name] = normalizedEnvironmentConfig;
|
|
5002
5003
|
}
|
|
5003
|
-
|
|
5004
|
+
tsconfigPaths.size && 'prefer-tsconfig' === normalizedBaseConfig.resolve.aliasStrategy && normalizedBaseConfig.dev.watchFiles.push({
|
|
5005
|
+
paths: Array.from(tsconfigPaths),
|
|
5006
|
+
type: 'reload-server'
|
|
5007
|
+
}), context.normalizedConfig = {
|
|
5004
5008
|
...normalizedBaseConfig,
|
|
5005
5009
|
environments
|
|
5006
5010
|
}, await updateEnvironmentContext(context, environments);
|
|
@@ -5069,7 +5073,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5069
5073
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
5070
5074
|
cliOptions && (commonOpts = cliOptions);
|
|
5071
5075
|
try {
|
|
5072
|
-
let cwd = process.cwd(), root = commonOpts.root ?
|
|
5076
|
+
let cwd = process.cwd(), root = commonOpts.root ? ensureAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
|
|
5073
5077
|
cwd: root,
|
|
5074
5078
|
rsbuildConfig: ()=>init_loadConfig(root),
|
|
5075
5079
|
environment: commonOpts.environment,
|
|
@@ -5079,17 +5083,16 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5079
5083
|
}
|
|
5080
5084
|
});
|
|
5081
5085
|
return rsbuild.onBeforeCreateCompiler(()=>{
|
|
5082
|
-
var _config_dev;
|
|
5083
5086
|
if ('dev' !== rsbuild.context.action && !isBuildWatch) return;
|
|
5084
5087
|
let files = [], config = rsbuild.getNormalizedConfig();
|
|
5085
|
-
if (
|
|
5086
|
-
if ('reload-server' !==
|
|
5087
|
-
let paths = castArray(
|
|
5088
|
-
|
|
5088
|
+
if (config.dev.watchFiles) for (let watchConfig of config.dev.watchFiles){
|
|
5089
|
+
if ('reload-server' !== watchConfig.type) continue;
|
|
5090
|
+
let paths = castArray(watchConfig.paths);
|
|
5091
|
+
watchConfig.options ? watchFilesForRestart({
|
|
5089
5092
|
files: paths,
|
|
5090
5093
|
rsbuild,
|
|
5091
5094
|
isBuildWatch,
|
|
5092
|
-
watchOptions:
|
|
5095
|
+
watchOptions: watchConfig.options
|
|
5093
5096
|
}) : files.push(...paths);
|
|
5094
5097
|
}
|
|
5095
5098
|
watchFilesForRestart({
|
|
@@ -5738,7 +5741,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5738
5741
|
clientPaths,
|
|
5739
5742
|
devConfig,
|
|
5740
5743
|
serverConfig
|
|
5741
|
-
}), { base } = serverConfig, assetPrefixes = publicPaths.map(
|
|
5744
|
+
}), { base } = serverConfig, assetPrefixes = publicPaths.map(getPathnameFromUrl).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
|
|
5742
5745
|
let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
|
|
5743
5746
|
assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
|
|
5744
5747
|
req.url = url, next(...args);
|
|
@@ -6637,12 +6640,20 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6637
6640
|
});
|
|
6638
6641
|
return rspackConfigs;
|
|
6639
6642
|
},
|
|
6640
|
-
inspectConfig
|
|
6643
|
+
async inspectConfig (inspectOptions) {
|
|
6644
|
+
let bundlerConfigs = (await initConfigs({
|
|
6645
|
+
context,
|
|
6646
|
+
pluginManager,
|
|
6647
|
+
rsbuildOptions
|
|
6648
|
+
})).rspackConfigs;
|
|
6649
|
+
return inspectConfig({
|
|
6641
6650
|
context,
|
|
6642
6651
|
pluginManager,
|
|
6643
6652
|
rsbuildOptions,
|
|
6644
|
-
inspectOptions
|
|
6645
|
-
|
|
6653
|
+
inspectOptions,
|
|
6654
|
+
bundlerConfigs
|
|
6655
|
+
});
|
|
6656
|
+
}
|
|
6646
6657
|
};
|
|
6647
6658
|
};
|
|
6648
6659
|
function prodServer_define_property(obj, key, value) {
|
|
@@ -6709,7 +6720,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6709
6720
|
pwd: context.rootPath,
|
|
6710
6721
|
output: {
|
|
6711
6722
|
path: context.distPath,
|
|
6712
|
-
assetPrefixes: Object.values(context.environments).map((e)=>
|
|
6723
|
+
assetPrefixes: Object.values(context.environments).map((e)=>getPathnameFromUrl(e.config.output.assetPrefix))
|
|
6713
6724
|
},
|
|
6714
6725
|
serverConfig
|
|
6715
6726
|
}, middlewares);
|
|
@@ -7555,11 +7566,11 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7555
7566
|
}
|
|
7556
7567
|
process.title = 'rsbuild-node';
|
|
7557
7568
|
let { npm_execpath } = process.env;
|
|
7558
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.
|
|
7569
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.21\n`);
|
|
7559
7570
|
try {
|
|
7560
7571
|
!function() {
|
|
7561
7572
|
let cli = cac_dist('rsbuild');
|
|
7562
|
-
cli.help(), cli.version("1.3.
|
|
7573
|
+
cli.help(), cli.version("1.3.21"), applyCommonOptions(cli);
|
|
7563
7574
|
let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
7564
7575
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
7565
7576
|
try {
|
|
@@ -7610,7 +7621,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
7610
7621
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
7611
7622
|
}
|
|
7612
7623
|
}
|
|
7613
|
-
let src_version = "1.3.
|
|
7624
|
+
let src_version = "1.3.21";
|
|
7614
7625
|
})(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
|
|
7615
7626
|
"PLUGIN_CSS_NAME",
|
|
7616
7627
|
"PLUGIN_SWC_NAME",
|