@rsbuild/core 1.3.7 → 1.3.9

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/dist/index.cjs CHANGED
@@ -2218,7 +2218,7 @@ for(var __webpack_i__ in (()=>{
2218
2218
  async function createContext(options, userConfig) {
2219
2219
  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;
2220
2220
  return {
2221
- version: "1.3.7",
2221
+ version: "1.3.9",
2222
2222
  rootPath,
2223
2223
  distPath: '',
2224
2224
  cachePath,
@@ -2781,7 +2781,8 @@ for(var __webpack_i__ in (()=>{
2781
2781
  }
2782
2782
  }), getCSSModulesLocalIdentName = (config, isProd)=>config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), getLightningCSSLoaderOptions = (config, targets, minify)=>{
2783
2783
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
2784
- targets
2784
+ targets,
2785
+ errorRecovery: !0
2785
2786
  };
2786
2787
  return minify && (initialOptions.minify = !0), reduceConfigs({
2787
2788
  initial: initialOptions,
@@ -3805,10 +3806,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3805
3806
  if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3806
3807
  return port;
3807
3808
  }, getServerConfig = async ({ config })=>{
3808
- let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
3809
+ let { host, port: originalPort, strictPort } = config.server, port = await getPort({
3809
3810
  host,
3810
3811
  port: originalPort,
3811
- strictPort: config.server.strictPort || !1
3812
+ strictPort
3812
3813
  }), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${index_js_default().yellow(`using port ${port}.`)}` : void 0;
3813
3814
  return {
3814
3815
  port,
@@ -3960,14 +3961,15 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3960
3961
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, isServer, environment })=>{
3961
3962
  let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
3962
3963
  var _context_devServer, _context_devServer1, _context_devServer2;
3963
- let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX, port = (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) || server.port || 3000;
3964
+ let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX;
3964
3965
  if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3965
3966
  else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3966
3967
  else if (!0 === dev.assetPrefix) {
3967
3968
  let protocol = (null == (_context_devServer1 = context.devServer) ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null == (_context_devServer2 = context.devServer) ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3968
3969
  publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3969
3970
  }
3970
- return formatPublicPath(replacePortPlaceholder(publicPath, port));
3971
+ let defaultPort = server.port ?? 3000;
3972
+ return formatPublicPath(replacePortPlaceholder(publicPath, isProd ? defaultPort : (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort));
3971
3973
  }({
3972
3974
  config,
3973
3975
  isProd,
@@ -4865,7 +4867,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4865
4867
  getPluginAPI: context.getPluginAPI,
4866
4868
  pluginManager
4867
4869
  }), await modifyRsbuildConfig(context);
4868
- let normalizeBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizeBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizeBaseConfig;
4870
+ let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4869
4871
  for (let [name, config] of Object.entries(mergedEnvironments)){
4870
4872
  let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4871
4873
  environments[name] = {
@@ -4878,7 +4880,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4878
4880
  };
4879
4881
  }
4880
4882
  context.normalizedConfig = {
4881
- ...normalizeBaseConfig,
4883
+ ...normalizedBaseConfig,
4882
4884
  environments
4883
4885
  }, await updateEnvironmentContext(context, environments);
4884
4886
  var context1 = context;
@@ -5836,7 +5838,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5836
5838
  next();
5837
5839
  }), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5838
5840
  let { compiler } = compilationManager;
5839
- middlewares.push(core_default().experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5841
+ 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(core_default().experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5840
5842
  }
5841
5843
  if (server.proxy) {
5842
5844
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
@@ -7416,11 +7418,11 @@ ${section.body}` : section.body).join("\n\n"));
7416
7418
  }
7417
7419
  process.title = 'rsbuild-node';
7418
7420
  let { npm_execpath } = process.env;
7419
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.7\n`);
7421
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.9\n`);
7420
7422
  try {
7421
7423
  !function() {
7422
7424
  let cli = cac_dist('rsbuild');
7423
- cli.help(), cli.version("1.3.7"), applyCommonOptions(cli);
7425
+ cli.help(), cli.version("1.3.9"), applyCommonOptions(cli);
7424
7426
  let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
7425
7427
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7426
7428
  try {
@@ -7471,7 +7473,7 @@ ${section.body}` : section.body).join("\n\n"));
7471
7473
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7472
7474
  }
7473
7475
  }
7474
- let src_version = "1.3.7";
7476
+ let src_version = "1.3.9";
7475
7477
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
7476
7478
  "PLUGIN_CSS_NAME",
7477
7479
  "PLUGIN_SWC_NAME",
package/dist/index.js CHANGED
@@ -2115,7 +2115,7 @@ async function updateEnvironmentContext(context, configs) {
2115
2115
  async function createContext(options, userConfig) {
2116
2116
  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;
2117
2117
  return {
2118
- version: "1.3.7",
2118
+ version: "1.3.9",
2119
2119
  rootPath,
2120
2120
  distPath: '',
2121
2121
  cachePath,
@@ -2677,7 +2677,8 @@ let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.
2677
2677
  }
2678
2678
  }), getCSSModulesLocalIdentName = (config, isProd)=>config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), getLightningCSSLoaderOptions = (config, targets, minify)=>{
2679
2679
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
2680
- targets
2680
+ targets,
2681
+ errorRecovery: !0
2681
2682
  };
2682
2683
  return minify && (initialOptions.minify = !0), reduceConfigs({
2683
2684
  initial: initialOptions,
@@ -3695,10 +3696,10 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3695
3696
  if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3696
3697
  return port;
3697
3698
  }, getServerConfig = async ({ config })=>{
3698
- let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
3699
+ let { host, port: originalPort, strictPort } = config.server, port = await getPort({
3699
3700
  host,
3700
3701
  port: originalPort,
3701
- strictPort: config.server.strictPort || !1
3702
+ strictPort
3702
3703
  }), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`using port ${port}.`)}` : void 0;
3703
3704
  return {
3704
3705
  port,
@@ -3850,14 +3851,15 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3850
3851
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, isServer, environment })=>{
3851
3852
  let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
3852
3853
  var _context_devServer, _context_devServer1, _context_devServer2;
3853
- let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX, port = (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) || server.port || 3000;
3854
+ let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX;
3854
3855
  if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3855
3856
  else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3856
3857
  else if (!0 === dev.assetPrefix) {
3857
3858
  let protocol = (null == (_context_devServer1 = context.devServer) ? void 0 : _context_devServer1.https) ? 'https' : 'http', hostname = (null == (_context_devServer2 = context.devServer) ? void 0 : _context_devServer2.hostname) || DEFAULT_DEV_HOST;
3858
3859
  publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3859
3860
  }
3860
- return formatPublicPath(replacePortPlaceholder(publicPath, port));
3861
+ let defaultPort = server.port ?? 3000;
3862
+ return formatPublicPath(replacePortPlaceholder(publicPath, isProd ? defaultPort : (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort));
3861
3863
  }({
3862
3864
  config,
3863
3865
  isProd,
@@ -4750,7 +4752,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
4750
4752
  getPluginAPI: context.getPluginAPI,
4751
4753
  pluginManager
4752
4754
  }), await modifyRsbuildConfig(context);
4753
- let normalizeBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizeBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizeBaseConfig;
4755
+ let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4754
4756
  for (let [name, config] of Object.entries(mergedEnvironments)){
4755
4757
  let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4756
4758
  environments[name] = {
@@ -4763,7 +4765,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
4763
4765
  };
4764
4766
  }
4765
4767
  context.normalizedConfig = {
4766
- ...normalizeBaseConfig,
4768
+ ...normalizedBaseConfig,
4767
4769
  environments
4768
4770
  }, await updateEnvironmentContext(context, environments);
4769
4771
  let distPaths = Object.values(context.environments).map((item)=>item.distPath);
@@ -5716,7 +5718,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5716
5718
  next();
5717
5719
  }), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5718
5720
  let { compiler } = compilationManager;
5719
- middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5721
+ 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5720
5722
  }
5721
5723
  if (server.proxy) {
5722
5724
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
@@ -7289,11 +7291,11 @@ async function runCLI() {
7289
7291
  }
7290
7292
  process.title = 'rsbuild-node';
7291
7293
  let { npm_execpath } = process.env;
7292
- (!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.3.7\n`);
7294
+ (!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.3.9\n`);
7293
7295
  try {
7294
7296
  !function() {
7295
7297
  let cli = cac_dist('rsbuild');
7296
- cli.help(), cli.version("1.3.7"), applyCommonOptions(cli);
7298
+ cli.help(), cli.version("1.3.9"), applyCommonOptions(cli);
7297
7299
  let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
7298
7300
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7299
7301
  try {
@@ -7344,6 +7346,6 @@ async function runCLI() {
7344
7346
  __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);
7345
7347
  }
7346
7348
  }
7347
- let src_version = "1.3.7";
7349
+ let src_version = "1.3.9";
7348
7350
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7349
7351
  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 };
@@ -8,10 +8,9 @@ import type { InspectConfigOptions, InspectConfigResult, NormalizedConfig, Plugi
8
8
  export declare const LOCAL_ORIGINS_REGEX: RegExp;
9
9
  export declare function getDefaultEntry(root: string): RsbuildEntry;
10
10
  export declare const withDefaultConfig: (rootPath: string, config: RsbuildConfig) => Promise<RsbuildConfig>;
11
- /** #__PURE__
12
- * 1. May used by multiple plugins.
13
- * 2. Object value that should not be empty.
14
- * 3. Meaningful and can be filled by constant value.
11
+ /**
12
+ * Merges user config with default values to ensure required properties
13
+ * are initialized.
15
14
  */
16
15
  export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
17
16
  export type ConfigParams = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -96,7 +96,7 @@
96
96
  "ws": "^8.18.1"
97
97
  },
98
98
  "engines": {
99
- "node": ">=16.7.0"
99
+ "node": ">=16.10.0"
100
100
  },
101
101
  "publishConfig": {
102
102
  "access": "public",