@rsbuild/core 1.2.3 → 1.2.5
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/postcss-load-config/index.js +9 -3
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +177 -145
- package/compiled/rspack-chain/index.d.ts +2 -2
- package/compiled/rspack-chain/index.js +98 -71
- package/compiled/rspack-chain/license +22 -373
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/style-loader/index.js +10 -10
- package/dist/client/hmr.js +22 -13
- package/dist/index.cjs +143 -91
- package/dist/index.js +143 -91
- package/dist-types/cli/commands.d.ts +3 -0
- package/dist-types/config.d.ts +9 -1
- package/dist-types/configChain.d.ts +1 -2
- package/dist-types/index.d.ts +1 -1
- package/dist-types/plugins/basic.d.ts +1 -1
- package/dist-types/provider/createCompiler.d.ts +2 -1
- package/dist-types/provider/helpers.d.ts +1 -1
- package/dist-types/server/devMiddleware.d.ts +1 -1
- package/dist-types/server/helper.d.ts +1 -0
- package/dist-types/server/hmrFallback.d.ts +10 -0
- package/dist-types/types/config.d.ts +3 -12
- package/dist-types/types/hooks.d.ts +1 -0
- package/dist-types/types/plugin.d.ts +2 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
|
22
22
|
import * as __WEBPACK_EXTERNAL_MODULE_node_inspector_dd9822d6__ from "node:inspector";
|
|
23
23
|
import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
|
|
24
24
|
import * as __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__ from "node:readline";
|
|
25
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__ from "node:dns";
|
|
25
26
|
import * as __WEBPACK_EXTERNAL_MODULE_node_querystring_aeb3c0b4__ from "node:querystring";
|
|
26
27
|
import * as __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__ from "node:vm";
|
|
27
28
|
import * as __WEBPACK_EXTERNAL_MODULE_events__ from "events";
|
|
@@ -305,7 +306,6 @@ __webpack_require__.n = function(module) {
|
|
|
305
306
|
};
|
|
306
307
|
var provider_helpers_namespaceObject = {};
|
|
307
308
|
__webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(provider_helpers_namespaceObject, {
|
|
308
|
-
chainToConfig: ()=>chainToConfig,
|
|
309
309
|
createDevServer: ()=>devServer_createDevServer,
|
|
310
310
|
formatStats: ()=>formatStats,
|
|
311
311
|
getChainUtils: ()=>getChainUtils,
|
|
@@ -827,36 +827,42 @@ let configCache = {}, OVERRIDE_PATHS = [
|
|
|
827
827
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
828
828
|
cliOptions && (commonOpts = cliOptions);
|
|
829
829
|
try {
|
|
830
|
-
var _config_server, _config_dev
|
|
830
|
+
var _config_server, _config_dev;
|
|
831
831
|
let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, envs = loadEnv({
|
|
832
832
|
cwd: getEnvDir(root, commonOpts.envDir),
|
|
833
833
|
mode: commonOpts.envMode
|
|
834
834
|
}), { content: config, filePath: configFilePath } = await config_loadConfig({
|
|
835
835
|
cwd: root,
|
|
836
836
|
path: commonOpts.config,
|
|
837
|
-
envMode: commonOpts.envMode
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
let files = [
|
|
841
|
-
...envs.filePaths
|
|
842
|
-
];
|
|
843
|
-
if (configFilePath && files.push(configFilePath), null === (_config_dev1 = config.dev) || void 0 === _config_dev1 ? void 0 : _config_dev1.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
844
|
-
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
845
|
-
let paths = castArray(watchFilesConfig.paths);
|
|
846
|
-
watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
|
|
847
|
-
}
|
|
848
|
-
watchFilesForRestart(files, root, isBuildWatch);
|
|
849
|
-
}
|
|
837
|
+
envMode: commonOpts.envMode,
|
|
838
|
+
loader: commonOpts.configLoader
|
|
839
|
+
});
|
|
850
840
|
config.source ||= {}, config.source.define = {
|
|
851
841
|
...envs.publicVars,
|
|
852
842
|
...config.source.define
|
|
853
|
-
}, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
|
|
843
|
+
}, commonOpts.base && (config.server ||= {}, config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
|
|
854
844
|
let rsbuild = await createRsbuild({
|
|
855
845
|
cwd: root,
|
|
856
846
|
rsbuildConfig: config,
|
|
857
847
|
environment: commonOpts.environment
|
|
858
848
|
});
|
|
859
|
-
return rsbuild.
|
|
849
|
+
return rsbuild.onBeforeCreateCompiler(()=>{
|
|
850
|
+
let command = process.argv[2];
|
|
851
|
+
if ('dev' === command || isBuildWatch) {
|
|
852
|
+
var _config_dev;
|
|
853
|
+
let files = [
|
|
854
|
+
...envs.filePaths
|
|
855
|
+
];
|
|
856
|
+
configFilePath && files.push(configFilePath);
|
|
857
|
+
let config = rsbuild.getNormalizedConfig();
|
|
858
|
+
if (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
|
|
859
|
+
if ('reload-server' !== watchFilesConfig.type) continue;
|
|
860
|
+
let paths = castArray(watchFilesConfig.paths);
|
|
861
|
+
watchFilesConfig.options ? watchFilesForRestart(paths, root, isBuildWatch, watchFilesConfig.options) : files.push(...paths);
|
|
862
|
+
}
|
|
863
|
+
watchFilesForRestart(files, root, isBuildWatch);
|
|
864
|
+
}
|
|
865
|
+
}), rsbuild.onCloseBuild(envs.cleanup), rsbuild.onCloseDevServer(envs.cleanup), rsbuild;
|
|
860
866
|
} catch (err) {
|
|
861
867
|
if (isRestart) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
862
868
|
else throw err;
|
|
@@ -1012,7 +1018,6 @@ let config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.create
|
|
|
1012
1018
|
}
|
|
1013
1019
|
}), getDefaultPerformanceConfig = ()=>({
|
|
1014
1020
|
profile: !1,
|
|
1015
|
-
buildCache: !0,
|
|
1016
1021
|
printFileSize: !0,
|
|
1017
1022
|
removeConsole: !1,
|
|
1018
1023
|
removeMomentLocale: !1,
|
|
@@ -1145,7 +1150,7 @@ async function watchFilesForRestart(files, root, isBuildWatch, watchOptions) {
|
|
|
1145
1150
|
});
|
|
1146
1151
|
watcher.on('add', callback), watcher.on('change', callback), watcher.on('unlink', callback);
|
|
1147
1152
|
}
|
|
1148
|
-
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta } = {}) {
|
|
1153
|
+
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1149
1154
|
let configExport;
|
|
1150
1155
|
let configFilePath = resolveConfigPath(cwd, path);
|
|
1151
1156
|
if (!configFilePath) return {
|
|
@@ -1155,10 +1160,11 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta } =
|
|
|
1155
1160
|
let applyMetaInfo = (config)=>(config._privateMeta = {
|
|
1156
1161
|
configFilePath
|
|
1157
1162
|
}, config);
|
|
1158
|
-
if (/\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
|
|
1159
|
-
let exportModule = await import(`${
|
|
1163
|
+
if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
|
|
1164
|
+
let configFileURL = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
|
|
1160
1165
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
1161
1166
|
} catch (err) {
|
|
1167
|
+
if ('native' === loader) throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with native loader: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
|
|
1162
1168
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`Failed to load file with dynamic import: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`);
|
|
1163
1169
|
}
|
|
1164
1170
|
try {
|
|
@@ -1611,7 +1617,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
1611
1617
|
async function createContext(options, userConfig, bundlerType) {
|
|
1612
1618
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
1613
1619
|
return {
|
|
1614
|
-
version: "1.2.
|
|
1620
|
+
version: "1.2.5",
|
|
1615
1621
|
rootPath,
|
|
1616
1622
|
distPath: '',
|
|
1617
1623
|
cachePath,
|
|
@@ -1754,26 +1760,6 @@ async function modifyBundlerChain(context, utils) {
|
|
|
1754
1760
|
if (null === (_utils_environment_config_tools = utils.environment.config.tools) || void 0 === _utils_environment_config_tools ? void 0 : _utils_environment_config_tools.bundlerChain) for (let item of castArray(utils.environment.config.tools.bundlerChain))await item(modifiedBundlerChain, utils);
|
|
1755
1761
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify bundler chain done'), modifiedBundlerChain;
|
|
1756
1762
|
}
|
|
1757
|
-
function chainToConfig(chain) {
|
|
1758
|
-
let config = chain.toConfig(), { entry } = config;
|
|
1759
|
-
if (!isPlainObject(entry)) return config;
|
|
1760
|
-
let formattedEntry = {};
|
|
1761
|
-
for (let [entryName, entryValue] of Object.entries(entry)){
|
|
1762
|
-
let entryImport = [], entryDescription = null;
|
|
1763
|
-
for (let item of castArray(entryValue)){
|
|
1764
|
-
if ('string' == typeof item) {
|
|
1765
|
-
entryImport.push(item);
|
|
1766
|
-
continue;
|
|
1767
|
-
}
|
|
1768
|
-
item.import && entryImport.push(...castArray(item.import)), entryDescription ? Object.assign(entryDescription, item) : entryDescription = item;
|
|
1769
|
-
}
|
|
1770
|
-
formattedEntry[entryName] = entryDescription ? {
|
|
1771
|
-
...entryDescription,
|
|
1772
|
-
import: entryImport
|
|
1773
|
-
} : entryImport;
|
|
1774
|
-
}
|
|
1775
|
-
return config.entry = formattedEntry, config;
|
|
1776
|
-
}
|
|
1777
1763
|
let configChain_CHAIN_ID = {
|
|
1778
1764
|
RULE: {
|
|
1779
1765
|
MJS: 'mjs',
|
|
@@ -1901,7 +1887,7 @@ let configChain_CHAIN_ID = {
|
|
|
1901
1887
|
}
|
|
1902
1888
|
});
|
|
1903
1889
|
}
|
|
1904
|
-
}),
|
|
1890
|
+
}), getDevtool = (config)=>{
|
|
1905
1891
|
let { sourceMap } = config.output, isProd = 'production' === config.mode;
|
|
1906
1892
|
return !1 !== sourceMap && (!0 === sourceMap ? isProd ? 'source-map' : 'cheap-module-source-map' : void 0 === sourceMap.js ? !isProd && 'cheap-module-source-map' : sourceMap.js);
|
|
1907
1893
|
}, pluginBasic = ()=>({
|
|
@@ -1909,7 +1895,16 @@ let configChain_CHAIN_ID = {
|
|
|
1909
1895
|
setup (api) {
|
|
1910
1896
|
api.modifyBundlerChain((chain, { env, isDev, target, bundler, environment, CHAIN_ID })=>{
|
|
1911
1897
|
let { config } = environment;
|
|
1912
|
-
chain.name(environment.name)
|
|
1898
|
+
chain.name(environment.name);
|
|
1899
|
+
let devtool = getDevtool(config);
|
|
1900
|
+
chain.devtool(devtool);
|
|
1901
|
+
let { sourceMap } = config.output;
|
|
1902
|
+
!devtool && 'object' == typeof sourceMap && sourceMap.css && chain.plugin('source-map-css').use(bundler.SourceMapDevToolPlugin, [
|
|
1903
|
+
{
|
|
1904
|
+
test: /\.css$/,
|
|
1905
|
+
filename: '[file].map[query]'
|
|
1906
|
+
}
|
|
1907
|
+
]), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.merge({
|
|
1913
1908
|
infrastructureLogging: {
|
|
1914
1909
|
level: 'error'
|
|
1915
1910
|
}
|
|
@@ -1930,10 +1925,16 @@ let configChain_CHAIN_ID = {
|
|
|
1930
1925
|
var _config_performance;
|
|
1931
1926
|
return process.env.BUNDLE_ANALYZE || (null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : _config_performance.bundleAnalyze);
|
|
1932
1927
|
};
|
|
1933
|
-
async function
|
|
1928
|
+
async function validateWebpackCache(cacheDirectory, buildDependencies) {
|
|
1934
1929
|
let configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cacheDirectory, 'buildDependencies.json');
|
|
1935
1930
|
if (await isFileExists(configFile)) {
|
|
1936
|
-
|
|
1931
|
+
let rawConfigFile = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(configFile, 'utf-8'), prevBuildDependencies = null;
|
|
1932
|
+
try {
|
|
1933
|
+
prevBuildDependencies = JSON.parse(rawConfigFile);
|
|
1934
|
+
} catch (e) {
|
|
1935
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('Failed to parse the previous buildDependencies.json', e);
|
|
1936
|
+
}
|
|
1937
|
+
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) return;
|
|
1937
1938
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.rm(cacheDirectory, {
|
|
1938
1939
|
force: !0,
|
|
1939
1940
|
recursive: !0
|
|
@@ -1970,24 +1971,33 @@ async function getBuildDependencies(context, config, environmentContext) {
|
|
|
1970
1971
|
let pluginCache = ()=>({
|
|
1971
1972
|
name: 'rsbuild:cache',
|
|
1972
1973
|
setup (api) {
|
|
1973
|
-
|
|
1974
|
+
let cacheEnabled = !1;
|
|
1975
|
+
api.modifyBundlerChain(async (chain, { environment, env })=>{
|
|
1974
1976
|
var digest;
|
|
1975
|
-
let { config } = environment, {
|
|
1976
|
-
if (!1 === buildCache)
|
|
1977
|
-
|
|
1978
|
-
return;
|
|
1979
|
-
}
|
|
1977
|
+
let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
|
|
1978
|
+
if (!1 === buildCache) return;
|
|
1979
|
+
cacheEnabled = !0;
|
|
1980
1980
|
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = function({ cacheDirectory }, context) {
|
|
1981
1981
|
return cacheDirectory ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.rootPath, cacheDirectory) : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.cachePath, context.bundlerType);
|
|
1982
1982
|
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment);
|
|
1983
|
-
await
|
|
1984
|
-
let
|
|
1985
|
-
chain.cache({
|
|
1986
|
-
|
|
1983
|
+
'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
|
|
1984
|
+
let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${digest = cacheConfig.cacheDigest, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash('md5').update(JSON.stringify(digest)).digest('hex').slice(0, 8)}` : `${environment.name}-${env}`;
|
|
1985
|
+
'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
|
|
1986
|
+
...chain.get('experiments'),
|
|
1987
|
+
cache: {
|
|
1988
|
+
type: 'persistent',
|
|
1989
|
+
version: cacheVersion,
|
|
1990
|
+
directory: cacheDirectory,
|
|
1991
|
+
buildDependencies: Object.values(buildDependencies).flat()
|
|
1992
|
+
}
|
|
1993
|
+
})) : chain.cache({
|
|
1994
|
+
name: cacheVersion,
|
|
1987
1995
|
type: 'filesystem',
|
|
1988
1996
|
cacheDirectory,
|
|
1989
1997
|
buildDependencies
|
|
1990
1998
|
});
|
|
1999
|
+
}), api.onAfterCreateCompiler(()=>{
|
|
2000
|
+
cacheEnabled && 'rspack' === api.context.bundlerType && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`Rspack persistent cache enabled ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('(experimental)')}`);
|
|
1991
2001
|
});
|
|
1992
2002
|
}
|
|
1993
2003
|
}), addTrailingSep = (dir)=>dir.endsWith(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep) ? dir : dir + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep, isStrictSubdir = (parent, child)=>{
|
|
@@ -2012,9 +2022,9 @@ let pluginCache = ()=>({
|
|
|
2012
2022
|
if (!0 === enable || 'auto' === enable && isStrictSubdir(rootPath, targetPath)) return {
|
|
2013
2023
|
path: targetPath
|
|
2014
2024
|
};
|
|
2015
|
-
}, getPathInfo = (environment)=>{
|
|
2025
|
+
}, getPathInfo = (environment, isDev)=>{
|
|
2016
2026
|
let { rootPath } = api.context, { config, distPath } = environment, { enable, keep } = normalizeCleanDistPath(config.output.cleanDistPath);
|
|
2017
|
-
return 'auto' === enable ? isStrictSubdir(rootPath, distPath) ? {
|
|
2027
|
+
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
2018
2028
|
path: distPath,
|
|
2019
2029
|
keep
|
|
2020
2030
|
} : (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Please set ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`output.cleanDistPath`')} config manually.`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current root path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(rootPath)}`), void __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Current dist path: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(distPath)}`)) : !0 === enable ? {
|
|
@@ -2023,7 +2033,7 @@ let pluginCache = ()=>({
|
|
|
2023
2033
|
} : void 0;
|
|
2024
2034
|
}, cleanAll = async (params)=>{
|
|
2025
2035
|
for (let pathInfo of [
|
|
2026
|
-
...Object.values(params.environments).reduce((result, curr)=>(result.find((item)=>item.distPath === curr.distPath) || result.push(curr), result), []).map(getPathInfo),
|
|
2036
|
+
...Object.values(params.environments).reduce((result, curr)=>(result.find((item)=>item.distPath === curr.distPath) || result.push(curr), result), []).map((environment)=>getPathInfo(environment, params.isDev)),
|
|
2027
2037
|
getRsbuildOutputPath()
|
|
2028
2038
|
].filter((pathInfo)=>!!pathInfo))await emptyDir(pathInfo.path, pathInfo.keep);
|
|
2029
2039
|
};
|
|
@@ -2031,7 +2041,12 @@ let pluginCache = ()=>({
|
|
|
2031
2041
|
isFirstCompile && await cleanAll({
|
|
2032
2042
|
environments
|
|
2033
2043
|
});
|
|
2034
|
-
}), api.onBeforeStartDevServer(
|
|
2044
|
+
}), api.onBeforeStartDevServer(async ({ environments })=>{
|
|
2045
|
+
await cleanAll({
|
|
2046
|
+
environments,
|
|
2047
|
+
isDev: !0
|
|
2048
|
+
});
|
|
2049
|
+
});
|
|
2035
2050
|
}
|
|
2036
2051
|
}), dist_isNil = (o)=>null == o, dist_isFunction = (func)=>'function' == typeof func, dist_isObject = (obj)=>null !== obj && 'object' == typeof obj, dist_isPlainObject = (obj)=>dist_isObject(obj) && '[object Object]' === Object.prototype.toString.call(obj);
|
|
2037
2052
|
function reduceConfigs({ initial, config, mergeFn = Object.assign }) {
|
|
@@ -2930,27 +2945,27 @@ class PatchSplitChunksPlugin {
|
|
|
2930
2945
|
apply(compiler) {
|
|
2931
2946
|
let { splitChunks } = compiler.options.optimization;
|
|
2932
2947
|
if (!splitChunks) return;
|
|
2933
|
-
let applyPatch = (
|
|
2934
|
-
if ('object' != typeof
|
|
2935
|
-
let { chunks } =
|
|
2948
|
+
let applyPatch = (config)=>{
|
|
2949
|
+
if ('object' != typeof config || (0, __WEBPACK_EXTERNAL_MODULE_node_util_types_ce11fc49__.isRegExp)(config)) return;
|
|
2950
|
+
let { chunks } = config;
|
|
2936
2951
|
if (chunks && 'async' !== chunks) {
|
|
2937
2952
|
if ('function' == typeof chunks) {
|
|
2938
|
-
|
|
2953
|
+
config.chunks = (chunk)=>(!chunk.name || chunk.name !== this.name) && chunks(chunk);
|
|
2939
2954
|
return;
|
|
2940
2955
|
}
|
|
2941
2956
|
if ('all' === chunks) {
|
|
2942
|
-
|
|
2957
|
+
config.chunks = (chunk)=>!chunk.name || chunk.name !== this.name;
|
|
2943
2958
|
return;
|
|
2944
2959
|
}
|
|
2945
2960
|
if ('initial' === chunks) {
|
|
2946
|
-
|
|
2961
|
+
config.chunks = (chunk)=>(!chunk.name || chunk.name !== this.name) && chunk.isOnlyInitial();
|
|
2947
2962
|
return;
|
|
2948
2963
|
}
|
|
2949
2964
|
}
|
|
2950
2965
|
};
|
|
2951
2966
|
applyPatch(splitChunks);
|
|
2952
2967
|
let { cacheGroups } = splitChunks;
|
|
2953
|
-
if (cacheGroups) for (let cacheGroupKey of Object.keys(cacheGroups))applyPatch(cacheGroups[cacheGroupKey]);
|
|
2968
|
+
if (cacheGroups) for (let cacheGroupKey of Object.keys(cacheGroups))cacheGroups[cacheGroupKey] && applyPatch(cacheGroups[cacheGroupKey]);
|
|
2954
2969
|
}
|
|
2955
2970
|
constructor(name){
|
|
2956
2971
|
var key, value;
|
|
@@ -3127,12 +3142,16 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
3127
3142
|
detail.family !== familyV4Value || ipv4Interfaces.has(detail.address) || ipv4Interfaces.set(detail.address, detail);
|
|
3128
3143
|
}
|
|
3129
3144
|
return Array.from(ipv4Interfaces.values());
|
|
3130
|
-
},
|
|
3145
|
+
}, isWildcardHost = (host)=>new Set([
|
|
3146
|
+
'0.0.0.0',
|
|
3147
|
+
'::',
|
|
3148
|
+
'0000:0000:0000:0000:0000:0000:0000:0000'
|
|
3149
|
+
]).has(host), isLoopbackHost = (host)=>new Set([
|
|
3131
3150
|
'localhost',
|
|
3132
3151
|
'127.0.0.1',
|
|
3133
3152
|
'::1',
|
|
3134
3153
|
'0000:0000:0000:0000:0000:0000:0000:0001'
|
|
3135
|
-
].
|
|
3154
|
+
]).has(host), getHostInUrl = (host)=>host === DEFAULT_DEV_HOST ? 'localhost' : __WEBPACK_EXTERNAL_MODULE_node_net_0373943e__.default.isIPv6(host) ? '::' === host ? '[::1]' : `[${host}]` : host, concatUrl = ({ host, port, protocol })=>`${protocol}://${host}:${port}`, LOCAL_LABEL = 'Local: ', NETWORK_LABEL = 'Network: ', getUrlLabel = (url)=>{
|
|
3136
3155
|
try {
|
|
3137
3156
|
let { host } = new URL(url);
|
|
3138
3157
|
return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL;
|
|
@@ -3591,7 +3610,8 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
3591
3610
|
return;
|
|
3592
3611
|
}
|
|
3593
3612
|
try {
|
|
3594
|
-
|
|
3613
|
+
let moduleURL = 'win32' === process.platform ? (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(packagePath).href : packagePath;
|
|
3614
|
+
module = await import(moduleURL);
|
|
3595
3615
|
} catch (err) {
|
|
3596
3616
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(packageName))} module.`);
|
|
3597
3617
|
return;
|
|
@@ -4123,16 +4143,17 @@ function getChainUtils(target, environment) {
|
|
|
4123
4143
|
};
|
|
4124
4144
|
}
|
|
4125
4145
|
async function generateRspackConfig({ target, context, environment }) {
|
|
4126
|
-
let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, HotModuleReplacementPlugin } = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack, rspackConfig =
|
|
4146
|
+
let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack, rspackConfig = (await modifyBundlerChain(context, {
|
|
4127
4147
|
...chainUtils,
|
|
4128
4148
|
bundler: {
|
|
4129
4149
|
BannerPlugin,
|
|
4130
4150
|
DefinePlugin,
|
|
4131
4151
|
IgnorePlugin,
|
|
4132
4152
|
ProvidePlugin,
|
|
4153
|
+
SourceMapDevToolPlugin,
|
|
4133
4154
|
HotModuleReplacementPlugin
|
|
4134
4155
|
}
|
|
4135
|
-
}));
|
|
4156
|
+
})).toConfig();
|
|
4136
4157
|
return !function(config) {
|
|
4137
4158
|
if (config.plugins) {
|
|
4138
4159
|
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
@@ -4218,6 +4239,8 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
|
|
|
4218
4239
|
])
|
|
4219
4240
|
})
|
|
4220
4241
|
};
|
|
4242
|
+
}, validateRsbuildConfig = (config)=>{
|
|
4243
|
+
if (config.server.base && !config.server.base.startsWith('/')) throw Error('[rsbuild:config] The "server.base" option should start with a slash, for example: "/base"');
|
|
4221
4244
|
};
|
|
4222
4245
|
async function initRsbuildConfig({ context, pluginManager }) {
|
|
4223
4246
|
if (context.normalizedConfig) return context.normalizedConfig;
|
|
@@ -4255,7 +4278,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
4255
4278
|
}
|
|
4256
4279
|
return common.join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep);
|
|
4257
4280
|
}(distPaths);
|
|
4258
|
-
}(context), context.normalizedConfig;
|
|
4281
|
+
}(context), validateRsbuildConfig(context.normalizedConfig), context.normalizedConfig;
|
|
4259
4282
|
}
|
|
4260
4283
|
async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
4261
4284
|
let normalizedConfig = await initRsbuildConfig({
|
|
@@ -4343,6 +4366,30 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
|
|
|
4343
4366
|
rl.close();
|
|
4344
4367
|
};
|
|
4345
4368
|
}
|
|
4369
|
+
async function getLocalhostResolvedAddress() {
|
|
4370
|
+
let [defaultLookup, explicitLookup] = await Promise.all([
|
|
4371
|
+
__WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__.promises.lookup('localhost'),
|
|
4372
|
+
__WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__.promises.lookup('localhost', {
|
|
4373
|
+
verbatim: !0
|
|
4374
|
+
})
|
|
4375
|
+
]);
|
|
4376
|
+
return defaultLookup.family === explicitLookup.family && defaultLookup.address === explicitLookup.address ? void 0 : defaultLookup.address;
|
|
4377
|
+
}
|
|
4378
|
+
async function resolveHostname(host = 'localhost') {
|
|
4379
|
+
if ('localhost' === host) {
|
|
4380
|
+
let resolvedAddress = await getLocalhostResolvedAddress();
|
|
4381
|
+
if (resolvedAddress) return resolvedAddress;
|
|
4382
|
+
}
|
|
4383
|
+
return void 0 === host || isWildcardHost(host) ? 'localhost' : host;
|
|
4384
|
+
}
|
|
4385
|
+
async function getResolvedClientConfig(clientConfig, serverConfig) {
|
|
4386
|
+
let resolvedHost = await resolveHostname(serverConfig.host);
|
|
4387
|
+
return {
|
|
4388
|
+
...clientConfig,
|
|
4389
|
+
host: resolvedHost,
|
|
4390
|
+
port: serverConfig.port
|
|
4391
|
+
};
|
|
4392
|
+
}
|
|
4346
4393
|
let isClientCompiler = (compiler)=>{
|
|
4347
4394
|
let { target } = compiler.options;
|
|
4348
4395
|
return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
|
|
@@ -4359,13 +4406,14 @@ let isClientCompiler = (compiler)=>{
|
|
|
4359
4406
|
}), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
|
|
4360
4407
|
}, getDevMiddleware = async (multiCompiler)=>{
|
|
4361
4408
|
let { default: rsbuildDevMiddleware } = await import("../compiled/rsbuild-dev-middleware/index.js");
|
|
4362
|
-
return (options)=>{
|
|
4363
|
-
let { clientPaths, clientConfig, callbacks, liveReload, ...restOptions } = options;
|
|
4409
|
+
return async (options)=>{
|
|
4410
|
+
let { clientPaths, clientConfig, callbacks, liveReload, serverConfig, ...restOptions } = options, resolvedClientConfig = await getResolvedClientConfig(clientConfig, serverConfig);
|
|
4364
4411
|
return applyToCompiler(multiCompiler, (compiler)=>{
|
|
4365
|
-
clientPaths && function({ compiler, clientPaths, clientConfig = {}, liveReload = !0 }) {
|
|
4412
|
+
clientPaths && function({ compiler, clientPaths, clientConfig = {}, resolvedClientConfig = {}, liveReload = !0 }) {
|
|
4366
4413
|
if (isClientCompiler(compiler)) for (let clientPath of (new compiler.webpack.DefinePlugin({
|
|
4367
4414
|
RSBUILD_COMPILATION_NAME: JSON.stringify(getCompilationId(compiler)),
|
|
4368
4415
|
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
|
|
4416
|
+
RSBUILD_RESOLVED_CLIENT_CONFIG: JSON.stringify(resolvedClientConfig),
|
|
4369
4417
|
RSBUILD_DEV_LIVE_RELOAD: liveReload
|
|
4370
4418
|
}).apply(compiler), clientPaths))new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
|
|
4371
4419
|
name: void 0
|
|
@@ -4374,6 +4422,7 @@ let isClientCompiler = (compiler)=>{
|
|
|
4374
4422
|
compiler,
|
|
4375
4423
|
clientPaths,
|
|
4376
4424
|
clientConfig,
|
|
4425
|
+
resolvedClientConfig,
|
|
4377
4426
|
liveReload
|
|
4378
4427
|
}), setupServerHooks(compiler, callbacks);
|
|
4379
4428
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
@@ -4712,7 +4761,7 @@ let compilerDevMiddleware_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab
|
|
|
4712
4761
|
class CompilerDevMiddleware {
|
|
4713
4762
|
async init() {
|
|
4714
4763
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
4715
|
-
this.middleware = this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4764
|
+
this.middleware = await this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4716
4765
|
}
|
|
4717
4766
|
upgrade(req, sock, head) {
|
|
4718
4767
|
this.socketServer.upgrade(req, sock, head);
|
|
@@ -4734,8 +4783,12 @@ class CompilerDevMiddleware {
|
|
|
4734
4783
|
data
|
|
4735
4784
|
});
|
|
4736
4785
|
}
|
|
4737
|
-
setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4738
|
-
let { devConfig, serverConfig
|
|
4786
|
+
async setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4787
|
+
let { devConfig, serverConfig } = this, { headers, base } = serverConfig, clientPaths = function(devConfig) {
|
|
4788
|
+
var _devConfig_client;
|
|
4789
|
+
let clientPaths = [];
|
|
4790
|
+
return (devConfig.hmr || devConfig.liveReload) && (clientPaths.push(compilerDevMiddleware_require.resolve('@rsbuild/core/client/hmr')), (null === (_devConfig_client = devConfig.client) || void 0 === _devConfig_client ? void 0 : _devConfig_client.overlay) && clientPaths.push(`${compilerDevMiddleware_require.resolve('@rsbuild/core/client/overlay')}`)), clientPaths;
|
|
4791
|
+
}(devConfig), middleware = await devMiddleware({
|
|
4739
4792
|
headers,
|
|
4740
4793
|
publicPath: '/',
|
|
4741
4794
|
stats: !1,
|
|
@@ -4757,16 +4810,13 @@ class CompilerDevMiddleware {
|
|
|
4757
4810
|
this.socketServer.updateStats(stats);
|
|
4758
4811
|
}
|
|
4759
4812
|
},
|
|
4760
|
-
clientPaths:
|
|
4761
|
-
var _devConfig_client;
|
|
4762
|
-
let clientPaths = [];
|
|
4763
|
-
return (devConfig.hmr || devConfig.liveReload) && (clientPaths.push(compilerDevMiddleware_require.resolve('@rsbuild/core/client/hmr')), (null === (_devConfig_client = devConfig.client) || void 0 === _devConfig_client ? void 0 : _devConfig_client.overlay) && clientPaths.push(`${compilerDevMiddleware_require.resolve('@rsbuild/core/client/overlay')}`)), clientPaths;
|
|
4764
|
-
}(devConfig),
|
|
4813
|
+
clientPaths: clientPaths,
|
|
4765
4814
|
clientConfig: devConfig.client,
|
|
4766
4815
|
liveReload: devConfig.liveReload,
|
|
4767
4816
|
writeToDisk: devConfig.writeToDisk,
|
|
4768
4817
|
serverSideRender: !0,
|
|
4769
|
-
etag: 'weak'
|
|
4818
|
+
etag: 'weak',
|
|
4819
|
+
serverConfig
|
|
4770
4820
|
}), assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
|
|
4771
4821
|
let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
|
|
4772
4822
|
assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
|
|
@@ -5189,7 +5239,7 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5189
5239
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("../compiled/http-proxy-middleware/index.js");
|
|
5190
5240
|
for (let opts of formattedOptions){
|
|
5191
5241
|
let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
|
|
5192
|
-
let bypassUrl = 'function' == typeof opts.bypass ? opts.bypass(req, res, opts) : null;
|
|
5242
|
+
let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
|
|
5193
5243
|
!1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
|
|
5194
5244
|
};
|
|
5195
5245
|
middlewares.push(middleware), opts.ws && proxyMiddlewares.push(proxyMiddleware);
|
|
@@ -5849,7 +5899,7 @@ async function createRsbuild(options = {}) {
|
|
|
5849
5899
|
if (isFunction(plugin.apply)) {
|
|
5850
5900
|
let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
|
|
5851
5901
|
throw Error([
|
|
5852
|
-
`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)} looks like a
|
|
5902
|
+
`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)} looks like a webpack or Rspack plugin, please use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('`tools.rspack`')} to register it:`,
|
|
5853
5903
|
__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(`
|
|
5854
5904
|
// rsbuild.config.ts
|
|
5855
5905
|
export default {
|
|
@@ -6455,7 +6505,9 @@ class CAC extends __WEBPACK_EXTERNAL_MODULE_events__.EventEmitter {
|
|
|
6455
6505
|
}
|
|
6456
6506
|
}
|
|
6457
6507
|
let cac_dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
6458
|
-
cli.option('
|
|
6508
|
+
cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
|
|
6509
|
+
default: 'jiti'
|
|
6510
|
+
}).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
6459
6511
|
type: [
|
|
6460
6512
|
String
|
|
6461
6513
|
],
|
|
@@ -6476,12 +6528,12 @@ async function runCLI() {
|
|
|
6476
6528
|
}
|
|
6477
6529
|
}(), process.title = 'rsbuild-node';
|
|
6478
6530
|
let { npm_execpath } = process.env;
|
|
6479
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.2.
|
|
6531
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.2.5\n`);
|
|
6480
6532
|
}();
|
|
6481
6533
|
try {
|
|
6482
6534
|
!function() {
|
|
6483
6535
|
let cli = cac_dist('rsbuild');
|
|
6484
|
-
cli.help(), cli.version("1.2.
|
|
6536
|
+
cli.help(), cli.version("1.2.5"), applyCommonOptions(cli);
|
|
6485
6537
|
let devCommand = cli.command('dev', 'starting the dev server'), 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');
|
|
6486
6538
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6487
6539
|
try {
|
|
@@ -6532,6 +6584,6 @@ async function runCLI() {
|
|
|
6532
6584
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
6533
6585
|
}
|
|
6534
6586
|
}
|
|
6535
|
-
let src_version = "1.2.
|
|
6587
|
+
let src_version = "1.2.5";
|
|
6536
6588
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
6537
6589
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { ConfigLoader } from '../config';
|
|
1
2
|
import type { RsbuildMode } from '../types';
|
|
2
3
|
export type CommonOptions = {
|
|
4
|
+
base?: string;
|
|
3
5
|
root?: string;
|
|
4
6
|
mode?: RsbuildMode;
|
|
5
7
|
config?: string;
|
|
8
|
+
configLoader?: ConfigLoader;
|
|
6
9
|
envDir?: string;
|
|
7
10
|
envMode?: string;
|
|
8
11
|
open?: boolean | string;
|
package/dist-types/config.d.ts
CHANGED
|
@@ -46,6 +46,13 @@ export type LoadConfigOptions = {
|
|
|
46
46
|
* @default process.env.NODE_ENV
|
|
47
47
|
*/
|
|
48
48
|
envMode?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Specify the config loader, can be `jiti` or `native`.
|
|
51
|
+
* - 'jiti': Use `jiti` as loader, which supports TypeScript and ESM out of the box
|
|
52
|
+
* - 'native': Use native Node.js loader, requires TypeScript support in Node.js >= 22.6
|
|
53
|
+
* @default 'jiti'
|
|
54
|
+
*/
|
|
55
|
+
loader?: ConfigLoader;
|
|
49
56
|
};
|
|
50
57
|
export type LoadConfigResult = {
|
|
51
58
|
/**
|
|
@@ -58,7 +65,8 @@ export type LoadConfigResult = {
|
|
|
58
65
|
*/
|
|
59
66
|
filePath: string | null;
|
|
60
67
|
};
|
|
61
|
-
export
|
|
68
|
+
export type ConfigLoader = 'jiti' | 'native';
|
|
69
|
+
export declare function loadConfig({ cwd, path, envMode, meta, loader, }?: LoadConfigOptions): Promise<LoadConfigResult>;
|
|
62
70
|
export declare const getRsbuildInspectConfig: ({ normalizedConfig, inspectOptions, pluginManager, }: {
|
|
63
71
|
normalizedConfig: NormalizedConfig;
|
|
64
72
|
inspectOptions: InspectConfigOptions;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import RspackChain from '../compiled/rspack-chain/index.js';
|
|
2
|
-
import type { InternalContext, ModifyBundlerChainUtils
|
|
2
|
+
import type { InternalContext, ModifyBundlerChainUtils } from './types';
|
|
3
3
|
export declare function getBundlerChain(): RspackChain;
|
|
4
4
|
export declare function modifyBundlerChain(context: InternalContext, utils: ModifyBundlerChainUtils): Promise<RspackChain>;
|
|
5
|
-
export declare function chainToConfig(chain: RspackChain): Rspack.Configuration;
|
|
6
5
|
export declare const CHAIN_ID: {
|
|
7
6
|
/** Predefined rules */
|
|
8
7
|
readonly RULE: {
|
package/dist-types/index.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export { logger } from './logger';
|
|
|
15
15
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
16
16
|
export { ensureAssetPrefix } from './helpers';
|
|
17
17
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME } from './constants';
|
|
18
|
-
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance,
|
|
18
|
+
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, Charset, ClientConfig, CliShortcut, CleanDistPath, CleanDistPathObject, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentContext, EnvironmentConfig, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlConfig, HtmlRspackPlugin, HtmlBasicTag, HtmlFallback, HtmlTagHandler, HtmlTagDescriptor, HtmlTagContext, InspectConfigOptions, InspectConfigResult, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InternalContext, LegalComments, ManifestData, ManifestConfig, ManifestObjectConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyRsbuildConfigFn, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, MergedEnvironmentConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterEnvironmentCompileFn, OnBeforeEnvironmentCompileFn, OnCloseBuildFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PreloadIncludeType, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreviewOptions, PreconnectOption, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PrintUrls, PublicDir, PublicDirOptions, ProgressBarConfig, RequestHandler, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, StartDevServerOptions, SriOptions, SriAlgorithm, ScriptInject, ScriptLoading, SecurityConfig, SourceMap, SetupMiddlewaresFn, SetupMiddlewaresServer, ServerConfig, SourceConfig, SplitChunks, StyleLoaderOptions, TransformContext, TransformDescriptor, ToolsConfig, TransformFn, TransformHandler, TransformImport, WatchFiles, } from './types';
|
|
19
19
|
export type { ChainIdentifier } from './configChain';
|
|
20
20
|
export type { RsbuildDevServer } from './server/devServer';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DevConfig, Rspack } from '../types';
|
|
1
|
+
import type { DevConfig, Rspack, ServerConfig } from '../types';
|
|
2
2
|
import { type InitConfigsOptions } from './initConfigs';
|
|
3
3
|
export declare function createCompiler(options: InitConfigsOptions): Promise<{
|
|
4
4
|
compiler: Rspack.Compiler | Rspack.MultiCompiler;
|
|
@@ -24,4 +24,5 @@ export type DevMiddlewareOptions = {
|
|
|
24
24
|
callbacks: MiddlewareCallbacks;
|
|
25
25
|
/** whether use Server Side Render */
|
|
26
26
|
serverSideRender?: boolean;
|
|
27
|
+
serverConfig: ServerConfig;
|
|
27
28
|
};
|
|
@@ -8,5 +8,5 @@ export { getHTMLPlugin } from '../pluginHelper';
|
|
|
8
8
|
export { formatStats, getStatsOptions, prettyTime } from '../helpers';
|
|
9
9
|
export { registerBuildHook, registerDevHook } from '../hooks';
|
|
10
10
|
export { getChainUtils, getConfigUtils } from './rspackConfig';
|
|
11
|
-
export {
|
|
11
|
+
export { modifyBundlerChain } from '../configChain';
|
|
12
12
|
export { createDevServer } from '../server/devServer';
|
|
@@ -22,6 +22,6 @@ export type DevMiddlewareAPI = Middleware & {
|
|
|
22
22
|
* - Inject the HMR client path into page (the HMR client rsbuild/server already provide).
|
|
23
23
|
* - Notify server when compiler hooks are triggered.
|
|
24
24
|
*/
|
|
25
|
-
export type DevMiddleware = (options: DevMiddlewareOptions) => DevMiddlewareAPI
|
|
25
|
+
export type DevMiddleware = (options: DevMiddlewareOptions) => Promise<DevMiddlewareAPI>;
|
|
26
26
|
export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => Promise<NonNullable<DevMiddleware>>;
|
|
27
27
|
export {};
|