@rspack/core 0.5.6 → 0.5.7-canary-3320ea8-20240312032922

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.
@@ -1923,6 +1923,8 @@ declare const generatorOptionsByModuleType: z.ZodUnion<[z.ZodObject<{
1923
1923
  } | undefined;
1924
1924
  }>, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>]>;
1925
1925
  export type GeneratorOptionsByModuleType = z.infer<typeof generatorOptionsByModuleType>;
1926
+ declare const noParseOption: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>]>, "many">]>;
1927
+ export type NoParseOption = z.infer<typeof noParseOption>;
1926
1928
  declare const moduleOptions: z.ZodObject<{
1927
1929
  defaultRules: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"...">, z.ZodType<RuleSetRule, z.ZodTypeDef, RuleSetRule>]>, z.ZodUnion<[z.ZodLiteral<false>, z.ZodLiteral<0>, z.ZodLiteral<"">, z.ZodNull, z.ZodUndefined]>]>, "many">>;
1928
1930
  rules: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"...">, z.ZodType<RuleSetRule, z.ZodTypeDef, RuleSetRule>]>, z.ZodUnion<[z.ZodLiteral<false>, z.ZodLiteral<0>, z.ZodLiteral<"">, z.ZodNull, z.ZodUndefined]>]>, "many">>;
@@ -2085,6 +2087,7 @@ declare const moduleOptions: z.ZodObject<{
2085
2087
  publicPath?: string | undefined;
2086
2088
  } | undefined;
2087
2089
  }>, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>]>>;
2090
+ noParse: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>]>, "many">]>>;
2088
2091
  }, "strict", z.ZodTypeAny, {
2089
2092
  defaultRules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
2090
2093
  rules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
@@ -2121,6 +2124,7 @@ declare const moduleOptions: z.ZodObject<{
2121
2124
  publicPath?: string | undefined;
2122
2125
  } | undefined;
2123
2126
  } | undefined;
2127
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
2124
2128
  }, {
2125
2129
  defaultRules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
2126
2130
  rules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
@@ -2157,6 +2161,7 @@ declare const moduleOptions: z.ZodObject<{
2157
2161
  publicPath?: string | undefined;
2158
2162
  } | undefined;
2159
2163
  } | undefined;
2164
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
2160
2165
  }>;
2161
2166
  export type ModuleOptions = z.infer<typeof moduleOptions>;
2162
2167
  declare const target: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["web", "webworker", "es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "browserslist"]>, z.ZodLiteral<"node">]>, z.ZodLiteral<"async-node">]>, z.ZodType<`node${number}`, z.ZodTypeDef, `node${number}`>]>, z.ZodType<`async-node${number}`, z.ZodTypeDef, `async-node${number}`>]>, z.ZodType<`node${number}.${number}`, z.ZodTypeDef, `node${number}.${number}`>]>, z.ZodType<`async-node${number}.${number}`, z.ZodTypeDef, `async-node${number}.${number}`>]>, z.ZodLiteral<"electron-main">]>, z.ZodType<`electron${number}-main`, z.ZodTypeDef, `electron${number}-main`>]>, z.ZodType<`electron${number}.${number}-main`, z.ZodTypeDef, `electron${number}.${number}-main`>]>, z.ZodLiteral<"electron-renderer">]>, z.ZodType<`electron${number}-renderer`, z.ZodTypeDef, `electron${number}-renderer`>]>, z.ZodType<`electron${number}.${number}-renderer`, z.ZodTypeDef, `electron${number}.${number}-renderer`>]>, z.ZodLiteral<"electron-preload">]>, z.ZodType<`electron${number}-preload`, z.ZodTypeDef, `electron${number}-preload`>]>, z.ZodType<`electron${number}.${number}-preload`, z.ZodTypeDef, `electron${number}.${number}-preload`>]>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["web", "webworker", "es3", "es5", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "es2021", "es2022", "browserslist"]>, z.ZodLiteral<"node">]>, z.ZodLiteral<"async-node">]>, z.ZodType<`node${number}`, z.ZodTypeDef, `node${number}`>]>, z.ZodType<`async-node${number}`, z.ZodTypeDef, `async-node${number}`>]>, z.ZodType<`node${number}.${number}`, z.ZodTypeDef, `node${number}.${number}`>]>, z.ZodType<`async-node${number}.${number}`, z.ZodTypeDef, `async-node${number}.${number}`>]>, z.ZodLiteral<"electron-main">]>, z.ZodType<`electron${number}-main`, z.ZodTypeDef, `electron${number}-main`>]>, z.ZodType<`electron${number}.${number}-main`, z.ZodTypeDef, `electron${number}.${number}-main`>]>, z.ZodLiteral<"electron-renderer">]>, z.ZodType<`electron${number}-renderer`, z.ZodTypeDef, `electron${number}-renderer`>]>, z.ZodType<`electron${number}.${number}-renderer`, z.ZodTypeDef, `electron${number}.${number}-renderer`>]>, z.ZodLiteral<"electron-preload">]>, z.ZodType<`electron${number}-preload`, z.ZodTypeDef, `electron${number}-preload`>]>, z.ZodType<`electron${number}.${number}-preload`, z.ZodTypeDef, `electron${number}.${number}-preload`>]>, "many">]>;
@@ -2417,6 +2422,7 @@ declare const statsOptions: z.ZodObject<{
2417
2422
  children: z.ZodOptional<z.ZodBoolean>;
2418
2423
  usedExports: z.ZodOptional<z.ZodBoolean>;
2419
2424
  providedExports: z.ZodOptional<z.ZodBoolean>;
2425
+ optimizationBailout: z.ZodOptional<z.ZodBoolean>;
2420
2426
  }, "strict", z.ZodTypeAny, {
2421
2427
  all?: boolean | undefined;
2422
2428
  preset?: "none" | "normal" | "verbose" | "errors-only" | "errors-warnings" | undefined;
@@ -2451,6 +2457,7 @@ declare const statsOptions: z.ZodObject<{
2451
2457
  children?: boolean | undefined;
2452
2458
  usedExports?: boolean | undefined;
2453
2459
  providedExports?: boolean | undefined;
2460
+ optimizationBailout?: boolean | undefined;
2454
2461
  }, {
2455
2462
  all?: boolean | undefined;
2456
2463
  preset?: "none" | "normal" | "verbose" | "errors-only" | "errors-warnings" | undefined;
@@ -2485,6 +2492,7 @@ declare const statsOptions: z.ZodObject<{
2485
2492
  children?: boolean | undefined;
2486
2493
  usedExports?: boolean | undefined;
2487
2494
  providedExports?: boolean | undefined;
2495
+ optimizationBailout?: boolean | undefined;
2488
2496
  }>;
2489
2497
  export type StatsOptions = z.infer<typeof statsOptions>;
2490
2498
  declare const statsValue: z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["none", "errors-only", "errors-warnings", "normal", "verbose"]>, z.ZodBoolean]>, z.ZodObject<{
@@ -2521,6 +2529,7 @@ declare const statsValue: z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["none", "errors-onl
2521
2529
  children: z.ZodOptional<z.ZodBoolean>;
2522
2530
  usedExports: z.ZodOptional<z.ZodBoolean>;
2523
2531
  providedExports: z.ZodOptional<z.ZodBoolean>;
2532
+ optimizationBailout: z.ZodOptional<z.ZodBoolean>;
2524
2533
  }, "strict", z.ZodTypeAny, {
2525
2534
  all?: boolean | undefined;
2526
2535
  preset?: "none" | "normal" | "verbose" | "errors-only" | "errors-warnings" | undefined;
@@ -2555,6 +2564,7 @@ declare const statsValue: z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["none", "errors-onl
2555
2564
  children?: boolean | undefined;
2556
2565
  usedExports?: boolean | undefined;
2557
2566
  providedExports?: boolean | undefined;
2567
+ optimizationBailout?: boolean | undefined;
2558
2568
  }, {
2559
2569
  all?: boolean | undefined;
2560
2570
  preset?: "none" | "normal" | "verbose" | "errors-only" | "errors-warnings" | undefined;
@@ -2589,6 +2599,7 @@ declare const statsValue: z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["none", "errors-onl
2589
2599
  children?: boolean | undefined;
2590
2600
  usedExports?: boolean | undefined;
2591
2601
  providedExports?: boolean | undefined;
2602
+ optimizationBailout?: boolean | undefined;
2592
2603
  }>]>;
2593
2604
  export type StatsValue = z.infer<typeof statsValue>;
2594
2605
  export interface RspackPluginInstance {
@@ -3914,6 +3925,7 @@ export declare const rspackOptions: z.ZodObject<{
3914
3925
  children: z.ZodOptional<z.ZodBoolean>;
3915
3926
  usedExports: z.ZodOptional<z.ZodBoolean>;
3916
3927
  providedExports: z.ZodOptional<z.ZodBoolean>;
3928
+ optimizationBailout: z.ZodOptional<z.ZodBoolean>;
3917
3929
  }, "strict", z.ZodTypeAny, {
3918
3930
  all?: boolean | undefined;
3919
3931
  preset?: "none" | "normal" | "verbose" | "errors-only" | "errors-warnings" | undefined;
@@ -3948,6 +3960,7 @@ export declare const rspackOptions: z.ZodObject<{
3948
3960
  children?: boolean | undefined;
3949
3961
  usedExports?: boolean | undefined;
3950
3962
  providedExports?: boolean | undefined;
3963
+ optimizationBailout?: boolean | undefined;
3951
3964
  }, {
3952
3965
  all?: boolean | undefined;
3953
3966
  preset?: "none" | "normal" | "verbose" | "errors-only" | "errors-warnings" | undefined;
@@ -3982,6 +3995,7 @@ export declare const rspackOptions: z.ZodObject<{
3982
3995
  children?: boolean | undefined;
3983
3996
  usedExports?: boolean | undefined;
3984
3997
  providedExports?: boolean | undefined;
3998
+ optimizationBailout?: boolean | undefined;
3985
3999
  }>]>>;
3986
4000
  snapshot: z.ZodOptional<z.ZodObject<{
3987
4001
  module: z.ZodOptional<z.ZodObject<{
@@ -4486,6 +4500,7 @@ export declare const rspackOptions: z.ZodObject<{
4486
4500
  publicPath?: string | undefined;
4487
4501
  } | undefined;
4488
4502
  }>, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>]>>;
4503
+ noParse: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>]>, "many">]>>;
4489
4504
  }, "strict", z.ZodTypeAny, {
4490
4505
  defaultRules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
4491
4506
  rules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
@@ -4522,6 +4537,7 @@ export declare const rspackOptions: z.ZodObject<{
4522
4537
  publicPath?: string | undefined;
4523
4538
  } | undefined;
4524
4539
  } | undefined;
4540
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
4525
4541
  }, {
4526
4542
  defaultRules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
4527
4543
  rules?: (false | "" | 0 | "..." | RuleSetRule | null | undefined)[] | undefined;
@@ -4558,6 +4574,7 @@ export declare const rspackOptions: z.ZodObject<{
4558
4574
  publicPath?: string | undefined;
4559
4575
  } | undefined;
4560
4576
  } | undefined;
4577
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
4561
4578
  }>>;
4562
4579
  profile: z.ZodOptional<z.ZodBoolean>;
4563
4580
  bail: z.ZodOptional<z.ZodBoolean>;
@@ -4772,6 +4789,7 @@ export declare const rspackOptions: z.ZodObject<{
4772
4789
  children?: boolean | undefined;
4773
4790
  usedExports?: boolean | undefined;
4774
4791
  providedExports?: boolean | undefined;
4792
+ optimizationBailout?: boolean | undefined;
4775
4793
  } | undefined;
4776
4794
  snapshot?: {
4777
4795
  module?: {
@@ -4882,6 +4900,7 @@ export declare const rspackOptions: z.ZodObject<{
4882
4900
  publicPath?: string | undefined;
4883
4901
  } | undefined;
4884
4902
  } | undefined;
4903
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
4885
4904
  } | undefined;
4886
4905
  profile?: boolean | undefined;
4887
4906
  bail?: boolean | undefined;
@@ -5096,6 +5115,7 @@ export declare const rspackOptions: z.ZodObject<{
5096
5115
  children?: boolean | undefined;
5097
5116
  usedExports?: boolean | undefined;
5098
5117
  providedExports?: boolean | undefined;
5118
+ optimizationBailout?: boolean | undefined;
5099
5119
  } | undefined;
5100
5120
  snapshot?: {
5101
5121
  module?: {
@@ -5206,6 +5226,7 @@ export declare const rspackOptions: z.ZodObject<{
5206
5226
  publicPath?: string | undefined;
5207
5227
  } | undefined;
5208
5228
  } | undefined;
5229
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
5209
5230
  } | undefined;
5210
5231
  profile?: boolean | undefined;
5211
5232
  bail?: boolean | undefined;
@@ -345,11 +345,17 @@ const generatorOptionsByModuleTypeKnown = zod_1.z.strictObject({
345
345
  });
346
346
  const generatorOptionsByModuleTypeUnknown = zod_1.z.record(zod_1.z.record(zod_1.z.any()));
347
347
  const generatorOptionsByModuleType = generatorOptionsByModuleTypeKnown.or(generatorOptionsByModuleTypeUnknown);
348
+ const noParseOptionSingle = zod_1.z
349
+ .string()
350
+ .or(zod_1.z.instanceof(RegExp))
351
+ .or(zod_1.z.function().args(zod_1.z.string()).returns(zod_1.z.boolean()));
352
+ const noParseOption = noParseOptionSingle.or(zod_1.z.array(noParseOptionSingle));
348
353
  const moduleOptions = zod_1.z.strictObject({
349
354
  defaultRules: ruleSetRules.optional(),
350
355
  rules: ruleSetRules.optional(),
351
356
  parser: parserOptionsByModuleType.optional(),
352
- generator: generatorOptionsByModuleType.optional()
357
+ generator: generatorOptionsByModuleType.optional(),
358
+ noParse: noParseOption.optional()
353
359
  });
354
360
  //#endregion
355
361
  //#region Target
@@ -568,7 +574,8 @@ const statsOptions = zod_1.z.strictObject({
568
574
  runtimeModules: zod_1.z.boolean().optional(),
569
575
  children: zod_1.z.boolean().optional(),
570
576
  usedExports: zod_1.z.boolean().optional(),
571
- providedExports: zod_1.z.boolean().optional()
577
+ providedExports: zod_1.z.boolean().optional(),
578
+ optimizationBailout: zod_1.z.boolean().optional()
572
579
  });
573
580
  const statsValue = zod_1.z
574
581
  .enum(["none", "errors-only", "errors-warnings", "normal", "verbose"])
package/dist/exports.d.ts CHANGED
@@ -233,6 +233,7 @@ export declare const config: {
233
233
  children?: boolean | undefined;
234
234
  usedExports?: boolean | undefined;
235
235
  providedExports?: boolean | undefined;
236
+ optimizationBailout?: boolean | undefined;
236
237
  } | undefined;
237
238
  snapshot?: {
238
239
  module?: {
@@ -343,6 +344,7 @@ export declare const config: {
343
344
  publicPath?: string | undefined;
344
345
  } | undefined;
345
346
  } | undefined;
347
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
346
348
  } | undefined;
347
349
  profile?: boolean | undefined;
348
350
  bail?: boolean | undefined;
@@ -559,6 +561,7 @@ export declare const config: {
559
561
  children?: boolean | undefined;
560
562
  usedExports?: boolean | undefined;
561
563
  providedExports?: boolean | undefined;
564
+ optimizationBailout?: boolean | undefined;
562
565
  } | undefined;
563
566
  snapshot?: {
564
567
  module?: {
@@ -669,6 +672,7 @@ export declare const config: {
669
672
  publicPath?: string | undefined;
670
673
  } | undefined;
671
674
  } | undefined;
675
+ noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
672
676
  } | undefined;
673
677
  profile?: boolean | undefined;
674
678
  bail?: boolean | undefined;
@@ -14,12 +14,15 @@ type Append<T extends any[], U> = {
14
14
  7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
15
15
  8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
16
16
  }[Measure<T["length"]>];
17
- type AsArray<T> = T extends any[] ? T : [T];
17
+ export type AsArray<T> = T extends any[] ? T : [T];
18
+ export type Fn<T, R> = (...args: AsArray<T>) => R;
19
+ export type FnWithCallback<T, R> = (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void;
18
20
  declare class UnsetAdditionalOptions {
19
21
  _UnsetAdditionalOptions: true;
20
22
  }
21
23
  type IfSet<X> = X extends UnsetAdditionalOptions ? {} : X;
22
24
  type Callback<E, T> = (error: E | null, result?: T) => void;
25
+ type InnerCallback<E, T> = (error?: E | null | false, result?: T) => void;
23
26
  type FullTap = Tap & {
24
27
  type: "sync" | "async" | "promise";
25
28
  fn: Function;
@@ -31,7 +34,8 @@ type TapOptions = {
31
34
  before?: string;
32
35
  stage?: number;
33
36
  };
34
- interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
37
+ export type Options<AdditionalOptions = UnsetAdditionalOptions> = string | (Tap & IfSet<AdditionalOptions>);
38
+ export interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
35
39
  name?: string;
36
40
  tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
37
41
  call?: (...args: any[]) => void;
@@ -55,38 +59,44 @@ declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
55
59
  _runTapInterceptors(tap: FullTap & IfSet<AdditionalOptions>): void;
56
60
  _runDoneInterceptors(): void;
57
61
  isUsed(): boolean;
58
- callAsyncStageRange(stageRange: StageRange, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
62
+ queryStageRange(stageRange: StageRange): QueriedHook<T, R, AdditionalOptions>;
63
+ callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
59
64
  callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
60
- promiseStageRange(stageRange: StageRange, ...args: AsArray<T>): Promise<R>;
65
+ promiseStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): Promise<R>;
61
66
  promise(...args: AsArray<T>): Promise<R>;
62
- tap(options: string | (Tap & IfSet<AdditionalOptions>), fn: (...args: AsArray<T>) => R): void;
63
- _tap(type: "sync" | "async" | "promise", options: string | (Tap & IfSet<AdditionalOptions>), fn: (...args: AsArray<T>) => R): void;
67
+ tap(options: Options<AdditionalOptions>, fn: Fn<T, R>): void;
68
+ _tap(type: "sync" | "async" | "promise", options: Options<AdditionalOptions>, fn: Function): void;
64
69
  _insert(item: FullTap & IfSet<AdditionalOptions>): void;
65
70
  }
66
- export declare class StageRange {
67
- #private;
68
- constructor(from: number, to: number);
69
- static from(from: number, to: number): StageRange;
70
- static all(): StageRange;
71
- get from(): number;
72
- get to(): number;
73
- static MAX: number;
74
- static MIN: number;
75
- static trim(n: number): number;
71
+ export type StageRange = readonly [number, number];
72
+ export declare const minStage: number;
73
+ export declare const maxStage: number;
74
+ export declare const safeStage: (stage: number) => number;
75
+ export declare class QueriedHook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
76
+ stageRange: StageRange;
77
+ hook: Hook<T, R, AdditionalOptions>;
78
+ tapsInRange: (FullTap & IfSet<AdditionalOptions>)[];
79
+ constructor(stageRange: StageRange, hook: Hook<T, R, AdditionalOptions>);
80
+ isUsed(): boolean;
81
+ call(...args: AsArray<T>): R;
82
+ callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
83
+ promise(...args: AsArray<T>): Promise<R>;
76
84
  }
77
85
  export declare class SyncHook<T, R = void, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
78
- callAsyncStageRange({ from, to }: StageRange, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
86
+ callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
79
87
  call(...args: AsArray<T>): R;
80
- /**
81
- * call a range of taps, from < stage <= to, (from, to]
82
- */
83
- callStageRange(stageRange: StageRange, ...args: AsArray<T>): R;
88
+ callStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): R;
84
89
  tapAsync(): never;
85
90
  tapPromise(): never;
86
91
  }
87
92
  export declare class AsyncParallelHook<T, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, void, AdditionalOptions> {
88
- callAsyncStageRange({ from, to }: StageRange, ...args: Append<AsArray<T>, Callback<Error, void>>): void;
89
- tapAsync(options: string | (Tap & IfSet<AdditionalOptions>), fn: (...args: AsArray<T>) => void): void;
90
- tapPromise(options: string | (Tap & IfSet<AdditionalOptions>), fn: (...args: AsArray<T>) => void): void;
93
+ callAsyncStageRange(queried: QueriedHook<T, void, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, void>>): void;
94
+ tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
95
+ tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
96
+ }
97
+ export declare class AsyncSeriesHook<T, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, void, AdditionalOptions> {
98
+ callAsyncStageRange(queried: QueriedHook<T, void, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, void>>): void;
99
+ tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
100
+ tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
91
101
  }
92
102
  export {};
@@ -1,18 +1,6 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _StageRange_from, _StageRange_to;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.AsyncParallelHook = exports.SyncHook = exports.StageRange = void 0;
3
+ exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = void 0;
16
4
  class Hook {
17
5
  constructor(args, name) {
18
6
  this.args = args;
@@ -70,16 +58,20 @@ class Hook {
70
58
  isUsed() {
71
59
  return this.taps.length > 0 || this.interceptors.length > 0;
72
60
  }
73
- callAsyncStageRange(stageRange, ...args) {
61
+ queryStageRange(stageRange) {
62
+ return new QueriedHook(stageRange, this);
63
+ }
64
+ callAsyncStageRange(queried, ...args) {
74
65
  throw new Error("Hook should implement there own _callAsyncStageRange");
75
66
  }
76
67
  callAsync(...args) {
77
- return this.callAsyncStageRange(StageRange.all(), ...args);
68
+ return this.callAsyncStageRange(this.queryStageRange(allStageRange), ...args);
78
69
  }
79
- promiseStageRange(stageRange, ...args) {
70
+ promiseStageRange(queried, ...args) {
80
71
  return new Promise((resolve, reject) => {
72
+ this.callAsyncStageRange(queried,
81
73
  // @ts-expect-error
82
- this.callAsyncStageRange(stageRange, ...args, (e, r) => {
74
+ ...args, (e, r) => {
83
75
  if (e)
84
76
  return reject(e);
85
77
  return resolve(r);
@@ -87,7 +79,7 @@ class Hook {
87
79
  });
88
80
  }
89
81
  promise(...args) {
90
- return this.promiseStageRange(StageRange.all(), ...args);
82
+ return this.promiseStageRange(this.queryStageRange(allStageRange), ...args);
91
83
  }
92
84
  tap(options, fn) {
93
85
  this._tap("sync", options, fn);
@@ -144,74 +136,95 @@ class Hook {
144
136
  this.taps[i] = item;
145
137
  }
146
138
  }
147
- class StageRange {
148
- constructor(from, to) {
149
- _StageRange_from.set(this, void 0);
150
- _StageRange_to.set(this, void 0);
151
- __classPrivateFieldSet(this, _StageRange_from, StageRange.trim(from), "f");
152
- __classPrivateFieldSet(this, _StageRange_to, StageRange.trim(to), "f");
153
- }
154
- static from(from, to) {
155
- return new StageRange(from, to);
139
+ exports.minStage = -Infinity;
140
+ exports.maxStage = Infinity;
141
+ const allStageRange = [exports.minStage, exports.maxStage];
142
+ const i32MIN = -(2 ** 31);
143
+ const i32MAX = 2 ** 31 - 1;
144
+ const safeStage = (stage) => {
145
+ if (stage < i32MIN)
146
+ return i32MIN;
147
+ if (stage > i32MAX)
148
+ return i32MAX;
149
+ return stage;
150
+ };
151
+ exports.safeStage = safeStage;
152
+ class QueriedHook {
153
+ constructor(stageRange, hook) {
154
+ var _a;
155
+ const tapsInRange = [];
156
+ const [from, to] = stageRange;
157
+ for (let tap of hook.taps) {
158
+ const stage = (_a = tap.stage) !== null && _a !== void 0 ? _a : 0;
159
+ if (from < stage && stage <= to) {
160
+ tapsInRange.push(tap);
161
+ }
162
+ else if (from === exports.minStage && stage === exports.minStage) {
163
+ tapsInRange.push(tap);
164
+ }
165
+ }
166
+ this.stageRange = stageRange;
167
+ this.hook = hook;
168
+ this.tapsInRange = tapsInRange;
156
169
  }
157
- static all() {
158
- return StageRange.from(StageRange.MIN, StageRange.MAX);
170
+ isUsed() {
171
+ if (this.tapsInRange.length > 0)
172
+ return true;
173
+ if (this.stageRange[0] === exports.minStage &&
174
+ this.hook.interceptors.some(i => i.call))
175
+ return true;
176
+ if (this.stageRange[1] === exports.maxStage &&
177
+ this.hook.interceptors.some(i => i.done))
178
+ return true;
179
+ return false;
159
180
  }
160
- get from() {
161
- return __classPrivateFieldGet(this, _StageRange_from, "f");
181
+ call(...args) {
182
+ if (typeof this.hook.callStageRange !==
183
+ "function") {
184
+ throw new Error("hook is not a SyncHook, call methods only exists on SyncHook");
185
+ }
186
+ return this.hook.callStageRange(this, ...args);
162
187
  }
163
- get to() {
164
- return __classPrivateFieldGet(this, _StageRange_to, "f");
188
+ callAsync(...args) {
189
+ return this.hook.callAsyncStageRange(this, ...args);
165
190
  }
166
- static trim(n) {
167
- if (n > StageRange.MAX)
168
- return StageRange.MAX;
169
- if (n < StageRange.MIN)
170
- return StageRange.MIN;
171
- return n;
191
+ promise(...args) {
192
+ return this.hook.promiseStageRange(this, ...args);
172
193
  }
173
194
  }
174
- _StageRange_from = new WeakMap(), _StageRange_to = new WeakMap();
175
- StageRange.MAX = 2 ** 31 - 1;
176
- StageRange.MIN = -(2 ** 31);
177
- exports.StageRange = StageRange;
195
+ exports.QueriedHook = QueriedHook;
178
196
  class SyncHook extends Hook {
179
- callAsyncStageRange({ from, to }, ...args) {
180
- var _a;
197
+ callAsyncStageRange(queried, ...args) {
198
+ const { stageRange: [from, to], tapsInRange } = queried;
181
199
  const args2 = [...args];
182
200
  const cb = args2.pop();
183
- if (from === StageRange.MIN) {
201
+ if (from === exports.minStage) {
184
202
  this._runCallInterceptors(...args2);
185
203
  }
186
- for (let tap of this.taps) {
187
- const stage = (_a = tap.stage) !== null && _a !== void 0 ? _a : 0;
188
- if (from < stage && stage <= to) {
189
- this._runTapInterceptors(tap);
190
- try {
191
- tap.fn(...args2);
192
- }
193
- catch (e) {
194
- const err = e;
195
- this._runErrorInterceptors(err);
196
- return cb(err);
197
- }
204
+ for (let tap of tapsInRange) {
205
+ this._runTapInterceptors(tap);
206
+ try {
207
+ tap.fn(...args2);
208
+ }
209
+ catch (e) {
210
+ const err = e;
211
+ this._runErrorInterceptors(err);
212
+ return cb(err);
198
213
  }
199
214
  }
200
- if (to === StageRange.MAX) {
215
+ if (to === exports.maxStage) {
201
216
  this._runDoneInterceptors();
202
217
  cb(null);
203
218
  }
204
219
  }
205
220
  call(...args) {
206
- return this.callStageRange(StageRange.all(), ...args);
221
+ return this.callStageRange(this.queryStageRange(allStageRange), ...args);
207
222
  }
208
- /**
209
- * call a range of taps, from < stage <= to, (from, to]
210
- */
211
- callStageRange(stageRange, ...args) {
223
+ callStageRange(queried, ...args) {
212
224
  let result, error;
225
+ this.callAsyncStageRange(queried,
213
226
  // @ts-expect-error
214
- this.callAsyncStageRange(stageRange, ...args, (e, r) => {
227
+ ...args, (e, r) => {
215
228
  error = e;
216
229
  result = r;
217
230
  });
@@ -229,11 +242,11 @@ class SyncHook extends Hook {
229
242
  }
230
243
  exports.SyncHook = SyncHook;
231
244
  class AsyncParallelHook extends Hook {
232
- callAsyncStageRange({ from, to }, ...args) {
233
- var _a;
245
+ callAsyncStageRange(queried, ...args) {
246
+ const { stageRange: [from, to], tapsInRange } = queried;
234
247
  const args2 = [...args];
235
248
  const cb = args2.pop();
236
- if (from === StageRange.MIN) {
249
+ if (from === exports.minStage) {
237
250
  this._runCallInterceptors(...args2);
238
251
  }
239
252
  const done = () => {
@@ -244,13 +257,6 @@ class AsyncParallelHook extends Hook {
244
257
  this._runErrorInterceptors(e);
245
258
  cb(e);
246
259
  };
247
- const tapsInRange = [];
248
- for (let tap of this.taps) {
249
- const stage = (_a = tap.stage) !== null && _a !== void 0 ? _a : 0;
250
- if (from < stage && stage <= to) {
251
- tapsInRange.push(tap);
252
- }
253
- }
254
260
  if (tapsInRange.length === 0)
255
261
  return done();
256
262
  let counter = tapsInRange.length;
@@ -313,3 +319,95 @@ class AsyncParallelHook extends Hook {
313
319
  }
314
320
  }
315
321
  exports.AsyncParallelHook = AsyncParallelHook;
322
+ class AsyncSeriesHook extends Hook {
323
+ callAsyncStageRange(queried, ...args) {
324
+ const { stageRange: [from, to], tapsInRange } = queried;
325
+ const args2 = [...args];
326
+ const cb = args2.pop();
327
+ if (from === exports.minStage) {
328
+ this._runCallInterceptors(...args2);
329
+ }
330
+ const done = () => {
331
+ this._runDoneInterceptors();
332
+ cb(null);
333
+ };
334
+ const error = (e) => {
335
+ this._runErrorInterceptors(e);
336
+ cb(e);
337
+ };
338
+ if (tapsInRange.length === 0)
339
+ return done();
340
+ let index = 0;
341
+ const next = () => {
342
+ const tap = tapsInRange[index];
343
+ this._runTapInterceptors(tap);
344
+ if (tap.type === "promise") {
345
+ const promise = tap.fn(...args2);
346
+ if (!promise || !promise.then) {
347
+ throw new Error("Tap function (tapPromise) did not return promise (returned " +
348
+ promise +
349
+ ")");
350
+ }
351
+ promise.then(() => {
352
+ index += 1;
353
+ if (index === tapsInRange.length) {
354
+ done();
355
+ }
356
+ else {
357
+ next();
358
+ }
359
+ }, (e) => {
360
+ index = tapsInRange.length;
361
+ error(e);
362
+ });
363
+ }
364
+ else if (tap.type === "async") {
365
+ tap.fn(...args2, (e) => {
366
+ if (e) {
367
+ index = tapsInRange.length;
368
+ error(e);
369
+ }
370
+ else {
371
+ index += 1;
372
+ if (index === tapsInRange.length) {
373
+ done();
374
+ }
375
+ else {
376
+ next();
377
+ }
378
+ }
379
+ });
380
+ }
381
+ else {
382
+ let hasError = false;
383
+ try {
384
+ tap.fn(...args2);
385
+ }
386
+ catch (e) {
387
+ hasError = true;
388
+ index = tapsInRange.length;
389
+ error(e);
390
+ }
391
+ if (!hasError) {
392
+ index += 1;
393
+ if (index === tapsInRange.length) {
394
+ done();
395
+ }
396
+ else {
397
+ next();
398
+ }
399
+ }
400
+ }
401
+ if (index === tapsInRange.length)
402
+ return;
403
+ };
404
+ next();
405
+ }
406
+ tapAsync(options, fn) {
407
+ this._tap("async", options, fn);
408
+ }
409
+ tapPromise(options, fn) {
410
+ this._tap("promise", options, fn);
411
+ }
412
+ }
413
+ exports.AsyncSeriesHook = AsyncSeriesHook;
@@ -119,11 +119,13 @@ async function runLoaders(compiler, rawContext) {
119
119
  const resource = rawContext.resource;
120
120
  const loaderContext = {};
121
121
  //
122
- const splittedResource = parsePathQueryFragment(resource);
123
- const resourcePath = splittedResource.path;
124
- const resourceQuery = splittedResource.query;
125
- const resourceFragment = splittedResource.fragment;
126
- const contextDirectory = dirname(resourcePath);
122
+ const splittedResource = resource && parsePathQueryFragment(resource);
123
+ const resourcePath = splittedResource ? splittedResource.path : undefined;
124
+ const resourceQuery = splittedResource ? splittedResource.query : undefined;
125
+ const resourceFragment = splittedResource
126
+ ? splittedResource.fragment
127
+ : undefined;
128
+ const contextDirectory = resourcePath ? dirname(resourcePath) : null;
127
129
  // execution state
128
130
  let cacheable = true;
129
131
  const fileDependencies = rawContext.fileDependencies.slice();