@rsbuild/core 1.4.12 → 1.4.14

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin, isDockerCached, cachedResult;
2
+ let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin, isDockerCached, cachedResult, hmrClientPath, overlayClientPath;
3
3
  import { createRequire } from "node:module";
4
4
  import { logger } from "../compiled/rslog/index.js";
5
5
  import node_path, { dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, sep } from "node:path";
@@ -2846,7 +2846,8 @@ let configCache = {}, OVERRIDE_PATHS = [
2846
2846
  wasm: 'static/wasm',
2847
2847
  image: 'static/image',
2848
2848
  media: 'static/media',
2849
- assets: 'static/assets'
2849
+ assets: 'static/assets',
2850
+ favicon: './'
2850
2851
  },
2851
2852
  assetPrefix: DEFAULT_ASSET_PREFIX,
2852
2853
  filename: {},
@@ -3125,7 +3126,7 @@ async function updateEnvironmentContext(context, configs) {
3125
3126
  async function createContext(options, userConfig) {
3126
3127
  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, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
3127
3128
  return {
3128
- version: "1.4.12",
3129
+ version: "1.4.14",
3129
3130
  rootPath,
3130
3131
  distPath: '',
3131
3132
  cachePath,
@@ -3483,6 +3484,14 @@ async function generateRspackConfig({ target, context, environment }) {
3483
3484
  }
3484
3485
  return config.devServer && logger.warn(`${picocolors.dim('[rsbuild:config]')} Find invalid Rspack config: "${picocolors.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.`), rspackConfig;
3485
3486
  }
3487
+ let allowedEnvironmentDevKeys = [
3488
+ 'hmr',
3489
+ 'liveReload',
3490
+ 'writeToDisk',
3491
+ 'assetPrefix',
3492
+ 'progressBar',
3493
+ 'lazyCompilation'
3494
+ ];
3486
3495
  async function modifyRsbuildConfig(context) {
3487
3496
  var _context_config_plugins, _modified_plugins;
3488
3497
  logger.debug('modify Rsbuild config');
@@ -3549,13 +3558,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
3549
3558
  applyEnvironmentDefaultConfig({
3550
3559
  ...mergeRsbuildConfig({
3551
3560
  ...rsbuildSharedConfig,
3552
- dev: pick(dev, [
3553
- 'writeToDisk',
3554
- 'hmr',
3555
- 'assetPrefix',
3556
- 'progressBar',
3557
- 'lazyCompilation'
3558
- ])
3561
+ dev: pick(dev, allowedEnvironmentDevKeys)
3559
3562
  }, config)
3560
3563
  })
3561
3564
  ]));
@@ -3567,24 +3570,18 @@ async function initRsbuildConfig({ context, pluginManager }) {
3567
3570
  return {
3568
3571
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
3569
3572
  ...rsbuildSharedConfig,
3570
- dev: pick(dev, [
3571
- 'hmr',
3572
- 'assetPrefix',
3573
- 'progressBar',
3574
- 'lazyCompilation',
3575
- 'writeToDisk'
3576
- ])
3573
+ dev: pick(dev, allowedEnvironmentDevKeys)
3577
3574
  })
3578
3575
  };
3579
- })(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr: _hmr, assetPrefix: _assetPrefix, progressBar: _progressBar, lazyCompilation: _lazyCompilation, writeToDisk: _writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig, tsconfigPaths = new Set();
3576
+ })(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), tsconfigPaths = new Set();
3580
3577
  for (let [name, config] of Object.entries(mergedEnvironments)){
3581
3578
  let environmentConfig = await modifyEnvironmentConfig(context, config, name), normalizedEnvironmentConfig = {
3582
3579
  ...environmentConfig,
3583
3580
  dev: {
3584
- ...environmentConfig.dev,
3585
- ...rsbuildSharedDev
3581
+ ...normalizedBaseConfig.dev,
3582
+ ...environmentConfig.dev
3586
3583
  },
3587
- server
3584
+ server: normalizedBaseConfig.server
3588
3585
  }, { tsconfigPath } = normalizedEnvironmentConfig.source;
3589
3586
  if (tsconfigPath) {
3590
3587
  let absoluteTsconfigPath = ensureAbsolutePath(context.rootPath, tsconfigPath);
@@ -4107,22 +4104,26 @@ let entryNameSymbol = Symbol('entryName'), VOID_TAGS = [
4107
4104
  }));
4108
4105
  class RsbuildHtmlPlugin {
4109
4106
  apply(compiler) {
4110
- let emitFavicon = async (compilation, favicon)=>{
4107
+ let emitFavicon = async ({ compilation, favicon, faviconDistPath })=>{
4111
4108
  let buffer, name = node_path.basename(favicon);
4112
4109
  if (compilation.assets[name]) return name;
4113
4110
  if (!compilation.inputFileSystem) return addCompilationError(compilation, `${picocolors.dim('[rsbuild:html]')} Failed to read the favicon file as ${picocolors.yellow('compilation.inputFileSystem')} is not available.`), null;
4114
- let filename = node_path.isAbsolute(favicon) ? favicon : node_path.join(compilation.compiler.context, favicon);
4111
+ let inputFilename = node_path.isAbsolute(favicon) ? favicon : node_path.join(compilation.compiler.context, favicon);
4115
4112
  try {
4116
- if (!(buffer = await external_node_util_promisify(compilation.inputFileSystem.readFile)(filename))) throw Error('Buffer is undefined');
4113
+ if (!(buffer = await external_node_util_promisify(compilation.inputFileSystem.readFile)(inputFilename))) throw Error('Buffer is undefined');
4117
4114
  } catch (error) {
4118
- return logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${picocolors.dim('[rsbuild:html]')} Failed to read the favicon file at ${picocolors.yellow(filename)}.`), null;
4115
+ return logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${picocolors.dim('[rsbuild:html]')} Failed to read the favicon file at ${picocolors.yellow(inputFilename)}.`), null;
4119
4116
  }
4120
- let source = new compiler.webpack.sources.RawSource(buffer, !1);
4121
- return compilation.emitAsset(name, source), name;
4122
- }, addFavicon = async (headTags, favicon, compilation, publicPath)=>{
4117
+ let source = new compiler.webpack.sources.RawSource(buffer, !1), outputFilename = node_path.posix.join(faviconDistPath, name);
4118
+ return compilation.emitAsset(outputFilename, source), outputFilename;
4119
+ }, addFavicon = async ({ headTags, favicon, faviconDistPath, compilation, publicPath })=>{
4123
4120
  let href = favicon;
4124
4121
  if (!isURL(favicon)) {
4125
- let name = await emitFavicon(compilation, favicon);
4122
+ let name = await emitFavicon({
4123
+ compilation,
4124
+ favicon,
4125
+ faviconDistPath
4126
+ });
4126
4127
  if (null === name) return;
4127
4128
  href = ensureAssetPrefix(name, publicPath);
4128
4129
  }
@@ -4146,7 +4147,7 @@ class RsbuildHtmlPlugin {
4146
4147
  hooks.alterAssetTagGroups.tapPromise(this.name, async (data)=>{
4147
4148
  let extraData = getExtraDataByPlugin(data.plugin);
4148
4149
  if (!extraData) return data;
4149
- let { headTags, bodyTags } = data, { favicon, context, tagConfig, entryName, environment, templateContent } = extraData;
4150
+ let { headTags, bodyTags } = data, { favicon, faviconDistPath, context, tagConfig, entryName, environment, templateContent } = extraData;
4150
4151
  if (!(templateContent && /<title/i.test(templateContent) && /<\/title/i.test(templateContent))) {
4151
4152
  var _data_plugin_options;
4152
4153
  ((headTags, title = '')=>{
@@ -4159,7 +4160,13 @@ class RsbuildHtmlPlugin {
4159
4160
  });
4160
4161
  })(headTags, null == (_data_plugin_options = data.plugin.options) ? void 0 : _data_plugin_options.title);
4161
4162
  }
4162
- favicon && await addFavicon(headTags, favicon, compilation, data.publicPath);
4163
+ favicon && await addFavicon({
4164
+ headTags,
4165
+ favicon,
4166
+ faviconDistPath,
4167
+ compilation,
4168
+ publicPath: data.publicPath
4169
+ });
4163
4170
  let tags = {
4164
4171
  headTags: headTags.map(formatBasicTag),
4165
4172
  bodyTags: bodyTags.map(formatBasicTag)
@@ -5234,16 +5241,23 @@ async function getResolvedClientConfig(clientConfig, serverConfig) {
5234
5241
  port: serverConfig.port
5235
5242
  };
5236
5243
  }
5237
- let getCompilationMiddleware = async (compiler, options)=>{
5238
- let { default: rsbuildDevMiddleware } = await import("../compiled/rsbuild-dev-middleware/index.js"), { clientPaths, callbacks, devConfig, serverConfig } = options, resolvedClientConfig = await getResolvedClientConfig(devConfig.client, serverConfig);
5244
+ let compilationMiddleware_require = createRequire(import.meta.url), getCompilationMiddleware = async (compiler, options)=>{
5245
+ let { default: rsbuildDevMiddleware } = await import("../compiled/rsbuild-dev-middleware/index.js"), { callbacks, devConfig, serverConfig } = options, resolvedClientConfig = await getResolvedClientConfig(devConfig.client, serverConfig);
5239
5246
  return applyToCompiler(compiler, (compiler, index)=>{
5240
- var _Object_values_find;
5241
- let token = null == (_Object_values_find = Object.values(options.environments).find((env)=>env.index === index)) ? void 0 : _Object_values_find.webSocketToken;
5242
- token && (clientPaths && function({ compiler, clientPaths, devConfig, resolvedClientConfig, token }) {
5243
- if (((compiler)=>{
5247
+ let environment = Object.values(options.environments).find((env)=>env.index === index);
5248
+ if (!environment) return;
5249
+ let token = environment.webSocketToken;
5250
+ token && (!function({ config, compiler, devConfig, resolvedClientConfig, token }) {
5251
+ if (!((compiler)=>{
5244
5252
  let { target } = compiler.options;
5245
5253
  return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
5246
- })(compiler)) for (let clientPath of (new compiler.webpack.DefinePlugin({
5254
+ })(compiler)) return;
5255
+ let clientPaths = function(devConfig) {
5256
+ var _devConfig_client;
5257
+ let clientPaths = [];
5258
+ return (devConfig.hmr || devConfig.liveReload) && (hmrClientPath || (hmrClientPath = compilationMiddleware_require.resolve('@rsbuild/core/client/hmr')), clientPaths.push(hmrClientPath), (null == (_devConfig_client = devConfig.client) ? void 0 : _devConfig_client.overlay) && (overlayClientPath || (overlayClientPath = compilationMiddleware_require.resolve('@rsbuild/core/client/overlay')), clientPaths.push(overlayClientPath))), clientPaths;
5259
+ }(config.dev);
5260
+ if (clientPaths.length) for (let clientPath of (new compiler.webpack.DefinePlugin({
5247
5261
  RSBUILD_WEB_SOCKET_TOKEN: JSON.stringify(token),
5248
5262
  RSBUILD_CLIENT_CONFIG: JSON.stringify(devConfig.client),
5249
5263
  RSBUILD_RESOLVED_CLIENT_CONFIG: JSON.stringify(resolvedClientConfig),
@@ -5253,10 +5267,10 @@ let getCompilationMiddleware = async (compiler, options)=>{
5253
5267
  }).apply(compiler);
5254
5268
  }({
5255
5269
  compiler,
5256
- clientPaths,
5257
5270
  devConfig,
5258
5271
  resolvedClientConfig,
5259
- token
5272
+ token,
5273
+ config: environment.config
5260
5274
  }), (({ compiler, token, callbacks: { onDone, onInvalid } })=>{
5261
5275
  if (((compiler)=>{
5262
5276
  let { target } = compiler.options;
@@ -5354,9 +5368,6 @@ class SocketServer {
5354
5368
  socket && this.send(socket, messageStr);
5355
5369
  } else for (let socket of this.sockets.values())this.send(socket, messageStr);
5356
5370
  }
5357
- singleWrite(socket, message) {
5358
- this.send(socket, JSON.stringify(message));
5359
- }
5360
5371
  async close() {
5361
5372
  for (let socket of (this.clearHeartbeatTimer(), this.wsServer.removeAllListeners(), this.wsServer.clients))socket.terminate();
5362
5373
  for (let socket of this.sockets.values())socket.close();
@@ -5371,8 +5382,6 @@ class SocketServer {
5371
5382
  socket.isAlive = !0;
5372
5383
  }), this.sockets.set(token, socket), socket.on('close', ()=>{
5373
5384
  this.sockets.delete(token);
5374
- }), (this.options.hmr || this.options.liveReload) && this.singleWrite(socket, {
5375
- type: 'hot'
5376
5385
  }), this.stats && this.sendStats({
5377
5386
  force: !0,
5378
5387
  token
@@ -5417,7 +5426,7 @@ class SocketServer {
5417
5426
  if (!force && statsJson && !statsJson.errorsCount && statsJson.assets && statsJson.assets.every((asset)=>!asset.emitted)) return void this.sockWrite({
5418
5427
  type: 'ok'
5419
5428
  }, token);
5420
- if (this.sockWrite({
5429
+ if (statsJson.hash && this.sockWrite({
5421
5430
  type: 'hash',
5422
5431
  data: statsJson.hash
5423
5432
  }, token), statsJson.errorsCount) {
@@ -5629,7 +5638,6 @@ function compilationManager_define_property(obj, key, value) {
5629
5638
  writable: !0
5630
5639
  }) : obj[key] = value, obj;
5631
5640
  }
5632
- let compilationManager_require = createRequire(import.meta.url);
5633
5641
  class CompilationManager {
5634
5642
  async init() {
5635
5643
  await this.setupCompilationMiddleware(), await this.socketServer.prepare();
@@ -5651,25 +5659,17 @@ class CompilationManager {
5651
5659
  });
5652
5660
  }
5653
5661
  async setupCompilationMiddleware() {
5654
- let { devConfig, serverConfig, publicPaths, environments } = this, clientPaths = function(devConfig) {
5655
- var _devConfig_client;
5656
- let clientPaths = [];
5657
- return (devConfig.hmr || devConfig.liveReload) && (clientPaths.push(compilationManager_require.resolve('@rsbuild/core/client/hmr')), (null == (_devConfig_client = devConfig.client) ? void 0 : _devConfig_client.overlay) && clientPaths.push(compilationManager_require.resolve('@rsbuild/core/client/overlay'))), clientPaths;
5658
- }(devConfig), middleware = await getCompilationMiddleware(this.compiler, {
5662
+ let { devConfig, serverConfig, publicPaths, environments } = this, middleware = await getCompilationMiddleware(this.compiler, {
5659
5663
  callbacks: {
5660
5664
  onInvalid: (token, fileName)=>{
5661
5665
  if ('string' == typeof fileName && fileName.endsWith('.html')) return void this.socketServer.sockWrite({
5662
5666
  type: 'static-changed'
5663
5667
  }, token);
5664
- this.socketServer.sockWrite({
5665
- type: 'invalid'
5666
- }, token);
5667
5668
  },
5668
5669
  onDone: (token, stats)=>{
5669
5670
  this.socketServer.updateStats(stats, token);
5670
5671
  }
5671
5672
  },
5672
- clientPaths,
5673
5673
  devConfig,
5674
5674
  serverConfig,
5675
5675
  environments
@@ -6044,12 +6044,12 @@ let faviconFallbackMiddleware = (req, res, next)=>{
6044
6044
  'default',
6045
6045
  ...Object.keys(something)
6046
6046
  ])
6047
- ], m = new SyntheticModule(exports, ()=>{
6048
- for (let name of exports)m.setExport(name, 'default' === name ? something : something[name]);
6047
+ ], syntheticModule = new SyntheticModule(exports, ()=>{
6048
+ for (let name of exports)syntheticModule.setExport(name, 'default' === name ? something : something[name]);
6049
6049
  }, {
6050
6050
  context
6051
6051
  });
6052
- return unlinked || (await m.link(()=>{}), m.instantiate && m.instantiate(), await m.evaluate()), m;
6052
+ return unlinked || (await syntheticModule.link(()=>{}), await syntheticModule.evaluate()), syntheticModule;
6053
6053
  };
6054
6054
  function basic_define_property(obj, key, value) {
6055
6055
  return key in obj ? Object.defineProperty(obj, key, {
@@ -6212,7 +6212,7 @@ class EsmRunner extends CommonJsRunner {
6212
6212
  }), esmCache.set(file.path, esm)), context.esmMode === type_EsmMode.Unlinked) ? esm : (async ()=>{
6213
6213
  if (await esm.link(async (specifier, referencingModule)=>asModule(await _require(node_path.dirname(referencingModule.identifier ? referencingModule.identifier.slice(esmIdentifier.length + 1) : fileURLToPath(referencingModule.url)), specifier, {
6214
6214
  esmMode: type_EsmMode.Unlinked
6215
- }), referencingModule.context, !0)), esm.instantiate && esm.instantiate(), await esm.evaluate(), context.esmMode === type_EsmMode.Evaluated) return esm;
6215
+ }), referencingModule.context, !0)), await esm.evaluate(), context.esmMode === type_EsmMode.Evaluated) return esm;
6216
6216
  let ns = esm.namespace;
6217
6217
  return ns.default && ns.default instanceof Promise ? ns.default : ns;
6218
6218
  })();
@@ -7152,7 +7152,8 @@ async function applyDefaultPlugins(pluginManager, context) {
7152
7152
  let extraData = {
7153
7153
  entryName,
7154
7154
  context: context,
7155
- environment
7155
+ environment,
7156
+ faviconDistPath: config.output.distPath.favicon
7156
7157
  };
7157
7158
  extraDataMap.set(entryName, extraData), templateContent && (extraData.templateContent = templateContent);
7158
7159
  let tagConfig = ((config)=>{
@@ -8808,11 +8809,11 @@ async function runCLI() {
8808
8809
  ].includes(level) && (logger.level = level);
8809
8810
  }
8810
8811
  let { npm_execpath } = process.env;
8811
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.12\n`);
8812
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.14\n`);
8812
8813
  try {
8813
8814
  !function() {
8814
8815
  let cli = ((name = "")=>new CAC(name))('rsbuild');
8815
- cli.help(), cli.version("1.4.12"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
8816
+ cli.help(), cli.version("1.4.14"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
8816
8817
  default: 'jiti'
8817
8818
  }).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
8818
8819
  type: [
@@ -8870,5 +8871,5 @@ async function runCLI() {
8870
8871
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
8871
8872
  }
8872
8873
  }
8873
- let src_version = "1.4.12";
8874
+ let src_version = "1.4.14";
8874
8875
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack_rspack as rspack, runCLI, src_version as version };
@@ -2,6 +2,7 @@ export declare const __filename: string;
2
2
  export declare const __dirname: string;
3
3
  export declare const ROOT_DIST_DIR = "dist";
4
4
  export declare const HTML_DIST_DIR = "./";
5
+ export declare const FAVICON_DIST_DIR = "./";
5
6
  export declare const JS_DIST_DIR = "static/js";
6
7
  export declare const CSS_DIST_DIR = "static/css";
7
8
  export declare const SVG_DIST_DIR = "static/svg";
@@ -20,6 +20,7 @@ export type HtmlExtraData = {
20
20
  context: InternalContext;
21
21
  environment: EnvironmentContext;
22
22
  favicon?: string;
23
+ faviconDistPath: string;
23
24
  tagConfig?: TagConfig;
24
25
  templateContent?: string;
25
26
  };
@@ -15,10 +15,6 @@ export declare const setupServerHooks: ({ compiler, token, callbacks: { onDone,
15
15
  callbacks: ServerCallbacks;
16
16
  }) => void;
17
17
  export type CompilationMiddlewareOptions = {
18
- /**
19
- * To ensure HMR works, the devMiddleware need inject the HMR client path into page when HMR enable.
20
- */
21
- clientPaths?: string[];
22
18
  /**
23
19
  * Should trigger when compiler hook called
24
20
  */
@@ -1,9 +1,14 @@
1
1
  import type { Server } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
3
  import type { Connect, CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
4
+ import type { SocketMessage } from './socketServer';
4
5
  type HTTPServer = Server | Http2SecureServer;
5
- export type SockWriteType = 'static-changed' | (string & {});
6
- export type SockWrite = (type: SockWriteType, data?: string | boolean | Record<string, any>) => void;
6
+ type ExtractSocketMessageData<T extends SocketMessage['type']> = Extract<SocketMessage, {
7
+ type: T;
8
+ }> extends {
9
+ data: infer D;
10
+ } ? D : undefined;
11
+ export type SockWrite = <T extends SocketMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
7
12
  export type RsbuildDevServer = {
8
13
  /**
9
14
  * The `connect` app instance.
@@ -1,11 +1,30 @@
1
1
  import type { IncomingMessage } from 'node:http';
2
2
  import type { Socket } from 'node:net';
3
3
  import type { DevConfig, EnvironmentContext, Rspack } from '../types';
4
- import type { SockWriteType } from './devServer';
5
- interface SocketMessage {
6
- type: SockWriteType;
7
- data?: Record<string, any> | string | boolean;
8
- }
4
+ export type SocketMessageStaticChanged = {
5
+ type: 'static-changed' | 'content-changed';
6
+ };
7
+ export type SocketMessageHash = {
8
+ type: 'hash';
9
+ data: string;
10
+ };
11
+ export type SocketMessageOk = {
12
+ type: 'ok';
13
+ };
14
+ export type SocketMessageWarnings = {
15
+ type: 'warnings';
16
+ data: {
17
+ text: string[];
18
+ };
19
+ };
20
+ export type SocketMessageErrors = {
21
+ type: 'errors';
22
+ data: {
23
+ text: string[];
24
+ html: string;
25
+ };
26
+ };
27
+ export type SocketMessage = SocketMessageOk | SocketMessageStaticChanged | SocketMessageHash | SocketMessageWarnings | SocketMessageErrors;
9
28
  export declare class SocketServer {
10
29
  private wsServer;
11
30
  private readonly sockets;
@@ -27,11 +46,9 @@ export declare class SocketServer {
27
46
  * if not provided, the message will be sent to all sockets
28
47
  */
29
48
  sockWrite(message: SocketMessage, token?: string): void;
30
- private singleWrite;
31
49
  close(): Promise<void>;
32
50
  private onConnect;
33
51
  private getStats;
34
52
  private sendStats;
35
53
  private send;
36
54
  }
37
- export {};
@@ -683,7 +683,7 @@ export type DistPathConfig = {
683
683
  font?: string;
684
684
  /**
685
685
  * The output directory of HTML files.
686
- * @default '/'
686
+ * @default './'
687
687
  */
688
688
  html?: string;
689
689
  /**
@@ -706,6 +706,11 @@ export type DistPathConfig = {
706
706
  * @default 'static/assets'
707
707
  */
708
708
  assets?: string;
709
+ /**
710
+ * The output directory of favicon.
711
+ * @default './'
712
+ */
713
+ favicon?: string;
709
714
  };
710
715
  export type FilenameConfig = {
711
716
  /**
@@ -1523,6 +1528,10 @@ export type RsbuildConfigMeta = {
1523
1528
  */
1524
1529
  configFilePath: string;
1525
1530
  };
1531
+ /**
1532
+ * Only some dev options can be defined in the environment config
1533
+ */
1534
+ export type AllowedEnvironmentDevKeys = 'hmr' | 'liveReload' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk';
1526
1535
  /**
1527
1536
  * The Rsbuild config to run in the specified environment.
1528
1537
  * */
@@ -1530,7 +1539,7 @@ export interface EnvironmentConfig {
1530
1539
  /**
1531
1540
  * Options for local development.
1532
1541
  */
1533
- dev?: Pick<DevConfig, 'hmr' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk'>;
1542
+ dev?: Pick<DevConfig, AllowedEnvironmentDevKeys>;
1534
1543
  /**
1535
1544
  * Options for HTML generation.
1536
1545
  */
@@ -1618,7 +1627,7 @@ export interface RsbuildConfig extends EnvironmentConfig {
1618
1627
  export type MergedEnvironmentConfig = {
1619
1628
  mode: RsbuildMode;
1620
1629
  root: string;
1621
- dev: Pick<NormalizedDevConfig, 'hmr' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk'>;
1630
+ dev: Pick<NormalizedDevConfig, AllowedEnvironmentDevKeys>;
1622
1631
  html: NormalizedHtmlConfig;
1623
1632
  tools: NormalizedToolsConfig;
1624
1633
  resolve: NormalizedResolveConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.4.12",
3
+ "version": "1.4.14",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -53,10 +53,10 @@
53
53
  "jiti": "^2.5.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@rslib/core": "0.11.0",
56
+ "@rslib/core": "0.11.1",
57
57
  "@types/connect": "3.4.38",
58
58
  "@types/cors": "^2.8.19",
59
- "@types/node": "^22.16.5",
59
+ "@types/node": "^22.17.0",
60
60
  "@types/on-finished": "2.3.5",
61
61
  "@types/webpack-bundle-analyzer": "4.7.0",
62
62
  "@types/ws": "^8.18.1",
@@ -70,7 +70,7 @@
70
70
  "dotenv-expand": "12.0.2",
71
71
  "html-rspack-plugin": "6.1.2",
72
72
  "http-proxy-middleware": "^2.0.9",
73
- "launch-editor-middleware": "^2.10.0",
73
+ "launch-editor-middleware": "^2.11.0",
74
74
  "mrmime": "^2.0.1",
75
75
  "on-finished": "2.4.1",
76
76
  "open": "^10.2.0",
@@ -87,8 +87,8 @@
87
87
  "sirv": "^3.0.1",
88
88
  "style-loader": "3.3.4",
89
89
  "tinyglobby": "^0.2.14",
90
- "typescript": "^5.8.3",
91
- "webpack": "^5.100.2",
90
+ "typescript": "^5.9.2",
91
+ "webpack": "^5.101.0",
92
92
  "webpack-bundle-analyzer": "^4.10.2",
93
93
  "webpack-merge": "6.0.1",
94
94
  "ws": "^8.18.3"
@@ -98,7 +98,6 @@
98
98
  },
99
99
  "publishConfig": {
100
100
  "access": "public",
101
- "provenance": true,
102
101
  "registry": "https://registry.npmjs.org/"
103
102
  },
104
103
  "scripts": {