@rsbuild/core 2.2.3 → 2.2.5

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
- 999: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(377)["default"];
4
+ 61: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(23)["default"];
6
6
  },
7
- 377: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 23: (__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__(308);
12
+ var _utils = __nccwpck_require__(690);
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
- 308: (module, exports, __nccwpck_require__) => {
182
+ 690: (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__(999);
719
+ var __webpack_exports__ = __nccwpck_require__(61);
720
720
  module.exports = __webpack_exports__;
721
721
  })();
@@ -1 +1 @@
1
- {"name":"rspack-chain","version":"2.2.0","license":"MIT","types":"types/index.d.ts","type":"module"}
1
+ {"name":"rspack-chain","version":"2.3.2","license":"MIT","types":"types/index.d.ts","type":"module"}
@@ -12,6 +12,20 @@ interface PluginInstance {
12
12
  }
13
13
 
14
14
  declare namespace __Config {
15
+ // Allow loose object patches while preserving arrays and atomic values.
16
+ type MergeValue<Value> = Value extends
17
+ Function | readonly unknown[] | RegExp | Date
18
+ ? Value
19
+ : Value extends object
20
+ ? Value | Record<string, unknown>
21
+ : Value;
22
+
23
+ type MergeInput<OptionsType> = {
24
+ [Key in keyof OptionsType]?: MergeValue<OptionsType[Key]>;
25
+ } & Record<string, any>;
26
+
27
+ type NamedPatches = Record<string, Record<string, unknown>>;
28
+
15
29
  class Chained<Parent> {
16
30
  batch(handler: (chained: this) => void): this;
17
31
  end(): Parent;
@@ -36,7 +50,32 @@ declare namespace __Config {
36
50
  ): this;
37
51
  }
38
52
 
39
- class ChainedMap<Parent> extends TypedChainedMap<Parent, any> {}
53
+ class ChainedMap<
54
+ Parent,
55
+ OptionsType = any,
56
+ MergeOverrides = unknown,
57
+ > extends TypedChainedMap<Parent, any> {
58
+ // Known keys share their read/write types; custom keys remain unrestricted.
59
+ get<Key extends PropertyKey>(
60
+ key: Key,
61
+ ): Key extends keyof OptionsType ? OptionsType[Key] | undefined : any;
62
+ set<Key extends PropertyKey>(
63
+ key: Key,
64
+ value: Key extends keyof OptionsType ? OptionsType[Key] | undefined : any,
65
+ ): this;
66
+ getOrCompute<Key extends PropertyKey>(
67
+ key: Key,
68
+ compute: Key extends keyof OptionsType
69
+ ? () => OptionsType[Key] | undefined
70
+ : () => any,
71
+ ): Key extends keyof OptionsType ? OptionsType[Key] | undefined : any;
72
+ // Apply chain-specific container types without loosening their shape.
73
+ merge(
74
+ obj: MergeInput<Omit<OptionsType, keyof MergeOverrides>> &
75
+ Partial<MergeOverrides>,
76
+ omit?: string[],
77
+ ): this;
78
+ }
40
79
  class TypedChainedSet<Parent, Value> extends Chained<Parent> {
41
80
  add(value: Value): this;
42
81
  prepend(value: Value): this;
@@ -55,8 +94,17 @@ declare namespace __Config {
55
94
  class ChainedSet<Parent> extends TypedChainedSet<Parent, any> {}
56
95
  }
57
96
 
58
- type RspackConfig = Required<Configuration>;
59
- export declare class RspackChain extends __Config.ChainedMap<void> {
97
+ type RspackConfig = Configuration;
98
+ export declare class RspackChain extends __Config.ChainedMap<
99
+ void,
100
+ Configuration,
101
+ {
102
+ entry?: Record<
103
+ string,
104
+ RspackChain.RspackEntryObject | RspackChain.RspackEntryObject[]
105
+ >;
106
+ }
107
+ > {
60
108
  entryPoints: RspackChain.TypedChainedMap<
61
109
  RspackChain,
62
110
  { [key: string]: RspackChain.EntryPoint }
@@ -73,7 +121,7 @@ export declare class RspackChain extends __Config.ChainedMap<void> {
73
121
 
74
122
  context(value: RspackConfig['context']): this;
75
123
  mode(value: RspackConfig['mode']): this;
76
- devtool(value: RspackChain.DevTool): this;
124
+ devtool(value: RspackChain.DevTool | undefined): this;
77
125
  target(value: RspackConfig['target']): this;
78
126
  watch(value: RspackConfig['watch']): this;
79
127
  watchOptions(value: RspackConfig['watchOptions']): this;
@@ -117,7 +165,11 @@ export declare namespace RspackChain {
117
165
  Parent,
118
166
  OptionsType
119
167
  > {}
120
- class ChainedMap<Parent> extends __Config.TypedChainedMap<Parent, any> {}
168
+ class ChainedMap<
169
+ Parent,
170
+ OptionsType = any,
171
+ MergeOverrides = unknown,
172
+ > extends __Config.ChainedMap<Parent, OptionsType, MergeOverrides> {}
121
173
  class TypedChainedSet<Parent, Value> extends __Config.TypedChainedSet<
122
174
  Parent,
123
175
  Value
@@ -168,9 +220,13 @@ export declare namespace RspackChain {
168
220
 
169
221
  class EntryPoint extends TypedChainedSet<RspackChain, RspackEntryObject> {}
170
222
 
171
- type RspackModule = Required<NonNullable<Configuration['module']>>;
223
+ type RspackModule = NonNullable<Configuration['module']>;
172
224
 
173
- class Module extends ChainedMap<RspackChain> {
225
+ class Module extends ChainedMap<
226
+ RspackChain,
227
+ NonNullable<Configuration['module']>,
228
+ { rule?: __Config.NamedPatches; defaultRule?: __Config.NamedPatches }
229
+ > {
174
230
  defaultRules: TypedChainedMap<this, { [key: string]: Rule }>;
175
231
  rules: TypedChainedMap<this, { [key: string]: Rule }>;
176
232
  generator: ChainedMap<this>;
@@ -180,9 +236,12 @@ export declare namespace RspackChain {
180
236
  noParse(value: RspackModule['noParse']): this;
181
237
  }
182
238
 
183
- type RspackOutput = Required<NonNullable<Configuration['output']>>;
239
+ type RspackOutput = NonNullable<Configuration['output']>;
184
240
 
185
- class Output extends ChainedMap<RspackChain> {
241
+ class Output extends ChainedMap<
242
+ RspackChain,
243
+ NonNullable<Configuration['output']>
244
+ > {
186
245
  assetModuleFilename(value: RspackOutput['assetModuleFilename']): this;
187
246
  asyncChunks(value: RspackOutput['asyncChunks']): this;
188
247
  bundlerInfo(value: RspackOutput['bundlerInfo']): this;
@@ -252,16 +311,19 @@ export declare namespace RspackChain {
252
311
  >;
253
312
 
254
313
  type DevServerShorthandMethods<T> = {
255
- [K in keyof RspackDevServer]-?: (value: RspackDevServer[K]) => T;
314
+ [K in keyof RspackDevServer]-?: (
315
+ value: RspackDevServer[K] | undefined,
316
+ ) => T;
256
317
  };
257
318
 
319
+ // rslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
258
320
  class DevServer extends TypedChainedMap<RspackChain, RspackDevServer> {}
259
321
 
260
- // rslint-disable-next-line @typescript-eslint/no-empty-object-type
322
+ // rslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging
261
323
  interface DevServer extends DevServerShorthandMethods<DevServer> {}
262
324
 
263
325
  type RspackPerformance = Exclude<
264
- Required<NonNullable<Configuration['performance']>>,
326
+ NonNullable<Configuration['performance']>,
265
327
  false
266
328
  >;
267
329
  class Performance extends ChainedMap<RspackChain> {
@@ -301,14 +363,16 @@ export declare namespace RspackChain {
301
363
  modules: TypedChainedSet<this, RspackResolve['modules'][number]>;
302
364
  fallback: TypedChainedMap<this, RspackResolveAlias>;
303
365
  byDependency: TypedChainedMap<this, RspackResolve['byDependency']>;
304
- enforceExtension(value: RspackResolve['enforceExtension']): this;
305
- fullySpecified(value: RspackResolve['fullySpecified']): this;
306
- pnp(value: RspackResolve['pnp']): this;
307
- symlinks(value: RspackResolve['symlinks']): this;
308
- preferRelative(value: RspackResolve['preferRelative']): this;
309
- preferAbsolute(value: RspackResolve['preferAbsolute']): this;
310
-
311
- tsConfig(value: RspackResolve['tsConfig']): this;
366
+ enforceExtension(
367
+ value: RspackResolve['enforceExtension'] | undefined,
368
+ ): this;
369
+ fullySpecified(value: RspackResolve['fullySpecified'] | undefined): this;
370
+ pnp(value: RspackResolve['pnp'] | undefined): this;
371
+ symlinks(value: RspackResolve['symlinks'] | undefined): this;
372
+ preferRelative(value: RspackResolve['preferRelative'] | undefined): this;
373
+ preferAbsolute(value: RspackResolve['preferAbsolute'] | undefined): this;
374
+
375
+ tsConfig(value: RspackResolve['tsConfig'] | undefined): this;
312
376
  }
313
377
  class RuleResolve<T = RspackChain> extends Resolve<T> {}
314
378
 
@@ -318,12 +382,23 @@ export declare namespace RspackChain {
318
382
  packageMains: ChainedSet<this>;
319
383
  }
320
384
 
321
- type RspackRuleSet = Required<RuleSetRule>;
322
-
323
- class Rule<T = Module> extends ChainedMap<T> implements Orderable {
385
+ type RspackRuleSet = RuleSetRule;
386
+
387
+ class Rule<T = Module>
388
+ extends ChainedMap<
389
+ T,
390
+ RuleSetRule,
391
+ {
392
+ use?: __Config.NamedPatches;
393
+ rules?: __Config.NamedPatches;
394
+ oneOf?: __Config.NamedPatches;
395
+ }
396
+ >
397
+ implements Orderable
398
+ {
324
399
  uses: TypedChainedMap<this, { [key: string]: Use }>;
325
- include: TypedChainedSet<this, RspackRuleSet['include']>;
326
- exclude: TypedChainedSet<this, RspackRuleSet['exclude']>;
400
+ include: TypedChainedSet<this, NonNullable<RspackRuleSet['include']>>;
401
+ exclude: TypedChainedSet<this, NonNullable<RspackRuleSet['exclude']>>;
327
402
  rules: TypedChainedMap<this, { [key: string]: Rule<Rule> }>;
328
403
  oneOfs: TypedChainedMap<this, { [key: string]: Rule<Rule> }>;
329
404
  resolve: RuleResolve<Rule<T>>;
@@ -348,7 +423,9 @@ export declare namespace RspackChain {
348
423
  test(value: RspackRuleSet['test']): this;
349
424
  type(value: RspackRuleSet['type']): this;
350
425
 
351
- use(name: string): Use<this>;
426
+ use<Options extends LoaderOptions = LoaderOptions>(
427
+ name: string,
428
+ ): Use<this, Options>;
352
429
  rule(name: string): Rule<Rule>;
353
430
  oneOf(name: string): Rule<Rule>;
354
431
  pre(): this;
@@ -357,10 +434,11 @@ export declare namespace RspackChain {
357
434
  after(name: string): this;
358
435
  }
359
436
 
360
- type RspackOptimization = Required<
361
- NonNullable<Configuration['optimization']>
437
+ type RspackOptimization = NonNullable<Configuration['optimization']>;
438
+ type SplitChunksObject = Exclude<
439
+ RspackOptimization['splitChunks'],
440
+ false | undefined
362
441
  >;
363
- type SplitChunksObject = Exclude<RspackOptimization['splitChunks'], false>;
364
442
  class Optimization extends ChainedMap<RspackChain> {
365
443
  minimizer(name: string): RspackChain.Plugin<this, PluginInstance>;
366
444
  minimizers: TypedChainedMap<this, RspackChain.Plugin<this, PluginInstance>>;
@@ -404,13 +482,19 @@ export declare namespace RspackChain {
404
482
  RuleSetLoaderWithOptions['parallel']
405
483
  >;
406
484
 
407
- class Use<Parent = Rule> extends ChainedMap<Parent> implements Orderable {
408
- ident(value: NonNullable<RuleSetLoaderWithOptions['ident']>): this;
409
- loader(value: string): this;
410
- options(value: LoaderOptions): this;
411
- parallel(value: LoaderParallelOptions): this;
485
+ class Use<Parent = Rule, Options extends LoaderOptions = LoaderOptions>
486
+ extends ChainedMap<
487
+ Parent,
488
+ Omit<RuleSetLoaderWithOptions, 'options'> & { options?: Options }
489
+ >
490
+ implements Orderable
491
+ {
492
+ ident(value: RuleSetLoaderWithOptions['ident']): this;
493
+ loader(value: string | undefined): this;
494
+ options(value: Options | undefined): this;
495
+ parallel(value: LoaderParallelOptions | undefined): this;
412
496
 
413
- tap(f: (options: LoaderOptions) => LoaderOptions): this;
497
+ tap(f: (options: Options) => Options): this;
414
498
 
415
499
  // Orderable
416
500
  before(name: string): this;
@@ -418,7 +502,7 @@ export declare namespace RspackChain {
418
502
  }
419
503
 
420
504
  // [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map[-debugids].
421
- export type DevTool = RspackConfig['devtool'];
505
+ export type DevTool = NonNullable<RspackConfig['devtool']>;
422
506
 
423
507
  interface PluginClass<PluginType extends PluginInstance> {
424
508
  new (...opts: any[]): PluginType;