@rsbuild/core 2.0.12 → 2.0.13

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.
Files changed (3) hide show
  1. package/dist/756.js +40 -11
  2. package/package.json +1 -1
  3. package/types.d.ts +1 -1
package/dist/756.js CHANGED
@@ -3483,7 +3483,7 @@ function createPublicContext(context) {
3483
3483
  async function createContext(options, userConfig, logger) {
3484
3484
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3485
3485
  return {
3486
- version: "2.0.12",
3486
+ version: "2.0.13",
3487
3487
  rootPath,
3488
3488
  distPath: '',
3489
3489
  cachePath,
@@ -5868,6 +5868,14 @@ async function open_open({ port, routes, config, protocol, clearCache, logger })
5868
5868
  let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${protocol}://${host}:${port}`;
5869
5869
  for (let url of (targets.length ? urls.push(...targets.map((target)=>resolveUrl(replacePortPlaceholder(target, port), baseUrl))) : routes.length ? urls.push(`${baseUrl}${routes[0].pathname}`) : urls.push(baseUrl), before && await before(), urls))openedURLs.includes(url) || (openBrowser(url, logger), openedURLs.push(url));
5870
5870
  }
5871
+ let getServerUrlFromClientConfig = async (config, context)=>{
5872
+ let { devServer } = context;
5873
+ if (!devServer) return;
5874
+ let { client } = config.dev, hasClientHost = !!client.host, hasClientPort = void 0 !== client.port && '' !== client.port;
5875
+ if (!hasClientHost && !hasClientPort) return;
5876
+ let protocol = client.protocol ? `${'wss' === client.protocol ? 'https' : 'http'}:` : '', hostname = await getHostInUrl(client.host || devServer.hostname), port = client.port && '<port>' !== client.port ? client.port : devServer.port;
5877
+ return `${protocol}//${hostname}:${port}`;
5878
+ };
5871
5879
  function recursiveChunkGroup(chunkGroup, visited = new Set()) {
5872
5880
  if (visited.has(chunkGroup)) return [];
5873
5881
  visited.add(chunkGroup);
@@ -9454,7 +9462,7 @@ try {
9454
9462
  for (let file of chunkFiles){
9455
9463
  file.isInitial || (isCSSPath(file.path) ? asyncCSS.push(file.path) : asyncJS.push(file.path));
9456
9464
  let relatedLICENSE = licenseMap.get(file.path);
9457
- if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
9465
+ if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(manifestOptions.prefix ? ensureAssetPrefix(auxiliaryFile, publicPath) : auxiliaryFile);
9458
9466
  }
9459
9467
  let entryManifest = {};
9460
9468
  assets.size && (entryManifest.assets = Array.from(assets));
@@ -9519,18 +9527,39 @@ try {
9519
9527
  name: 'rsbuild:lazy-compilation',
9520
9528
  apply: 'serve',
9521
9529
  setup (api) {
9522
- api.modifyBundlerChain((chain, { environment, target })=>{
9530
+ api.modifyBundlerChain(async (chain, { environment, target })=>{
9523
9531
  if ('web' !== target) return;
9524
- let { config } = environment, options = config.dev?.lazyCompilation;
9532
+ let { config } = environment;
9533
+ if (!config.dev.hmr && !config.dev.liveReload) return;
9534
+ let options = config.dev?.lazyCompilation;
9525
9535
  if (options) {
9526
- if (!0 === options && Object.keys(chain.entryPoints.entries() || {}).length <= 1) return void chain.lazyCompilation({
9527
- entries: !1,
9528
- imports: !0
9529
- });
9536
+ if (!0 === options) {
9537
+ let entries = chain.entryPoints.entries() || {}, serverUrl = await getServerUrlFromClientConfig(config, api.context);
9538
+ if (Object.keys(entries).length <= 1) return void chain.lazyCompilation({
9539
+ entries: !1,
9540
+ imports: !0,
9541
+ ...serverUrl ? {
9542
+ serverUrl
9543
+ } : {}
9544
+ });
9545
+ if (serverUrl) return void chain.lazyCompilation({
9546
+ entries: !0,
9547
+ imports: !0,
9548
+ serverUrl
9549
+ });
9550
+ }
9530
9551
  if ('object' == typeof options && 'string' == typeof options.serverUrl && api.context.devServer) return void chain.lazyCompilation({
9531
9552
  ...options,
9532
9553
  serverUrl: replacePortPlaceholder(options.serverUrl, api.context.devServer.port)
9533
9554
  });
9555
+ if ('object' == typeof options) {
9556
+ let serverUrl = await getServerUrlFromClientConfig(config, api.context);
9557
+ chain.lazyCompilation(serverUrl ? {
9558
+ ...options,
9559
+ serverUrl
9560
+ } : options);
9561
+ return;
9562
+ }
9534
9563
  chain.lazyCompilation(options);
9535
9564
  }
9536
9565
  });
@@ -9941,7 +9970,7 @@ let applyServerOptions = (command)=>{
9941
9970
  };
9942
9971
  function setupCommands() {
9943
9972
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9944
- cli.version("2.0.12"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9973
+ cli.version("2.0.13"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9945
9974
  default: 'auto'
9946
9975
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9947
9976
  type: [
@@ -10012,7 +10041,7 @@ function initNodeEnv(command) {
10012
10041
  }
10013
10042
  function showGreeting() {
10014
10043
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
10015
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.12\n`);
10044
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.13\n`);
10016
10045
  }
10017
10046
  function setupLogLevel() {
10018
10047
  if (cli_argv.length <= 3) return;
@@ -10034,5 +10063,5 @@ function runCLI() {
10034
10063
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
10035
10064
  }
10036
10065
  }
10037
- let src_version = "2.0.12";
10066
+ let src_version = "2.0.13";
10038
10067
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
package/types.d.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  * }
12
12
  * ```
13
13
  */
14
- // rslint-disable-next-line @typescript-eslint/no-empty-interface
14
+ // rslint-disable-next-line @typescript-eslint/no-empty-object-type
15
15
  interface RsbuildTypeOptions {}
16
16
 
17
17
  /**