@rsbuild/core 1.3.7 → 1.3.8

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.8",
2222
2222
  rootPath,
2223
2223
  distPath: '',
2224
2224
  cachePath,
@@ -3805,10 +3805,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3805
3805
  if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3806
3806
  return port;
3807
3807
  }, getServerConfig = async ({ config })=>{
3808
- let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
3808
+ let { host, port: originalPort, strictPort } = config.server, port = await getPort({
3809
3809
  host,
3810
3810
  port: originalPort,
3811
- strictPort: config.server.strictPort || !1
3811
+ strictPort
3812
3812
  }), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${index_js_default().yellow(`using port ${port}.`)}` : void 0;
3813
3813
  return {
3814
3814
  port,
@@ -3960,14 +3960,15 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3960
3960
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, isServer, environment })=>{
3961
3961
  let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
3962
3962
  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;
3963
+ let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX;
3964
3964
  if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3965
3965
  else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3966
3966
  else if (!0 === dev.assetPrefix) {
3967
3967
  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
3968
  publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3969
3969
  }
3970
- return formatPublicPath(replacePortPlaceholder(publicPath, port));
3970
+ let defaultPort = server.port ?? 3000;
3971
+ return formatPublicPath(replacePortPlaceholder(publicPath, isProd ? defaultPort : (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort));
3971
3972
  }({
3972
3973
  config,
3973
3974
  isProd,
@@ -4865,7 +4866,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4865
4866
  getPluginAPI: context.getPluginAPI,
4866
4867
  pluginManager
4867
4868
  }), 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;
4869
+ let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4869
4870
  for (let [name, config] of Object.entries(mergedEnvironments)){
4870
4871
  let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4871
4872
  environments[name] = {
@@ -4878,7 +4879,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4878
4879
  };
4879
4880
  }
4880
4881
  context.normalizedConfig = {
4881
- ...normalizeBaseConfig,
4882
+ ...normalizedBaseConfig,
4882
4883
  environments
4883
4884
  }, await updateEnvironmentContext(context, environments);
4884
4885
  var context1 = context;
@@ -5836,7 +5837,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5836
5837
  next();
5837
5838
  }), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5838
5839
  let { compiler } = compilationManager;
5839
- middlewares.push(core_default().experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5840
+ '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
5841
  }
5841
5842
  if (server.proxy) {
5842
5843
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
@@ -7416,11 +7417,11 @@ ${section.body}` : section.body).join("\n\n"));
7416
7417
  }
7417
7418
  process.title = 'rsbuild-node';
7418
7419
  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`);
7420
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.8\n`);
7420
7421
  try {
7421
7422
  !function() {
7422
7423
  let cli = cac_dist('rsbuild');
7423
- cli.help(), cli.version("1.3.7"), applyCommonOptions(cli);
7424
+ cli.help(), cli.version("1.3.8"), applyCommonOptions(cli);
7424
7425
  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
7426
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7426
7427
  try {
@@ -7471,7 +7472,7 @@ ${section.body}` : section.body).join("\n\n"));
7471
7472
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7472
7473
  }
7473
7474
  }
7474
- let src_version = "1.3.7";
7475
+ let src_version = "1.3.8";
7475
7476
  })(), 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
7477
  "PLUGIN_CSS_NAME",
7477
7478
  "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.8",
2119
2119
  rootPath,
2120
2120
  distPath: '',
2121
2121
  cachePath,
@@ -3695,10 +3695,10 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3695
3695
  if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3696
3696
  return port;
3697
3697
  }, getServerConfig = async ({ config })=>{
3698
- let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
3698
+ let { host, port: originalPort, strictPort } = config.server, port = await getPort({
3699
3699
  host,
3700
3700
  port: originalPort,
3701
- strictPort: config.server.strictPort || !1
3701
+ strictPort
3702
3702
  }), 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
3703
  return {
3704
3704
  port,
@@ -3850,14 +3850,15 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3850
3850
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, isServer, environment })=>{
3851
3851
  let { distPath, config } = environment, publicPath = function({ isProd, config, context }) {
3852
3852
  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;
3853
+ let { dev, output, server } = config, publicPath = DEFAULT_ASSET_PREFIX;
3854
3854
  if (isProd) 'string' == typeof output.assetPrefix && (publicPath = output.assetPrefix);
3855
3855
  else if ('string' == typeof dev.assetPrefix) publicPath = dev.assetPrefix;
3856
3856
  else if (!0 === dev.assetPrefix) {
3857
3857
  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
3858
  publicPath = hostname === DEFAULT_DEV_HOST ? `${protocol}://localhost:<port>/` : `${protocol}://${hostname}:<port>/`, server.base && '/' !== server.base && (publicPath = urlJoin(publicPath, server.base));
3859
3859
  }
3860
- return formatPublicPath(replacePortPlaceholder(publicPath, port));
3860
+ let defaultPort = server.port ?? 3000;
3861
+ return formatPublicPath(replacePortPlaceholder(publicPath, isProd ? defaultPort : (null == (_context_devServer = context.devServer) ? void 0 : _context_devServer.port) ?? defaultPort));
3861
3862
  }({
3862
3863
  config,
3863
3864
  isProd,
@@ -4750,7 +4751,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
4750
4751
  getPluginAPI: context.getPluginAPI,
4751
4752
  pluginManager
4752
4753
  }), 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;
4754
+ let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4754
4755
  for (let [name, config] of Object.entries(mergedEnvironments)){
4755
4756
  let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4756
4757
  environments[name] = {
@@ -4763,7 +4764,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
4763
4764
  };
4764
4765
  }
4765
4766
  context.normalizedConfig = {
4766
- ...normalizeBaseConfig,
4767
+ ...normalizedBaseConfig,
4767
4768
  environments
4768
4769
  }, await updateEnvironmentContext(context, environments);
4769
4770
  let distPaths = Object.values(context.environments).map((item)=>item.distPath);
@@ -5716,7 +5717,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5716
5717
  next();
5717
5718
  }), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5718
5719
  let { compiler } = compilationManager;
5719
- middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5720
+ '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
5721
  }
5721
5722
  if (server.proxy) {
5722
5723
  let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
@@ -7289,11 +7290,11 @@ async function runCLI() {
7289
7290
  }
7290
7291
  process.title = 'rsbuild-node';
7291
7292
  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`);
7293
+ (!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.8\n`);
7293
7294
  try {
7294
7295
  !function() {
7295
7296
  let cli = cac_dist('rsbuild');
7296
- cli.help(), cli.version("1.3.7"), applyCommonOptions(cli);
7297
+ cli.help(), cli.version("1.3.8"), applyCommonOptions(cli);
7297
7298
  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
7299
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7299
7300
  try {
@@ -7344,6 +7345,6 @@ async function runCLI() {
7344
7345
  __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
7346
  }
7346
7347
  }
7347
- let src_version = "1.3.7";
7348
+ let src_version = "1.3.8";
7348
7349
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7349
7350
  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.8",
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",