@rsbuild/core 2.0.0-rc.0 → 2.0.0-rc.1

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.
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 855: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(433)["default"];
4
+ 864: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(334)["default"];
6
6
  },
7
- 433: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 334: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
8
  var __webpack_unused_export__;
9
9
  __webpack_unused_export__ = { value: true };
10
10
  exports["default"] = loader;
11
11
  var _nodePath = _interopRequireDefault(__nccwpck_require__(760));
12
- var _utils = __nccwpck_require__(516);
12
+ var _utils = __nccwpck_require__(791);
13
13
  function _interopRequireDefault(e) {
14
14
  return e && e.__esModule ? e : { default: e };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 516: (module, exports, __nccwpck_require__) => {
182
+ 791: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -716,6 +716,6 @@
716
716
  })();
717
717
  if (typeof __nccwpck_require__ !== "undefined")
718
718
  __nccwpck_require__.ab = __dirname + "/";
719
- var __webpack_exports__ = __nccwpck_require__(855);
719
+ var __webpack_exports__ = __nccwpck_require__(864);
720
720
  module.exports = __webpack_exports__;
721
721
  })();
@@ -1 +1 @@
1
- {"name":"rspack-chain","version":"2.0.0-beta.1","license":"MIT","types":"types/index.d.ts","type":"module"}
1
+ {"name":"rspack-chain","version":"2.0.0-rc.1","license":"MIT","types":"types/index.d.ts","type":"module"}
@@ -1,12 +1,4 @@
1
- import {
2
- Configuration,
3
- Compiler,
4
- RuleSetRule,
5
- ResolveOptions,
6
- } from '@rspack/core';
7
- import * as https from 'https';
8
-
9
- export default Config;
1
+ import { Configuration, RuleSetRule } from '@rspack/core';
10
2
 
11
3
  // The compiler type of Rspack / webpack are mismatch,
12
4
  // so we use a loose type here to allow using webpack plugins.
@@ -60,24 +52,24 @@ declare namespace __Config {
60
52
  }
61
53
 
62
54
  type RspackConfig = Required<Configuration>;
63
- declare class Config extends __Config.ChainedMap<void> {
64
- entryPoints: Config.TypedChainedMap<
65
- Config,
66
- { [key: string]: Config.EntryPoint }
55
+ export declare class RspackChain extends __Config.ChainedMap<void> {
56
+ entryPoints: RspackChain.TypedChainedMap<
57
+ RspackChain,
58
+ { [key: string]: RspackChain.EntryPoint }
67
59
  >;
68
- output: Config.Output;
69
- module: Config.Module;
70
- node: Config.ChainedMap<this> & ((value: boolean) => this);
71
- optimization: Config.Optimization;
72
- performance: Config.Performance & ((value: boolean) => this);
73
- plugins: Config.Plugins<this, PluginInstance>;
74
- resolve: Config.Resolve;
75
- resolveLoader: Config.ResolveLoader;
76
- devServer: Config.DevServer;
60
+ output: RspackChain.Output;
61
+ module: RspackChain.Module;
62
+ node: RspackChain.ChainedMap<this> & ((value: boolean) => this);
63
+ optimization: RspackChain.Optimization;
64
+ performance: RspackChain.Performance & ((value: boolean) => this);
65
+ plugins: RspackChain.Plugins<this, PluginInstance>;
66
+ resolve: RspackChain.Resolve;
67
+ resolveLoader: RspackChain.ResolveLoader;
68
+ devServer: RspackChain.DevServer;
77
69
 
78
70
  context(value: RspackConfig['context']): this;
79
71
  mode(value: RspackConfig['mode']): this;
80
- devtool(value: Config.DevTool): this;
72
+ devtool(value: RspackChain.DevTool): this;
81
73
  target(value: RspackConfig['target']): this;
82
74
  watch(value: RspackConfig['watch']): this;
83
75
  watchOptions(value: RspackConfig['watchOptions']): this;
@@ -97,8 +89,8 @@ declare class Config extends __Config.ChainedMap<void> {
97
89
  snapshot(value: RspackConfig['snapshot']): this;
98
90
  lazyCompilation(value: RspackConfig['lazyCompilation']): this;
99
91
 
100
- entry(name: string): Config.EntryPoint;
101
- plugin(name: string): Config.Plugin<this, PluginInstance>;
92
+ entry(name: string): RspackChain.EntryPoint;
93
+ plugin(name: string): RspackChain.Plugin<this, PluginInstance>;
102
94
 
103
95
  toConfig(): Configuration;
104
96
 
@@ -114,7 +106,7 @@ declare class Config extends __Config.ChainedMap<void> {
114
106
  ): string;
115
107
  }
116
108
 
117
- declare namespace Config {
109
+ export declare namespace RspackChain {
118
110
  class Chained<Parent> extends __Config.Chained<Parent> {}
119
111
  class TypedChainedMap<Parent, OptionsType> extends __Config.TypedChainedMap<
120
112
  Parent,
@@ -169,11 +161,11 @@ declare namespace Config {
169
161
  string | string[] | Function
170
162
  >[string];
171
163
 
172
- class EntryPoint extends TypedChainedSet<Config, RspackEntryObject> {}
164
+ class EntryPoint extends TypedChainedSet<RspackChain, RspackEntryObject> {}
173
165
 
174
166
  type RspackModule = Required<NonNullable<Configuration['module']>>;
175
167
 
176
- class Module extends ChainedMap<Config> {
168
+ class Module extends ChainedMap<RspackChain> {
177
169
  rules: TypedChainedMap<this, { [key: string]: Rule }>;
178
170
  generator: ChainedMap<this>;
179
171
  parser: ChainedMap<this>;
@@ -183,7 +175,7 @@ declare namespace Config {
183
175
 
184
176
  type RspackOutput = Required<NonNullable<Configuration['output']>>;
185
177
 
186
- class Output extends ChainedMap<Config> {
178
+ class Output extends ChainedMap<RspackChain> {
187
179
  assetModuleFilename(value: RspackOutput['assetModuleFilename']): this;
188
180
  bundlerInfo(value: RspackOutput['bundlerInfo']): this;
189
181
  chunkFilename(value: RspackOutput['chunkFilename']): this;
@@ -241,92 +233,21 @@ declare namespace Config {
241
233
  clean(value: RspackOutput['clean']): this;
242
234
  }
243
235
 
244
- // await for @types/webpack-dev-server update do v4 to remove all any
245
- class DevServer extends ChainedMap<Config> {
246
- allowedHosts: TypedChainedSet<this, string>;
247
- after(value: (app: any, server: any, compiler: Compiler) => void): this;
248
- before(value: (app: any, server: any, compiler: Compiler) => void): this;
249
- bonjour(value: boolean): this;
250
- clientLogLevel(
251
- value:
252
- | 'silent'
253
- | 'trace'
254
- | 'debug'
255
- | 'info'
256
- | 'warn'
257
- | 'error'
258
- | 'none'
259
- | 'warning',
260
- ): this;
261
- compress(value: boolean): this;
262
- contentBase(value: boolean | string | string[]): this;
263
- contentBasePublicPath(value: string): this;
264
- disableHostCheck(value: boolean): this;
265
- filename(value: string): this;
266
- headers(value: { [header: string]: string }): this;
267
- historyApiFallback(value: boolean | any): this;
268
- host(value: string): this;
269
- hot(value: boolean): this;
270
- hotOnly(value: boolean): this;
271
- http2(value: boolean): this;
272
- https(value: boolean | https.ServerOptions): this;
273
- index(value: string): this;
274
- injectClient(value: boolean | ((compiler: Compiler) => boolean)): this;
275
- injectHot(value: boolean | ((compiler: Compiler) => boolean)): this;
276
- inline(value: boolean): this;
277
- lazy(value: boolean): this;
278
- liveReload(value: boolean): this;
279
- mimeTypes(value: Object): this;
280
- noInfo(value: boolean): this;
281
- onListening(value: (server: any) => void): this;
282
- open(value: boolean): this;
283
- openPage(value: string | string[]): this;
284
- overlay(value: boolean | { warnings?: boolean; errors?: boolean }): this;
285
- pfx(value: string): this;
286
- pfxPassphrase(value: string): this;
287
- port(value: number): this;
288
- progress(value: boolean): this;
289
- proxy(value: any): this;
290
- public(value: string): this;
291
- publicPath(publicPath: string): this;
292
- quiet(value: boolean): this;
293
- serveIndex(value: boolean): this;
294
- setup(value: (expressApp: any) => void): this;
295
- socket(value: string): this;
296
- sockHost(value: string): this;
297
- sockPath(value: string): this;
298
- sockPort(value: number): this;
299
- staticOptions(value: any): this;
300
- stats(value: Configuration['stats']): this;
301
- stdin(value: boolean): this;
302
- transportMode(
303
- value:
304
- | 'sockjs'
305
- | 'ws'
306
- | {
307
- server: 'ws';
308
- client: object;
309
- }
310
- | {
311
- client: 'sockjs';
312
- server: object;
313
- }
314
- | {
315
- client: object;
316
- server: object;
317
- },
318
- ): this;
319
- useLocalIp(value: boolean): this;
320
- watchContentBase(value: boolean): this;
321
- watchOptions(value: Configuration['watchOptions']): this;
322
- writeToDisk(value: boolean): this;
323
- }
236
+ type RspackDevServer = Required<NonNullable<Configuration['devServer']>>;
237
+
238
+ type DevServerShorthandMethods<T> = {
239
+ [K in keyof RspackDevServer]-?: (value: RspackDevServer[K]) => T;
240
+ };
241
+
242
+ class DevServer extends TypedChainedMap<RspackChain, RspackDevServer> {}
243
+
244
+ interface DevServer extends DevServerShorthandMethods<DevServer> {}
324
245
 
325
246
  type RspackPerformance = Exclude<
326
247
  Required<NonNullable<Configuration['performance']>>,
327
248
  false
328
249
  >;
329
- class Performance extends ChainedMap<Config> {
250
+ class Performance extends ChainedMap<RspackChain> {
330
251
  hints(value: RspackPerformance['hints']): this;
331
252
  maxEntrypointSize(value: RspackPerformance['maxEntrypointSize']): this;
332
253
  maxAssetSize(value: RspackPerformance['maxAssetSize']): this;
@@ -334,7 +255,7 @@ declare namespace Config {
334
255
  }
335
256
 
336
257
  type RspackResolve = Required<NonNullable<Configuration['resolve']>>;
337
- class Resolve<T = Config> extends ChainedMap<T> {
258
+ class Resolve<T = RspackChain> extends ChainedMap<T> {
338
259
  alias: TypedChainedMap<this, { [key: string]: string | false | string[] }>;
339
260
  aliasFields: TypedChainedSet<this, RspackResolve['aliasFields'][number]>;
340
261
  conditionNames: TypedChainedSet<
@@ -373,7 +294,7 @@ declare namespace Config {
373
294
  tsConfig(value: RspackResolve['tsConfig']): this;
374
295
  }
375
296
 
376
- class RuleResolve<T = Config> extends Resolve<T> {
297
+ class RuleResolve<T = RspackChain> extends Resolve<T> {
377
298
  fullySpecified(value: boolean): this;
378
299
  }
379
300
 
@@ -422,9 +343,9 @@ declare namespace Config {
422
343
  NonNullable<Configuration['optimization']>
423
344
  >;
424
345
  type SplitChunksObject = Exclude<RspackOptimization['splitChunks'], false>;
425
- class Optimization extends ChainedMap<Config> {
426
- minimizer(name: string): Config.Plugin<this, PluginInstance>;
427
- minimizers: TypedChainedMap<this, Config.Plugin<this, PluginInstance>>;
346
+ class Optimization extends ChainedMap<RspackChain> {
347
+ minimizer(name: string): RspackChain.Plugin<this, PluginInstance>;
348
+ minimizers: TypedChainedMap<this, RspackChain.Plugin<this, PluginInstance>>;
428
349
  splitChunks: TypedChainedMap<this, SplitChunksObject> &
429
350
  ((value: SplitChunksObject | false) => this);
430
351
 
@@ -5,7 +5,7 @@ function __webpack_require__(moduleId) {
5
5
  var module = __webpack_module_cache__[moduleId] = {
6
6
  exports: {}
7
7
  };
8
- return __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__), module.exports;
8
+ return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
9
9
  }
10
10
  __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
11
11
  var getter = module && module.__esModule ? ()=>module.default : ()=>module;
@@ -1,5 +1,5 @@
1
- /*! LICENSE: 552.js.LICENSE.txt */
2
- let flagForceColor, runtimeProcessArgs, runtimeInfo, swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
1
+ /*! LICENSE: 863.js.LICENSE.txt */
2
+ let flagForceColor, runtimeProcessArgs, runtimeInfo, swcHelpersPath, pluginHelper_htmlPlugin;
3
3
  import { rspack as core_rspack } from "@rspack/core";
4
4
  import node_util, { stripVTControlCharacters } from "node:util";
5
5
  import node_process from "node:process";
@@ -612,9 +612,6 @@ __webpack_require__.add({
612
612
  throw Error(`'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${importError.map((error)=>error.message).join('\n')}`);
613
613
  };
614
614
  },
615
- assert (module) {
616
- module.exports = __rspack_createRequire_require("assert");
617
- },
618
615
  async_hooks (module) {
619
616
  module.exports = __rspack_createRequire_require("async_hooks");
620
617
  },
@@ -672,9 +669,6 @@ __webpack_require__.add({
672
669
  process (module) {
673
670
  module.exports = __rspack_createRequire_require("process");
674
671
  },
675
- querystring (module) {
676
- module.exports = __rspack_createRequire_require("querystring");
677
- },
678
672
  stream (module) {
679
673
  module.exports = __rspack_createRequire_require("stream");
680
674
  },
@@ -1988,69 +1982,32 @@ let ChainedMap = createMap(createChainable(Object)), ChainedValueMap = (superCla
1988
1982
  }
1989
1983
  }, DevServer = class extends ChainedMap {
1990
1984
  constructor(parent){
1991
- super(parent), this.allowedHosts = new ChainedSet(this), this.extend([
1992
- 'after',
1993
- 'before',
1994
- 'bonjour',
1995
- 'clientLogLevel',
1985
+ super(parent), this.extend([
1986
+ 'allowedHosts',
1987
+ 'app',
1988
+ 'client',
1996
1989
  'compress',
1997
- 'contentBase',
1998
- 'contentBasePublicPath',
1999
- 'disableHostCheck',
2000
- 'filename',
1990
+ 'devMiddleware',
2001
1991
  'headers',
2002
- 'historyApiFallback',
2003
1992
  'host',
1993
+ 'historyApiFallback',
2004
1994
  'hot',
2005
- 'hotOnly',
2006
- 'http2',
2007
- 'https',
2008
- 'index',
2009
- 'injectClient',
2010
- 'injectHot',
2011
- 'inline',
2012
- 'lazy',
1995
+ 'ipc',
2013
1996
  'liveReload',
2014
- 'mimeTypes',
2015
- 'noInfo',
2016
1997
  'onListening',
2017
1998
  'open',
2018
- 'openPage',
2019
- 'overlay',
2020
- 'pfx',
2021
- 'pfxPassphrase',
2022
1999
  'port',
2023
2000
  'proxy',
2024
- 'progress',
2025
- 'public',
2026
- 'publicPath',
2027
- 'quiet',
2028
- 'serveIndex',
2029
- 'setup',
2030
- 'socket',
2031
- 'sockHost',
2032
- 'sockPath',
2033
- 'sockPort',
2034
- 'staticOptions',
2035
- 'stats',
2036
- 'stdin',
2037
- 'transportMode',
2038
- 'useLocalIp',
2039
- 'watchContentBase',
2040
- 'watchOptions',
2041
- 'writeToDisk'
2001
+ 'server',
2002
+ 'setupExitSignals',
2003
+ 'setupMiddlewares',
2004
+ 'static',
2005
+ 'watchFiles',
2006
+ 'webSocketServer'
2042
2007
  ]);
2043
2008
  }
2044
2009
  toConfig() {
2045
- return this.clean({
2046
- allowedHosts: this.allowedHosts.values(),
2047
- ...this.entries() || {}
2048
- });
2049
- }
2050
- merge(obj, omit = []) {
2051
- return !omit.includes('allowedHosts') && 'allowedHosts' in obj && this.allowedHosts.merge(obj.allowedHosts), super.merge(obj, [
2052
- 'allowedHosts'
2053
- ]);
2010
+ return this.clean(this.entries() || {});
2054
2011
  }
2055
2012
  }, Orderable = (Class)=>class extends Class {
2056
2013
  before(name) {
@@ -2272,7 +2229,7 @@ let Rule = Orderable(class extends ChainedMap {
2272
2229
  ]);
2273
2230
  }
2274
2231
  minimizer(name) {
2275
- if (Array.isArray(name)) throw Error("optimization.minimizer() no longer supports being passed an array. Either switch to the new syntax (https://github.com/neutrinojs/webpack-chain#config-optimization-minimizers-adding) or downgrade to webpack-chain 4. If using Vue this likely means a Vue plugin has not yet been updated to support Vue CLI 4+.");
2232
+ if (Array.isArray(name)) throw Error('optimization.minimizer() no longer supports being passed an array.');
2276
2233
  return this.minimizers.getOrCompute(name, ()=>new src_Plugin(this, name, 'optimization.minimizer'));
2277
2234
  }
2278
2235
  toConfig() {
@@ -2298,7 +2255,8 @@ let Rule = Orderable(class extends ChainedMap {
2298
2255
  }
2299
2256
  }, dist = __nested_rspack_require_65__("./node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js"), castArray = (value)=>Array.isArray(value) ? value : [
2300
2257
  value
2301
- ], dist_src = class extends ChainedMap {
2258
+ ];
2259
+ class RspackChain extends ChainedMap {
2302
2260
  constructor(){
2303
2261
  super(), this.entryPoints = new ChainedMap(this), this.output = new Output(this), this.module = new dist_Module(this), this.resolve = new Resolve(this), this.resolveLoader = new ResolveLoader(this), this.optimization = new Optimization(this), this.plugins = new ChainedMap(this), this.devServer = new DevServer(this), this.performance = new Performance(this), this.node = new ChainedValueMap(this), this.extend([
2304
2262
  'context',
@@ -2406,7 +2364,8 @@ let Rule = Orderable(class extends ChainedMap {
2406
2364
  'plugin'
2407
2365
  ]);
2408
2366
  }
2409
- }, vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), cjs_0 = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
2367
+ }
2368
+ let vendors_require = createRequire(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), cjs_0 = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
2410
2369
  var cjs_0_default = __webpack_require__.n(cjs_0);
2411
2370
  let setNodeEnv = (env)=>{
2412
2371
  process.env.NODE_ENV = env;
@@ -3087,7 +3046,7 @@ let OVERRIDE_PATHS = new Set([
3087
3046
  define: {},
3088
3047
  preEntry: [],
3089
3048
  decorators: {
3090
- version: '2022-03'
3049
+ version: '2023-11'
3091
3050
  }
3092
3051
  },
3093
3052
  output: {
@@ -3602,7 +3561,7 @@ function createPublicContext(context) {
3602
3561
  async function createContext(options, userConfig, logger) {
3603
3562
  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;
3604
3563
  return {
3605
- version: "2.0.0-rc.0",
3564
+ version: "2.0.0-rc.1",
3606
3565
  rootPath,
3607
3566
  distPath: '',
3608
3567
  cachePath,
@@ -3664,7 +3623,7 @@ async function emitConfigFiles({ bundlerConfigs, environmentConfigs, extraConfig
3664
3623
  logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
3665
3624
  }
3666
3625
  function stringifyConfig(config, verbose) {
3667
- return dist_src.toString(config, {
3626
+ return RspackChain.toString(config, {
3668
3627
  verbose
3669
3628
  });
3670
3629
  }
@@ -3733,12 +3692,20 @@ function reduceConfigsWithContext({ initial, config, ctx, mergeFn = Object.assig
3733
3692
  }), initial) : config ?? initial;
3734
3693
  }
3735
3694
  async function reduceConfigsAsyncWithContext({ initial, config, ctx, mergeFn = Object.assign }) {
3736
- return null == config ? initial : dist_isPlainObject(config) ? dist_isPlainObject(initial) ? mergeFn(initial, config) : config : 'function' == typeof config ? await config(initial, ctx) ?? initial : Array.isArray(config) ? config.reduce((initial, config)=>reduceConfigsWithContext({
3737
- initial,
3738
- config,
3695
+ if (null == config) return initial;
3696
+ if (dist_isPlainObject(config)) return dist_isPlainObject(initial) ? mergeFn(initial, config) : config;
3697
+ if ('function' == typeof config) return await config(initial, ctx) ?? initial;
3698
+ if (Array.isArray(config)) {
3699
+ let result = initial;
3700
+ for (let item of config)result = await reduceConfigsAsyncWithContext({
3701
+ initial: result,
3702
+ config: item,
3739
3703
  ctx,
3740
3704
  mergeFn
3741
- }), initial) : config ?? initial;
3705
+ });
3706
+ return result;
3707
+ }
3708
+ return config ?? initial;
3742
3709
  }
3743
3710
  function reduceConfigsMergeContext({ initial, config, ctx, mergeFn = Object.assign }) {
3744
3711
  return null == config ? initial : dist_isPlainObject(config) ? dist_isPlainObject(initial) ? mergeFn(initial, config) : config : 'function' == typeof config ? config({
@@ -3753,7 +3720,7 @@ function reduceConfigsMergeContext({ initial, config, ctx, mergeFn = Object.assi
3753
3720
  }
3754
3721
  async function modifyBundlerChain(context, utils) {
3755
3722
  context.logger.debug('applying modifyBundlerChain hook');
3756
- let rspackChain = new dist_src(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.callChain({
3723
+ let rspackChain = new RspackChain(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.callChain({
3757
3724
  environment: utils.environment.name,
3758
3725
  args: [
3759
3726
  rspackChain,
@@ -6157,6 +6124,7 @@ init(
6157
6124
  ${JSON.stringify(clientConfig)},
6158
6125
  ${JSON.stringify(resolvedHost)},
6159
6126
  ${resolvedPort},
6127
+ ${JSON.stringify(config.server.base)},
6160
6128
  ${liveReloadEnabled},
6161
6129
  ${!!config.dev.browserLogs},
6162
6130
  ${JSON.stringify(config.dev.client.logLevel)}
@@ -6187,7 +6155,7 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
6187
6155
  let errorsCount = null, warningsCount = null;
6188
6156
  compiler.hooks.invalid.tap('rsbuild-dev-server', (fileName)=>{
6189
6157
  errorsCount = null, warningsCount = null, 'string' == typeof fileName && fileName.endsWith('.html') && normalizeLiveReload(liveReload).html && socketServer.sockWrite({
6190
- type: 'static-changed'
6158
+ type: 'full-reload'
6191
6159
  }, token);
6192
6160
  }), compiler.hooks.done.tap('rsbuild-dev-server', (stats)=>{
6193
6161
  let { errors, warnings } = stats.compilation;
@@ -6627,7 +6595,7 @@ class SocketServer {
6627
6595
  if (!result) return null;
6628
6596
  let { stats, errors, warnings } = result, newInitialChunks = this.getInitialChunks(stats), initialChunks = this.initialChunksMap.get(token), shouldReload = stats.entrypoints && initialChunks && !isEqualSet(initialChunks, newInitialChunks);
6629
6597
  if (this.initialChunksMap.set(token, newInitialChunks), shouldReload) return void this.sockWrite({
6630
- type: 'static-changed'
6598
+ type: 'full-reload'
6631
6599
  }, token);
6632
6600
  if (stats.hash) {
6633
6601
  let prevHash = this.currentHash.get(token);
@@ -6907,7 +6875,7 @@ function formatProxyOptions(proxyOptions, logger) {
6907
6875
  }));
6908
6876
  }
6909
6877
  async function createProxyMiddleware(proxyOptions, logger) {
6910
- let formattedOptions = formatProxyOptions(proxyOptions, logger), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("./http-proxy-middleware.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/index.js", 23));
6878
+ let formattedOptions = formatProxyOptions(proxyOptions, logger), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("./http-proxy-middleware.js");
6911
6879
  for (let opts of formattedOptions){
6912
6880
  let proxyMiddleware = baseMiddleware(opts), middleware = async (req, res, next)=>{
6913
6881
  let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
@@ -7354,10 +7322,6 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
7354
7322
  };
7355
7323
  }, createHttpServer = async ({ serverConfig, middlewares })=>{
7356
7324
  if (serverConfig.https) {
7357
- if (serverConfig.proxy) {
7358
- let { createServer } = await import("node:https");
7359
- return createServer(serverConfig.https, middlewares);
7360
- }
7361
7325
  let { createSecureServer } = await import("node:http2");
7362
7326
  return createSecureServer({
7363
7327
  allowHTTP1: !0,
@@ -7432,7 +7396,7 @@ async function startWatchFiles({ paths, options, type = 'reload-page' }, buildMa
7432
7396
  let watcher = await createChokidar(paths, root, options);
7433
7397
  return watcher.on('change', ()=>{
7434
7398
  buildManager.socketServer.sockWrite({
7435
- type: 'static-changed'
7399
+ type: 'full-reload'
7436
7400
  });
7437
7401
  }), watcher;
7438
7402
  }
@@ -8331,7 +8295,7 @@ try {
8331
8295
  config: config.tools.styleLoader
8332
8296
  });
8333
8297
  mainRule.use(CHAIN_ID.USE.STYLE).loader(join(COMPILED_PATH, 'style-loader', 'index.js')).options(styleLoaderOptions);
8334
- } else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || core_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
8298
+ } else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(core_rspack.CssExtractRspackPlugin.loader).options(config.tools.cssExtract.loaderOptions);
8335
8299
  else mainRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(node_path.join(dirname, 'ignoreCssLoader.mjs'));
8336
8300
  let importLoaders = {
8337
8301
  normal: 0,
@@ -8419,7 +8383,7 @@ try {
8419
8383
  let isStringExport = 'string' === cssLoaderOptions.exportType;
8420
8384
  if (isStringExport && mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && mainRule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
8421
8385
  let extractPluginOptions = config.tools.cssExtract.pluginOptions, cssPath = config.output.distPath.css, cssFilename = getFilename(config, 'css', isProd), isCssFilenameFn = 'function' == typeof cssFilename, cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : 'async');
8422
- chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || core_rspack.CssExtractRspackPlugin, [
8386
+ chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(core_rspack.CssExtractRspackPlugin, [
8423
8387
  {
8424
8388
  filename: isCssFilenameFn ? (...args)=>{
8425
8389
  let name = cssFilename(...args);
@@ -8812,7 +8776,7 @@ try {
8812
8776
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8813
8777
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8814
8778
  if (!1 === manifest) return;
8815
- let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.0_@emnapi+core@1.8.1_@emnapi+runtime_36ca8bbe9cc8ea53288c7dff23b25fc0/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8779
+ let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.1_@emnapi+core@1.9.2_@emnapi+runtime_ae0458ffc4f2907bc50e0834703a6ec7/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8816
8780
  manifestFilenames.set(environment.name, manifestOptions.filename);
8817
8781
  let pluginOptions = {
8818
8782
  fileName: manifestOptions.filename,
@@ -9326,7 +9290,7 @@ let applyServerOptions = (command)=>{
9326
9290
  };
9327
9291
  function setupCommands() {
9328
9292
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9329
- cli.version("2.0.0-rc.0"), 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)', {
9293
+ cli.version("2.0.0-rc.1"), 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)', {
9330
9294
  default: 'auto'
9331
9295
  }).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', {
9332
9296
  type: [
@@ -9403,7 +9367,7 @@ function initNodeEnv() {
9403
9367
  }
9404
9368
  function showGreeting() {
9405
9369
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9406
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-rc.0\n`);
9370
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-rc.1\n`);
9407
9371
  }
9408
9372
  function setupLogLevel() {
9409
9373
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9424,5 +9388,5 @@ function runCLI() {
9424
9388
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9425
9389
  }
9426
9390
  }
9427
- let src_version = "2.0.0-rc.0";
9391
+ let src_version = "2.0.0-rc.1";
9428
9392
  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, runCLI, src_logger as logger, src_version as version };
@@ -25,18 +25,19 @@ const registerOverlay = (createFn, clearFn)=>{
25
25
  createOverlay = createFn;
26
26
  clearOverlay = clearFn;
27
27
  };
28
- function init(token, config, serverHost, serverPort, liveReload, browserLogs, logLevel) {
28
+ function init(token, config, serverHost, serverPort, serverBase, liveReload, browserLogs, logLevel) {
29
29
  logger.level = logLevel;
30
30
  const queuedMessages = [];
31
31
  const clientErrors = [];
32
32
  const customListenersMap = new Map();
33
33
  let lastHash;
34
34
  let hasBuildErrors = false;
35
+ const base = serverBase.endsWith('/') ? serverBase : `${serverBase}/`;
35
36
  function formatURL(fallback) {
36
- const { location } = self;
37
- const hostname = (fallback ? serverHost : config.host) || location.hostname;
38
- const port = (fallback ? serverPort : config.port) || location.port;
39
- const protocol = config.protocol || ('https:' === location.protocol ? 'wss' : 'ws');
37
+ const { location: location1 } = self;
38
+ const hostname = (fallback ? serverHost : config.host) || location1.hostname;
39
+ const port = (fallback ? serverPort : config.port) || location1.port;
40
+ const protocol = config.protocol || ('https:' === location1.protocol ? 'wss' : 'ws');
40
41
  const pathname = config.path;
41
42
  if ("u" > typeof URL) {
42
43
  const url = new URL('http://localhost');
@@ -85,7 +86,7 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
85
86
  const forcedReload = err || !updatedModules;
86
87
  if (forcedReload) {
87
88
  if (err) logger.error('[rsbuild] HMR update failed, performing full reload:', err);
88
- reloadPage();
89
+ fullReload();
89
90
  return;
90
91
  }
91
92
  tryApplyUpdates();
@@ -101,7 +102,7 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
101
102
  });
102
103
  return;
103
104
  }
104
- reloadPage();
105
+ fullReload();
105
106
  }
106
107
  let socket = null;
107
108
  let reconnectCount = 0;
@@ -133,8 +134,11 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
133
134
  case 'ok':
134
135
  handleSuccess();
135
136
  break;
137
+ case 'full-reload':
138
+ fullReload(message.data);
139
+ break;
136
140
  case 'static-changed':
137
- reloadPage();
141
+ fullReload();
138
142
  break;
139
143
  case 'warnings':
140
144
  handleWarnings(message.data);
@@ -223,8 +227,17 @@ function init(token, config, serverHost, serverPort, liveReload, browserLogs, lo
223
227
  socket.removeEventListener('error', onSocketError);
224
228
  }
225
229
  }
226
- function reloadPage() {
227
- if (liveReload) window.location.reload();
230
+ function fullReload(data) {
231
+ if (!liveReload) return;
232
+ const path = null == data ? void 0 : data.path;
233
+ if (null == path ? void 0 : path.endsWith('.html')) {
234
+ const pathname = decodeURI(location.pathname);
235
+ const targetPath = base + path.slice(1);
236
+ const targetPathWithoutExt = targetPath.slice(0, -5);
237
+ if (pathname === targetPath || pathname === targetPathWithoutExt || pathname.endsWith('/') && `${pathname}index.html` === targetPath) location.reload();
238
+ return;
239
+ }
240
+ location.reload();
228
241
  }
229
242
  if (browserLogs && "u" > typeof window) {
230
243
  window.addEventListener('error', ({ message, error })=>{