@rsbuild/core 1.2.3 → 1.2.4
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 -20
- 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 +66 -45
- package/dist/index.js +66 -45
- 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 -1
- 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.cjs
CHANGED
|
@@ -384,7 +384,6 @@ var __webpack_exports__ = {};
|
|
|
384
384
|
});
|
|
385
385
|
var provider_helpers_namespaceObject = {};
|
|
386
386
|
__webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(provider_helpers_namespaceObject, {
|
|
387
|
-
chainToConfig: ()=>chainToConfig,
|
|
388
387
|
createDevServer: ()=>devServer_createDevServer,
|
|
389
388
|
formatStats: ()=>formatStats,
|
|
390
389
|
getChainUtils: ()=>getChainUtils,
|
|
@@ -1703,7 +1702,7 @@ var __webpack_exports__ = {};
|
|
|
1703
1702
|
async function createContext(options, userConfig, bundlerType) {
|
|
1704
1703
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(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;
|
|
1705
1704
|
return {
|
|
1706
|
-
version: "1.2.
|
|
1705
|
+
version: "1.2.4",
|
|
1707
1706
|
rootPath,
|
|
1708
1707
|
distPath: '',
|
|
1709
1708
|
cachePath,
|
|
@@ -1846,26 +1845,6 @@ var __webpack_exports__ = {};
|
|
|
1846
1845
|
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);
|
|
1847
1846
|
return rslog_index_js_namespaceObject.logger.debug('modify bundler chain done'), modifiedBundlerChain;
|
|
1848
1847
|
}
|
|
1849
|
-
function chainToConfig(chain) {
|
|
1850
|
-
let config = chain.toConfig(), { entry } = config;
|
|
1851
|
-
if (!isPlainObject(entry)) return config;
|
|
1852
|
-
let formattedEntry = {};
|
|
1853
|
-
for (let [entryName, entryValue] of Object.entries(entry)){
|
|
1854
|
-
let entryImport = [], entryDescription = null;
|
|
1855
|
-
for (let item of castArray(entryValue)){
|
|
1856
|
-
if ('string' == typeof item) {
|
|
1857
|
-
entryImport.push(item);
|
|
1858
|
-
continue;
|
|
1859
|
-
}
|
|
1860
|
-
item.import && entryImport.push(...castArray(item.import)), entryDescription ? Object.assign(entryDescription, item) : entryDescription = item;
|
|
1861
|
-
}
|
|
1862
|
-
formattedEntry[entryName] = entryDescription ? {
|
|
1863
|
-
...entryDescription,
|
|
1864
|
-
import: entryImport
|
|
1865
|
-
} : entryImport;
|
|
1866
|
-
}
|
|
1867
|
-
return config.entry = formattedEntry, config;
|
|
1868
|
-
}
|
|
1869
1848
|
let configChain_CHAIN_ID = {
|
|
1870
1849
|
RULE: {
|
|
1871
1850
|
MJS: 'mjs',
|
|
@@ -1993,7 +1972,7 @@ var __webpack_exports__ = {};
|
|
|
1993
1972
|
}
|
|
1994
1973
|
});
|
|
1995
1974
|
}
|
|
1996
|
-
}),
|
|
1975
|
+
}), getDevtool = (config)=>{
|
|
1997
1976
|
let { sourceMap } = config.output, isProd = 'production' === config.mode;
|
|
1998
1977
|
return !1 !== sourceMap && (!0 === sourceMap ? isProd ? 'source-map' : 'cheap-module-source-map' : void 0 === sourceMap.js ? !isProd && 'cheap-module-source-map' : sourceMap.js);
|
|
1999
1978
|
}, pluginBasic = ()=>({
|
|
@@ -2001,7 +1980,16 @@ var __webpack_exports__ = {};
|
|
|
2001
1980
|
setup (api) {
|
|
2002
1981
|
api.modifyBundlerChain((chain, { env, isDev, target, bundler, environment, CHAIN_ID })=>{
|
|
2003
1982
|
let { config } = environment;
|
|
2004
|
-
chain.name(environment.name)
|
|
1983
|
+
chain.name(environment.name);
|
|
1984
|
+
let devtool = getDevtool(config);
|
|
1985
|
+
chain.devtool(devtool);
|
|
1986
|
+
let { sourceMap } = config.output;
|
|
1987
|
+
!devtool && 'object' == typeof sourceMap && sourceMap.css && chain.plugin('source-map-css').use(bundler.SourceMapDevToolPlugin, [
|
|
1988
|
+
{
|
|
1989
|
+
test: /\.css$/,
|
|
1990
|
+
filename: '[file].map[query]'
|
|
1991
|
+
}
|
|
1992
|
+
]), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.merge({
|
|
2005
1993
|
infrastructureLogging: {
|
|
2006
1994
|
level: 'error'
|
|
2007
1995
|
}
|
|
@@ -3227,12 +3215,16 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3227
3215
|
detail.family !== familyV4Value || ipv4Interfaces.has(detail.address) || ipv4Interfaces.set(detail.address, detail);
|
|
3228
3216
|
}
|
|
3229
3217
|
return Array.from(ipv4Interfaces.values());
|
|
3230
|
-
},
|
|
3218
|
+
}, isWildcardHost = (host)=>new Set([
|
|
3219
|
+
'0.0.0.0',
|
|
3220
|
+
'::',
|
|
3221
|
+
'0000:0000:0000:0000:0000:0000:0000:0000'
|
|
3222
|
+
]).has(host), isLoopbackHost = (host)=>new Set([
|
|
3231
3223
|
'localhost',
|
|
3232
3224
|
'127.0.0.1',
|
|
3233
3225
|
'::1',
|
|
3234
3226
|
'0000:0000:0000:0000:0000:0000:0000:0001'
|
|
3235
|
-
].
|
|
3227
|
+
]).has(host), getHostInUrl = (host)=>host === DEFAULT_DEV_HOST ? 'localhost' : external_node_net_default().isIPv6(host) ? '::' === host ? '[::1]' : `[${host}]` : host, concatUrl = ({ host, port, protocol })=>`${protocol}://${host}:${port}`, LOCAL_LABEL = 'Local: ', NETWORK_LABEL = 'Network: ', getUrlLabel = (url)=>{
|
|
3236
3228
|
try {
|
|
3237
3229
|
let { host } = new URL(url);
|
|
3238
3230
|
return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL;
|
|
@@ -4227,16 +4219,17 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4227
4219
|
};
|
|
4228
4220
|
}
|
|
4229
4221
|
async function generateRspackConfig({ target, context, environment }) {
|
|
4230
|
-
let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, HotModuleReplacementPlugin } = core_namespaceObject.rspack, rspackConfig =
|
|
4222
|
+
let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = core_namespaceObject.rspack, rspackConfig = (await modifyBundlerChain(context, {
|
|
4231
4223
|
...chainUtils,
|
|
4232
4224
|
bundler: {
|
|
4233
4225
|
BannerPlugin,
|
|
4234
4226
|
DefinePlugin,
|
|
4235
4227
|
IgnorePlugin,
|
|
4236
4228
|
ProvidePlugin,
|
|
4229
|
+
SourceMapDevToolPlugin,
|
|
4237
4230
|
HotModuleReplacementPlugin
|
|
4238
4231
|
}
|
|
4239
|
-
}));
|
|
4232
|
+
})).toConfig();
|
|
4240
4233
|
return !function(config) {
|
|
4241
4234
|
if (config.plugins) {
|
|
4242
4235
|
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
@@ -4449,6 +4442,31 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4449
4442
|
rl.close();
|
|
4450
4443
|
};
|
|
4451
4444
|
}
|
|
4445
|
+
let external_node_dns_namespaceObject = require("node:dns");
|
|
4446
|
+
async function getLocalhostResolvedAddress() {
|
|
4447
|
+
let [defaultLookup, explicitLookup] = await Promise.all([
|
|
4448
|
+
external_node_dns_namespaceObject.promises.lookup('localhost'),
|
|
4449
|
+
external_node_dns_namespaceObject.promises.lookup('localhost', {
|
|
4450
|
+
verbatim: !0
|
|
4451
|
+
})
|
|
4452
|
+
]);
|
|
4453
|
+
return defaultLookup.family === explicitLookup.family && defaultLookup.address === explicitLookup.address ? void 0 : defaultLookup.address;
|
|
4454
|
+
}
|
|
4455
|
+
async function resolveHostname(host = 'localhost') {
|
|
4456
|
+
if ('localhost' === host) {
|
|
4457
|
+
let resolvedAddress = await getLocalhostResolvedAddress();
|
|
4458
|
+
if (resolvedAddress) return resolvedAddress;
|
|
4459
|
+
}
|
|
4460
|
+
return void 0 === host || isWildcardHost(host) ? 'localhost' : host;
|
|
4461
|
+
}
|
|
4462
|
+
async function getResolvedClientConfig(clientConfig, serverConfig) {
|
|
4463
|
+
let resolvedHost = await resolveHostname(serverConfig.host);
|
|
4464
|
+
return {
|
|
4465
|
+
...clientConfig,
|
|
4466
|
+
host: resolvedHost,
|
|
4467
|
+
port: serverConfig.port
|
|
4468
|
+
};
|
|
4469
|
+
}
|
|
4452
4470
|
let isClientCompiler = (compiler)=>{
|
|
4453
4471
|
let { target } = compiler.options;
|
|
4454
4472
|
return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
|
|
@@ -4465,13 +4483,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4465
4483
|
}), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
|
|
4466
4484
|
}, getDevMiddleware = async (multiCompiler)=>{
|
|
4467
4485
|
let { default: rsbuildDevMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rsbuild-dev-middleware/index.js"));
|
|
4468
|
-
return (options)=>{
|
|
4469
|
-
let { clientPaths, clientConfig, callbacks, liveReload, ...restOptions } = options;
|
|
4486
|
+
return async (options)=>{
|
|
4487
|
+
let { clientPaths, clientConfig, callbacks, liveReload, serverConfig, ...restOptions } = options, resolvedClientConfig = await getResolvedClientConfig(clientConfig, serverConfig);
|
|
4470
4488
|
return applyToCompiler(multiCompiler, (compiler)=>{
|
|
4471
|
-
clientPaths && function({ compiler, clientPaths, clientConfig = {}, liveReload = !0 }) {
|
|
4489
|
+
clientPaths && function({ compiler, clientPaths, clientConfig = {}, resolvedClientConfig = {}, liveReload = !0 }) {
|
|
4472
4490
|
if (isClientCompiler(compiler)) for (let clientPath of (new compiler.webpack.DefinePlugin({
|
|
4473
4491
|
RSBUILD_COMPILATION_NAME: JSON.stringify(getCompilationId(compiler)),
|
|
4474
4492
|
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
|
|
4493
|
+
RSBUILD_RESOLVED_CLIENT_CONFIG: JSON.stringify(resolvedClientConfig),
|
|
4475
4494
|
RSBUILD_DEV_LIVE_RELOAD: liveReload
|
|
4476
4495
|
}).apply(compiler), clientPaths))new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
|
|
4477
4496
|
name: void 0
|
|
@@ -4480,6 +4499,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4480
4499
|
compiler,
|
|
4481
4500
|
clientPaths,
|
|
4482
4501
|
clientConfig,
|
|
4502
|
+
resolvedClientConfig,
|
|
4483
4503
|
liveReload
|
|
4484
4504
|
}), setupServerHooks(compiler, callbacks);
|
|
4485
4505
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
@@ -4818,7 +4838,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4818
4838
|
class CompilerDevMiddleware {
|
|
4819
4839
|
async init() {
|
|
4820
4840
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
4821
|
-
this.middleware = this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4841
|
+
this.middleware = await this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4822
4842
|
}
|
|
4823
4843
|
upgrade(req, sock, head) {
|
|
4824
4844
|
this.socketServer.upgrade(req, sock, head);
|
|
@@ -4840,8 +4860,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4840
4860
|
data
|
|
4841
4861
|
});
|
|
4842
4862
|
}
|
|
4843
|
-
setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4844
|
-
let { devConfig, serverConfig
|
|
4863
|
+
async setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4864
|
+
let { devConfig, serverConfig } = this, { headers, base } = serverConfig, clientPaths = function(devConfig) {
|
|
4865
|
+
var _devConfig_client;
|
|
4866
|
+
let clientPaths = [];
|
|
4867
|
+
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;
|
|
4868
|
+
}(devConfig), middleware = await devMiddleware({
|
|
4845
4869
|
headers,
|
|
4846
4870
|
publicPath: '/',
|
|
4847
4871
|
stats: !1,
|
|
@@ -4863,16 +4887,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4863
4887
|
this.socketServer.updateStats(stats);
|
|
4864
4888
|
}
|
|
4865
4889
|
},
|
|
4866
|
-
clientPaths:
|
|
4867
|
-
var _devConfig_client;
|
|
4868
|
-
let clientPaths = [];
|
|
4869
|
-
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;
|
|
4870
|
-
}(devConfig),
|
|
4890
|
+
clientPaths: clientPaths,
|
|
4871
4891
|
clientConfig: devConfig.client,
|
|
4872
4892
|
liveReload: devConfig.liveReload,
|
|
4873
4893
|
writeToDisk: devConfig.writeToDisk,
|
|
4874
4894
|
serverSideRender: !0,
|
|
4875
|
-
etag: 'weak'
|
|
4895
|
+
etag: 'weak',
|
|
4896
|
+
serverConfig
|
|
4876
4897
|
}), assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
|
|
4877
4898
|
let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
|
|
4878
4899
|
assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
|
|
@@ -5300,7 +5321,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5300
5321
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/http-proxy-middleware/index.js"));
|
|
5301
5322
|
for (let opts of formattedOptions){
|
|
5302
5323
|
let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
|
|
5303
|
-
let bypassUrl = 'function' == typeof opts.bypass ? opts.bypass(req, res, opts) : null;
|
|
5324
|
+
let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
|
|
5304
5325
|
!1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
|
|
5305
5326
|
};
|
|
5306
5327
|
middlewares.push(middleware), opts.ws && proxyMiddlewares.push(proxyMiddleware);
|
|
@@ -5960,7 +5981,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5960
5981
|
if (isFunction(plugin.apply)) {
|
|
5961
5982
|
let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
|
|
5962
5983
|
throw Error([
|
|
5963
|
-
`${index_js_default().yellow(name)} looks like a
|
|
5984
|
+
`${index_js_default().yellow(name)} looks like a webpack or Rspack plugin, please use ${index_js_default().yellow('`tools.rspack`')} to register it:`,
|
|
5964
5985
|
index_js_default().green(`
|
|
5965
5986
|
// rsbuild.config.ts
|
|
5966
5987
|
export default {
|
|
@@ -6588,12 +6609,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6588
6609
|
}
|
|
6589
6610
|
}(), process.title = 'rsbuild-node';
|
|
6590
6611
|
let { npm_execpath } = process.env;
|
|
6591
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.
|
|
6612
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.4\n`);
|
|
6592
6613
|
}();
|
|
6593
6614
|
try {
|
|
6594
6615
|
!function() {
|
|
6595
6616
|
let cli = cac_dist('rsbuild');
|
|
6596
|
-
cli.help(), cli.version("1.2.
|
|
6617
|
+
cli.help(), cli.version("1.2.4"), applyCommonOptions(cli);
|
|
6597
6618
|
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');
|
|
6598
6619
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6599
6620
|
try {
|
|
@@ -6644,7 +6665,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6644
6665
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
6645
6666
|
}
|
|
6646
6667
|
}
|
|
6647
|
-
let src_rslib_entry_version = "1.2.
|
|
6668
|
+
let src_rslib_entry_version = "1.2.4";
|
|
6648
6669
|
})();
|
|
6649
6670
|
var __webpack_export_target__ = exports;
|
|
6650
6671
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
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,
|
|
@@ -1611,7 +1611,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
1611
1611
|
async function createContext(options, userConfig, bundlerType) {
|
|
1612
1612
|
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
1613
|
return {
|
|
1614
|
-
version: "1.2.
|
|
1614
|
+
version: "1.2.4",
|
|
1615
1615
|
rootPath,
|
|
1616
1616
|
distPath: '',
|
|
1617
1617
|
cachePath,
|
|
@@ -1754,26 +1754,6 @@ async function modifyBundlerChain(context, utils) {
|
|
|
1754
1754
|
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
1755
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify bundler chain done'), modifiedBundlerChain;
|
|
1756
1756
|
}
|
|
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
1757
|
let configChain_CHAIN_ID = {
|
|
1778
1758
|
RULE: {
|
|
1779
1759
|
MJS: 'mjs',
|
|
@@ -1901,7 +1881,7 @@ let configChain_CHAIN_ID = {
|
|
|
1901
1881
|
}
|
|
1902
1882
|
});
|
|
1903
1883
|
}
|
|
1904
|
-
}),
|
|
1884
|
+
}), getDevtool = (config)=>{
|
|
1905
1885
|
let { sourceMap } = config.output, isProd = 'production' === config.mode;
|
|
1906
1886
|
return !1 !== sourceMap && (!0 === sourceMap ? isProd ? 'source-map' : 'cheap-module-source-map' : void 0 === sourceMap.js ? !isProd && 'cheap-module-source-map' : sourceMap.js);
|
|
1907
1887
|
}, pluginBasic = ()=>({
|
|
@@ -1909,7 +1889,16 @@ let configChain_CHAIN_ID = {
|
|
|
1909
1889
|
setup (api) {
|
|
1910
1890
|
api.modifyBundlerChain((chain, { env, isDev, target, bundler, environment, CHAIN_ID })=>{
|
|
1911
1891
|
let { config } = environment;
|
|
1912
|
-
chain.name(environment.name)
|
|
1892
|
+
chain.name(environment.name);
|
|
1893
|
+
let devtool = getDevtool(config);
|
|
1894
|
+
chain.devtool(devtool);
|
|
1895
|
+
let { sourceMap } = config.output;
|
|
1896
|
+
!devtool && 'object' == typeof sourceMap && sourceMap.css && chain.plugin('source-map-css').use(bundler.SourceMapDevToolPlugin, [
|
|
1897
|
+
{
|
|
1898
|
+
test: /\.css$/,
|
|
1899
|
+
filename: '[file].map[query]'
|
|
1900
|
+
}
|
|
1901
|
+
]), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.merge({
|
|
1913
1902
|
infrastructureLogging: {
|
|
1914
1903
|
level: 'error'
|
|
1915
1904
|
}
|
|
@@ -3127,12 +3116,16 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
3127
3116
|
detail.family !== familyV4Value || ipv4Interfaces.has(detail.address) || ipv4Interfaces.set(detail.address, detail);
|
|
3128
3117
|
}
|
|
3129
3118
|
return Array.from(ipv4Interfaces.values());
|
|
3130
|
-
},
|
|
3119
|
+
}, isWildcardHost = (host)=>new Set([
|
|
3120
|
+
'0.0.0.0',
|
|
3121
|
+
'::',
|
|
3122
|
+
'0000:0000:0000:0000:0000:0000:0000:0000'
|
|
3123
|
+
]).has(host), isLoopbackHost = (host)=>new Set([
|
|
3131
3124
|
'localhost',
|
|
3132
3125
|
'127.0.0.1',
|
|
3133
3126
|
'::1',
|
|
3134
3127
|
'0000:0000:0000:0000:0000:0000:0000:0001'
|
|
3135
|
-
].
|
|
3128
|
+
]).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
3129
|
try {
|
|
3137
3130
|
let { host } = new URL(url);
|
|
3138
3131
|
return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL;
|
|
@@ -4123,16 +4116,17 @@ function getChainUtils(target, environment) {
|
|
|
4123
4116
|
};
|
|
4124
4117
|
}
|
|
4125
4118
|
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 =
|
|
4119
|
+
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
4120
|
...chainUtils,
|
|
4128
4121
|
bundler: {
|
|
4129
4122
|
BannerPlugin,
|
|
4130
4123
|
DefinePlugin,
|
|
4131
4124
|
IgnorePlugin,
|
|
4132
4125
|
ProvidePlugin,
|
|
4126
|
+
SourceMapDevToolPlugin,
|
|
4133
4127
|
HotModuleReplacementPlugin
|
|
4134
4128
|
}
|
|
4135
|
-
}));
|
|
4129
|
+
})).toConfig();
|
|
4136
4130
|
return !function(config) {
|
|
4137
4131
|
if (config.plugins) {
|
|
4138
4132
|
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
@@ -4343,6 +4337,30 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
|
|
|
4343
4337
|
rl.close();
|
|
4344
4338
|
};
|
|
4345
4339
|
}
|
|
4340
|
+
async function getLocalhostResolvedAddress() {
|
|
4341
|
+
let [defaultLookup, explicitLookup] = await Promise.all([
|
|
4342
|
+
__WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__.promises.lookup('localhost'),
|
|
4343
|
+
__WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__.promises.lookup('localhost', {
|
|
4344
|
+
verbatim: !0
|
|
4345
|
+
})
|
|
4346
|
+
]);
|
|
4347
|
+
return defaultLookup.family === explicitLookup.family && defaultLookup.address === explicitLookup.address ? void 0 : defaultLookup.address;
|
|
4348
|
+
}
|
|
4349
|
+
async function resolveHostname(host = 'localhost') {
|
|
4350
|
+
if ('localhost' === host) {
|
|
4351
|
+
let resolvedAddress = await getLocalhostResolvedAddress();
|
|
4352
|
+
if (resolvedAddress) return resolvedAddress;
|
|
4353
|
+
}
|
|
4354
|
+
return void 0 === host || isWildcardHost(host) ? 'localhost' : host;
|
|
4355
|
+
}
|
|
4356
|
+
async function getResolvedClientConfig(clientConfig, serverConfig) {
|
|
4357
|
+
let resolvedHost = await resolveHostname(serverConfig.host);
|
|
4358
|
+
return {
|
|
4359
|
+
...clientConfig,
|
|
4360
|
+
host: resolvedHost,
|
|
4361
|
+
port: serverConfig.port
|
|
4362
|
+
};
|
|
4363
|
+
}
|
|
4346
4364
|
let isClientCompiler = (compiler)=>{
|
|
4347
4365
|
let { target } = compiler.options;
|
|
4348
4366
|
return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
|
|
@@ -4359,13 +4377,14 @@ let isClientCompiler = (compiler)=>{
|
|
|
4359
4377
|
}), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
|
|
4360
4378
|
}, getDevMiddleware = async (multiCompiler)=>{
|
|
4361
4379
|
let { default: rsbuildDevMiddleware } = await import("../compiled/rsbuild-dev-middleware/index.js");
|
|
4362
|
-
return (options)=>{
|
|
4363
|
-
let { clientPaths, clientConfig, callbacks, liveReload, ...restOptions } = options;
|
|
4380
|
+
return async (options)=>{
|
|
4381
|
+
let { clientPaths, clientConfig, callbacks, liveReload, serverConfig, ...restOptions } = options, resolvedClientConfig = await getResolvedClientConfig(clientConfig, serverConfig);
|
|
4364
4382
|
return applyToCompiler(multiCompiler, (compiler)=>{
|
|
4365
|
-
clientPaths && function({ compiler, clientPaths, clientConfig = {}, liveReload = !0 }) {
|
|
4383
|
+
clientPaths && function({ compiler, clientPaths, clientConfig = {}, resolvedClientConfig = {}, liveReload = !0 }) {
|
|
4366
4384
|
if (isClientCompiler(compiler)) for (let clientPath of (new compiler.webpack.DefinePlugin({
|
|
4367
4385
|
RSBUILD_COMPILATION_NAME: JSON.stringify(getCompilationId(compiler)),
|
|
4368
4386
|
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
|
|
4387
|
+
RSBUILD_RESOLVED_CLIENT_CONFIG: JSON.stringify(resolvedClientConfig),
|
|
4369
4388
|
RSBUILD_DEV_LIVE_RELOAD: liveReload
|
|
4370
4389
|
}).apply(compiler), clientPaths))new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
|
|
4371
4390
|
name: void 0
|
|
@@ -4374,6 +4393,7 @@ let isClientCompiler = (compiler)=>{
|
|
|
4374
4393
|
compiler,
|
|
4375
4394
|
clientPaths,
|
|
4376
4395
|
clientConfig,
|
|
4396
|
+
resolvedClientConfig,
|
|
4377
4397
|
liveReload
|
|
4378
4398
|
}), setupServerHooks(compiler, callbacks);
|
|
4379
4399
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
@@ -4712,7 +4732,7 @@ let compilerDevMiddleware_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab
|
|
|
4712
4732
|
class CompilerDevMiddleware {
|
|
4713
4733
|
async init() {
|
|
4714
4734
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
4715
|
-
this.middleware = this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4735
|
+
this.middleware = await this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4716
4736
|
}
|
|
4717
4737
|
upgrade(req, sock, head) {
|
|
4718
4738
|
this.socketServer.upgrade(req, sock, head);
|
|
@@ -4734,8 +4754,12 @@ class CompilerDevMiddleware {
|
|
|
4734
4754
|
data
|
|
4735
4755
|
});
|
|
4736
4756
|
}
|
|
4737
|
-
setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4738
|
-
let { devConfig, serverConfig
|
|
4757
|
+
async setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4758
|
+
let { devConfig, serverConfig } = this, { headers, base } = serverConfig, clientPaths = function(devConfig) {
|
|
4759
|
+
var _devConfig_client;
|
|
4760
|
+
let clientPaths = [];
|
|
4761
|
+
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;
|
|
4762
|
+
}(devConfig), middleware = await devMiddleware({
|
|
4739
4763
|
headers,
|
|
4740
4764
|
publicPath: '/',
|
|
4741
4765
|
stats: !1,
|
|
@@ -4757,16 +4781,13 @@ class CompilerDevMiddleware {
|
|
|
4757
4781
|
this.socketServer.updateStats(stats);
|
|
4758
4782
|
}
|
|
4759
4783
|
},
|
|
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),
|
|
4784
|
+
clientPaths: clientPaths,
|
|
4765
4785
|
clientConfig: devConfig.client,
|
|
4766
4786
|
liveReload: devConfig.liveReload,
|
|
4767
4787
|
writeToDisk: devConfig.writeToDisk,
|
|
4768
4788
|
serverSideRender: !0,
|
|
4769
|
-
etag: 'weak'
|
|
4789
|
+
etag: 'weak',
|
|
4790
|
+
serverConfig
|
|
4770
4791
|
}), assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
|
|
4771
4792
|
let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
|
|
4772
4793
|
assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
|
|
@@ -5189,7 +5210,7 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5189
5210
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("../compiled/http-proxy-middleware/index.js");
|
|
5190
5211
|
for (let opts of formattedOptions){
|
|
5191
5212
|
let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
|
|
5192
|
-
let bypassUrl = 'function' == typeof opts.bypass ? opts.bypass(req, res, opts) : null;
|
|
5213
|
+
let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
|
|
5193
5214
|
!1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
|
|
5194
5215
|
};
|
|
5195
5216
|
middlewares.push(middleware), opts.ws && proxyMiddlewares.push(proxyMiddleware);
|
|
@@ -5849,7 +5870,7 @@ async function createRsbuild(options = {}) {
|
|
|
5849
5870
|
if (isFunction(plugin.apply)) {
|
|
5850
5871
|
let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
|
|
5851
5872
|
throw Error([
|
|
5852
|
-
`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)} looks like a
|
|
5873
|
+
`${__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
5874
|
__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(`
|
|
5854
5875
|
// rsbuild.config.ts
|
|
5855
5876
|
export default {
|
|
@@ -6476,12 +6497,12 @@ async function runCLI() {
|
|
|
6476
6497
|
}
|
|
6477
6498
|
}(), process.title = 'rsbuild-node';
|
|
6478
6499
|
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.
|
|
6500
|
+
(!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.4\n`);
|
|
6480
6501
|
}();
|
|
6481
6502
|
try {
|
|
6482
6503
|
!function() {
|
|
6483
6504
|
let cli = cac_dist('rsbuild');
|
|
6484
|
-
cli.help(), cli.version("1.2.
|
|
6505
|
+
cli.help(), cli.version("1.2.4"), applyCommonOptions(cli);
|
|
6485
6506
|
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
6507
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6487
6508
|
try {
|
|
@@ -6532,6 +6553,6 @@ async function runCLI() {
|
|
|
6532
6553
|
__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
6554
|
}
|
|
6534
6555
|
}
|
|
6535
|
-
let src_version = "1.2.
|
|
6556
|
+
let src_version = "1.2.4";
|
|
6536
6557
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
6537
6558
|
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,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, CacheGroup, CacheGroups, 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, ProxyConfig, 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';
|
|
18
|
+
export type { AppIcon, AppIconItem, AliasStrategy, Build, BuildOptions, BundlerPluginInstance, CacheGroup, CacheGroups, 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 {};
|
|
@@ -50,6 +50,7 @@ export declare const getServerConfig: ({ config, }: {
|
|
|
50
50
|
https: boolean;
|
|
51
51
|
portTip: string | undefined;
|
|
52
52
|
}>;
|
|
53
|
+
export declare const isWildcardHost: (host: string) => boolean;
|
|
53
54
|
export declare const getHostInUrl: (host: string) => string;
|
|
54
55
|
type AddressUrl = {
|
|
55
56
|
label: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DevConfig, ServerConfig } from '../types/config';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if localhost resolves differently between node's default DNS lookup
|
|
4
|
+
* and explicit DNS lookup.
|
|
5
|
+
*
|
|
6
|
+
* Returns the resolved address if there's a difference, undefined otherwise.
|
|
7
|
+
* This helps detect cases where IPv4/IPv6 resolution might vary.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLocalhostResolvedAddress(): Promise<string | undefined>;
|
|
10
|
+
export declare function getResolvedClientConfig(clientConfig: DevConfig['client'], serverConfig: ServerConfig): Promise<DevConfig['client']>;
|
|
@@ -174,7 +174,8 @@ export interface NormalizedSourceConfig extends SourceConfig {
|
|
|
174
174
|
decorators: Required<Decorators>;
|
|
175
175
|
}
|
|
176
176
|
export type HtmlFallback = false | 'index';
|
|
177
|
-
export type ProxyBypass = (req: IncomingMessage, res: ServerResponse, proxyOptions: ProxyOptions) => string | undefined | null | boolean
|
|
177
|
+
export type ProxyBypass = (req: IncomingMessage, res: ServerResponse, proxyOptions: ProxyOptions) => MaybePromise<string | undefined | null | boolean>;
|
|
178
|
+
export type { ProxyFilter };
|
|
178
179
|
export type ProxyOptions = HttpProxyOptions & {
|
|
179
180
|
/**
|
|
180
181
|
* Bypass the proxy based on the return value of a function.
|
|
@@ -182,6 +183,7 @@ export type ProxyOptions = HttpProxyOptions & {
|
|
|
182
183
|
* - Return `true` to continue processing the request without proxy.
|
|
183
184
|
* - Return `false` to produce a 404 error for the request.
|
|
184
185
|
* - Return a path to serve from, instead of continuing to proxy the request.
|
|
186
|
+
* - Return a Promise to handle the request asynchronously.
|
|
185
187
|
*/
|
|
186
188
|
bypass?: ProxyBypass;
|
|
187
189
|
/**
|
|
@@ -135,6 +135,7 @@ export type ModifyBundlerChainUtils = ModifyChainUtils & {
|
|
|
135
135
|
DefinePlugin: PluginInstance;
|
|
136
136
|
IgnorePlugin: PluginInstance;
|
|
137
137
|
ProvidePlugin: PluginInstance;
|
|
138
|
+
SourceMapDevToolPlugin: PluginInstance;
|
|
138
139
|
HotModuleReplacementPlugin: PluginInstance;
|
|
139
140
|
};
|
|
140
141
|
};
|