@rsbuild/core 1.2.2 → 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 +81 -60
- package/dist/index.js +81 -60
- package/dist/transformLoader.mjs +3 -1
- package/dist/transformRawLoader.mjs +3 -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 -1
- package/dist-types/types/hooks.d.ts +1 -0
- package/dist-types/types/plugin.d.ts +11 -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,23 +4219,26 @@ 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
|
-
}));
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
let
|
|
4243
|
-
|
|
4232
|
+
})).toConfig();
|
|
4233
|
+
return !function(config) {
|
|
4234
|
+
if (config.plugins) {
|
|
4235
|
+
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
4236
|
+
let name = index_js_default().bold(index_js_default().yellow(plugin.name));
|
|
4237
|
+
throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
|
|
4238
|
+
}
|
|
4244
4239
|
}
|
|
4245
|
-
|
|
4246
|
-
|
|
4240
|
+
config.devServer && rslog_index_js_namespaceObject.logger.warn(`[rsbuild:config] Find invalid Rspack config: "${index_js_default().yellow('devServer')}". Note that Rspack's "devServer" config is not supported by Rsbuild. You can use Rsbuild's "dev" config to configure the Rsbuild dev server.`);
|
|
4241
|
+
}(rspackConfig = await modifyRspackConfig(context, rspackConfig, await getConfigUtils(rspackConfig, chainUtils))), rspackConfig;
|
|
4247
4242
|
}
|
|
4248
4243
|
async function modifyRsbuildConfig(context) {
|
|
4249
4244
|
rslog_index_js_namespaceObject.logger.debug('modify Rsbuild config');
|
|
@@ -4447,6 +4442,31 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4447
4442
|
rl.close();
|
|
4448
4443
|
};
|
|
4449
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
|
+
}
|
|
4450
4470
|
let isClientCompiler = (compiler)=>{
|
|
4451
4471
|
let { target } = compiler.options;
|
|
4452
4472
|
return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
|
|
@@ -4463,13 +4483,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4463
4483
|
}), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
|
|
4464
4484
|
}, getDevMiddleware = async (multiCompiler)=>{
|
|
4465
4485
|
let { default: rsbuildDevMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rsbuild-dev-middleware/index.js"));
|
|
4466
|
-
return (options)=>{
|
|
4467
|
-
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);
|
|
4468
4488
|
return applyToCompiler(multiCompiler, (compiler)=>{
|
|
4469
|
-
clientPaths && function({ compiler, clientPaths, clientConfig = {}, liveReload = !0 }) {
|
|
4489
|
+
clientPaths && function({ compiler, clientPaths, clientConfig = {}, resolvedClientConfig = {}, liveReload = !0 }) {
|
|
4470
4490
|
if (isClientCompiler(compiler)) for (let clientPath of (new compiler.webpack.DefinePlugin({
|
|
4471
4491
|
RSBUILD_COMPILATION_NAME: JSON.stringify(getCompilationId(compiler)),
|
|
4472
4492
|
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
|
|
4493
|
+
RSBUILD_RESOLVED_CLIENT_CONFIG: JSON.stringify(resolvedClientConfig),
|
|
4473
4494
|
RSBUILD_DEV_LIVE_RELOAD: liveReload
|
|
4474
4495
|
}).apply(compiler), clientPaths))new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
|
|
4475
4496
|
name: void 0
|
|
@@ -4478,6 +4499,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4478
4499
|
compiler,
|
|
4479
4500
|
clientPaths,
|
|
4480
4501
|
clientConfig,
|
|
4502
|
+
resolvedClientConfig,
|
|
4481
4503
|
liveReload
|
|
4482
4504
|
}), setupServerHooks(compiler, callbacks);
|
|
4483
4505
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
@@ -4816,7 +4838,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4816
4838
|
class CompilerDevMiddleware {
|
|
4817
4839
|
async init() {
|
|
4818
4840
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
4819
|
-
this.middleware = this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4841
|
+
this.middleware = await this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4820
4842
|
}
|
|
4821
4843
|
upgrade(req, sock, head) {
|
|
4822
4844
|
this.socketServer.upgrade(req, sock, head);
|
|
@@ -4838,8 +4860,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4838
4860
|
data
|
|
4839
4861
|
});
|
|
4840
4862
|
}
|
|
4841
|
-
setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4842
|
-
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({
|
|
4843
4869
|
headers,
|
|
4844
4870
|
publicPath: '/',
|
|
4845
4871
|
stats: !1,
|
|
@@ -4861,23 +4887,20 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4861
4887
|
this.socketServer.updateStats(stats);
|
|
4862
4888
|
}
|
|
4863
4889
|
},
|
|
4864
|
-
clientPaths:
|
|
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),
|
|
4890
|
+
clientPaths: clientPaths,
|
|
4869
4891
|
clientConfig: devConfig.client,
|
|
4870
4892
|
liveReload: devConfig.liveReload,
|
|
4871
4893
|
writeToDisk: devConfig.writeToDisk,
|
|
4872
4894
|
serverSideRender: !0,
|
|
4873
|
-
etag: 'weak'
|
|
4874
|
-
|
|
4895
|
+
etag: 'weak',
|
|
4896
|
+
serverConfig
|
|
4897
|
+
}), assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
|
|
4875
4898
|
let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
|
|
4876
4899
|
assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
|
|
4877
4900
|
req.url = url, next(...args);
|
|
4878
4901
|
})) : middleware(req, res, next);
|
|
4879
4902
|
};
|
|
4880
|
-
return
|
|
4903
|
+
return wrapper.close = middleware.close, wrapper;
|
|
4881
4904
|
}
|
|
4882
4905
|
constructor({ dev, server, compiler, publicPaths, environments }){
|
|
4883
4906
|
compilerDevMiddleware_define_property(this, "middleware", void 0), compilerDevMiddleware_define_property(this, "devConfig", void 0), compilerDevMiddleware_define_property(this, "serverConfig", void 0), compilerDevMiddleware_define_property(this, "compiler", void 0), compilerDevMiddleware_define_property(this, "publicPaths", void 0), compilerDevMiddleware_define_property(this, "socketServer", void 0), this.devConfig = formatDevConfig(dev, environments), this.serverConfig = server, this.compiler = compiler, this.publicPaths = publicPaths, this.socketServer = new SocketServer(dev);
|
|
@@ -5298,7 +5321,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5298
5321
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/http-proxy-middleware/index.js"));
|
|
5299
5322
|
for (let opts of formattedOptions){
|
|
5300
5323
|
let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
|
|
5301
|
-
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;
|
|
5302
5325
|
!1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
|
|
5303
5326
|
};
|
|
5304
5327
|
middlewares.push(middleware), opts.ws && proxyMiddlewares.push(proxyMiddleware);
|
|
@@ -5958,7 +5981,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5958
5981
|
if (isFunction(plugin.apply)) {
|
|
5959
5982
|
let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
|
|
5960
5983
|
throw Error([
|
|
5961
|
-
`${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:`,
|
|
5962
5985
|
index_js_default().green(`
|
|
5963
5986
|
// rsbuild.config.ts
|
|
5964
5987
|
export default {
|
|
@@ -6253,13 +6276,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6253
6276
|
rsbuild.addPlugins(plugins);
|
|
6254
6277
|
}
|
|
6255
6278
|
return rsbuildConfig.environments && await Promise.all(Object.entries(rsbuildConfig.environments).map(async ([name, config])=>{
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
});
|
|
6262
|
-
}
|
|
6279
|
+
if (!config.plugins || context.specifiedEnvironments && !context.specifiedEnvironments.includes(name)) return;
|
|
6280
|
+
let plugins = await getFlattenedPlugins(config.plugins);
|
|
6281
|
+
rsbuild.addPlugins(plugins, {
|
|
6282
|
+
environment: name
|
|
6283
|
+
});
|
|
6263
6284
|
})), rsbuild;
|
|
6264
6285
|
}
|
|
6265
6286
|
let external_events_namespaceObject = require("events");
|
|
@@ -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,23 +4116,26 @@ 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
|
-
}));
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
let
|
|
4139
|
-
|
|
4129
|
+
})).toConfig();
|
|
4130
|
+
return !function(config) {
|
|
4131
|
+
if (config.plugins) {
|
|
4132
|
+
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
4133
|
+
let name = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(plugin.name));
|
|
4134
|
+
throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
|
|
4135
|
+
}
|
|
4140
4136
|
}
|
|
4141
|
-
|
|
4142
|
-
|
|
4137
|
+
config.devServer && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`[rsbuild:config] Find invalid Rspack config: "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('devServer')}". Note that Rspack's "devServer" config is not supported by Rsbuild. You can use Rsbuild's "dev" config to configure the Rsbuild dev server.`);
|
|
4138
|
+
}(rspackConfig = await modifyRspackConfig(context, rspackConfig, await getConfigUtils(rspackConfig, chainUtils))), rspackConfig;
|
|
4143
4139
|
}
|
|
4144
4140
|
async function modifyRsbuildConfig(context) {
|
|
4145
4141
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
|
|
@@ -4341,6 +4337,30 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
|
|
|
4341
4337
|
rl.close();
|
|
4342
4338
|
};
|
|
4343
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
|
+
}
|
|
4344
4364
|
let isClientCompiler = (compiler)=>{
|
|
4345
4365
|
let { target } = compiler.options;
|
|
4346
4366
|
return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
|
|
@@ -4357,13 +4377,14 @@ let isClientCompiler = (compiler)=>{
|
|
|
4357
4377
|
}), done.tap('rsbuild-dev-server', hookCallbacks.onDone);
|
|
4358
4378
|
}, getDevMiddleware = async (multiCompiler)=>{
|
|
4359
4379
|
let { default: rsbuildDevMiddleware } = await import("../compiled/rsbuild-dev-middleware/index.js");
|
|
4360
|
-
return (options)=>{
|
|
4361
|
-
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);
|
|
4362
4382
|
return applyToCompiler(multiCompiler, (compiler)=>{
|
|
4363
|
-
clientPaths && function({ compiler, clientPaths, clientConfig = {}, liveReload = !0 }) {
|
|
4383
|
+
clientPaths && function({ compiler, clientPaths, clientConfig = {}, resolvedClientConfig = {}, liveReload = !0 }) {
|
|
4364
4384
|
if (isClientCompiler(compiler)) for (let clientPath of (new compiler.webpack.DefinePlugin({
|
|
4365
4385
|
RSBUILD_COMPILATION_NAME: JSON.stringify(getCompilationId(compiler)),
|
|
4366
4386
|
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
|
|
4387
|
+
RSBUILD_RESOLVED_CLIENT_CONFIG: JSON.stringify(resolvedClientConfig),
|
|
4367
4388
|
RSBUILD_DEV_LIVE_RELOAD: liveReload
|
|
4368
4389
|
}).apply(compiler), clientPaths))new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
|
|
4369
4390
|
name: void 0
|
|
@@ -4372,6 +4393,7 @@ let isClientCompiler = (compiler)=>{
|
|
|
4372
4393
|
compiler,
|
|
4373
4394
|
clientPaths,
|
|
4374
4395
|
clientConfig,
|
|
4396
|
+
resolvedClientConfig,
|
|
4375
4397
|
liveReload
|
|
4376
4398
|
}), setupServerHooks(compiler, callbacks);
|
|
4377
4399
|
}), rsbuildDevMiddleware(multiCompiler, restOptions);
|
|
@@ -4710,7 +4732,7 @@ let compilerDevMiddleware_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab
|
|
|
4710
4732
|
class CompilerDevMiddleware {
|
|
4711
4733
|
async init() {
|
|
4712
4734
|
let devMiddleware = await getDevMiddleware(this.compiler);
|
|
4713
|
-
this.middleware = this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4735
|
+
this.middleware = await this.setupDevMiddleware(devMiddleware, this.publicPaths), await this.socketServer.prepare();
|
|
4714
4736
|
}
|
|
4715
4737
|
upgrade(req, sock, head) {
|
|
4716
4738
|
this.socketServer.upgrade(req, sock, head);
|
|
@@ -4732,8 +4754,12 @@ class CompilerDevMiddleware {
|
|
|
4732
4754
|
data
|
|
4733
4755
|
});
|
|
4734
4756
|
}
|
|
4735
|
-
setupDevMiddleware(devMiddleware, publicPaths) {
|
|
4736
|
-
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({
|
|
4737
4763
|
headers,
|
|
4738
4764
|
publicPath: '/',
|
|
4739
4765
|
stats: !1,
|
|
@@ -4755,23 +4781,20 @@ class CompilerDevMiddleware {
|
|
|
4755
4781
|
this.socketServer.updateStats(stats);
|
|
4756
4782
|
}
|
|
4757
4783
|
},
|
|
4758
|
-
clientPaths:
|
|
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),
|
|
4784
|
+
clientPaths: clientPaths,
|
|
4763
4785
|
clientConfig: devConfig.client,
|
|
4764
4786
|
liveReload: devConfig.liveReload,
|
|
4765
4787
|
writeToDisk: devConfig.writeToDisk,
|
|
4766
4788
|
serverSideRender: !0,
|
|
4767
|
-
etag: 'weak'
|
|
4768
|
-
|
|
4789
|
+
etag: 'weak',
|
|
4790
|
+
serverConfig
|
|
4791
|
+
}), assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
|
|
4769
4792
|
let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
|
|
4770
4793
|
assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
|
|
4771
4794
|
req.url = url, next(...args);
|
|
4772
4795
|
})) : middleware(req, res, next);
|
|
4773
4796
|
};
|
|
4774
|
-
return
|
|
4797
|
+
return wrapper.close = middleware.close, wrapper;
|
|
4775
4798
|
}
|
|
4776
4799
|
constructor({ dev, server, compiler, publicPaths, environments }){
|
|
4777
4800
|
compilerDevMiddleware_define_property(this, "middleware", void 0), compilerDevMiddleware_define_property(this, "devConfig", void 0), compilerDevMiddleware_define_property(this, "serverConfig", void 0), compilerDevMiddleware_define_property(this, "compiler", void 0), compilerDevMiddleware_define_property(this, "publicPaths", void 0), compilerDevMiddleware_define_property(this, "socketServer", void 0), this.devConfig = formatDevConfig(dev, environments), this.serverConfig = server, this.compiler = compiler, this.publicPaths = publicPaths, this.socketServer = new SocketServer(dev);
|
|
@@ -5187,7 +5210,7 @@ let runner_run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>
|
|
|
5187
5210
|
}(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("../compiled/http-proxy-middleware/index.js");
|
|
5188
5211
|
for (let opts of formattedOptions){
|
|
5189
5212
|
let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
|
|
5190
|
-
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;
|
|
5191
5214
|
!1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
|
|
5192
5215
|
};
|
|
5193
5216
|
middlewares.push(middleware), opts.ws && proxyMiddlewares.push(proxyMiddleware);
|
|
@@ -5847,7 +5870,7 @@ async function createRsbuild(options = {}) {
|
|
|
5847
5870
|
if (isFunction(plugin.apply)) {
|
|
5848
5871
|
let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
|
|
5849
5872
|
throw Error([
|
|
5850
|
-
`${__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:`,
|
|
5851
5874
|
__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(`
|
|
5852
5875
|
// rsbuild.config.ts
|
|
5853
5876
|
export default {
|
|
@@ -6142,13 +6165,11 @@ async function createRsbuild(options = {}) {
|
|
|
6142
6165
|
rsbuild.addPlugins(plugins);
|
|
6143
6166
|
}
|
|
6144
6167
|
return rsbuildConfig.environments && await Promise.all(Object.entries(rsbuildConfig.environments).map(async ([name, config])=>{
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
});
|
|
6151
|
-
}
|
|
6168
|
+
if (!config.plugins || context.specifiedEnvironments && !context.specifiedEnvironments.includes(name)) return;
|
|
6169
|
+
let plugins = await getFlattenedPlugins(config.plugins);
|
|
6170
|
+
rsbuild.addPlugins(plugins, {
|
|
6171
|
+
environment: name
|
|
6172
|
+
});
|
|
6152
6173
|
})), rsbuild;
|
|
6153
6174
|
}
|
|
6154
6175
|
function toArr(any) {
|
|
@@ -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 };
|
package/dist/transformLoader.mjs
CHANGED
|
@@ -6,13 +6,15 @@ async function transformLoader_rslib_entry_transform(source, map) {
|
|
|
6
6
|
if (!transform) return bypass();
|
|
7
7
|
let result = await transform({
|
|
8
8
|
code: source,
|
|
9
|
+
context: this.context,
|
|
9
10
|
resource: this.resource,
|
|
10
11
|
resourcePath: this.resourcePath,
|
|
11
12
|
resourceQuery: this.resourceQuery,
|
|
12
13
|
environment: getEnvironment(),
|
|
13
14
|
addDependency: this.addDependency.bind(this),
|
|
14
15
|
emitFile: this.emitFile.bind(this),
|
|
15
|
-
importModule: this.importModule.bind(this)
|
|
16
|
+
importModule: this.importModule.bind(this),
|
|
17
|
+
resolve: this.resolve.bind(this)
|
|
16
18
|
});
|
|
17
19
|
if (null == result) return bypass();
|
|
18
20
|
if ('string' == typeof result) return callback(null, result, map);
|
|
@@ -6,13 +6,15 @@ let transformRawLoader_rslib_entry_ = async function(source, map) {
|
|
|
6
6
|
if (!transform) return bypass();
|
|
7
7
|
let result = await transform({
|
|
8
8
|
code: source,
|
|
9
|
+
context: this.context,
|
|
9
10
|
resource: this.resource,
|
|
10
11
|
resourcePath: this.resourcePath,
|
|
11
12
|
resourceQuery: this.resourceQuery,
|
|
12
13
|
environment: getEnvironment(),
|
|
13
14
|
addDependency: this.addDependency.bind(this),
|
|
14
15
|
emitFile: this.emitFile.bind(this),
|
|
15
|
-
importModule: this.importModule.bind(this)
|
|
16
|
+
importModule: this.importModule.bind(this),
|
|
17
|
+
resolve: this.resolve.bind(this)
|
|
16
18
|
});
|
|
17
19
|
if (null == result) return bypass();
|
|
18
20
|
if ('string' == typeof result) return callback(null, result, map);
|