@rspack/core 1.0.0-alpha.0 → 1.0.0-alpha.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.
Files changed (40) hide show
  1. package/compiled/enhanced-resolve/index.js +11 -11
  2. package/dist/Compilation.d.ts +12 -10
  3. package/dist/Compilation.js +13 -10
  4. package/dist/Compiler.d.ts +25 -27
  5. package/dist/Compiler.js +42 -24
  6. package/dist/ContextModuleFactory.d.ts +1 -1
  7. package/dist/ContextModuleFactory.js +1 -1
  8. package/dist/MultiCompiler.d.ts +11 -11
  9. package/dist/MultiCompiler.js +30 -13
  10. package/dist/NormalModule.d.ts +7 -3
  11. package/dist/NormalModule.js +27 -4
  12. package/dist/NormalModuleFactory.d.ts +2 -1
  13. package/dist/NormalModuleFactory.js +2 -1
  14. package/dist/ResolverFactory.d.ts +3 -3
  15. package/dist/ResolverFactory.js +1 -1
  16. package/dist/Stats.d.ts +2 -0
  17. package/dist/Stats.js +6 -0
  18. package/dist/Watching.d.ts +1 -1
  19. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  21. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -1
  22. package/dist/builtin-plugin/SplitChunksPlugin.js +11 -2
  23. package/dist/config/adapter.js +7 -6
  24. package/dist/config/zod.d.ts +585 -162
  25. package/dist/config/zod.js +4 -2
  26. package/dist/exports.d.ts +8 -1
  27. package/dist/exports.js +10 -5
  28. package/dist/lib/Cache.d.ts +3 -3
  29. package/dist/lib/Cache.js +1 -1
  30. package/dist/loader-runner/index.js +9 -5
  31. package/dist/rspack.d.ts +1 -1
  32. package/dist/stats/StatsFactory.d.ts +2 -2
  33. package/dist/stats/StatsFactory.js +12 -12
  34. package/dist/stats/StatsPrinter.d.ts +1 -1
  35. package/dist/stats/StatsPrinter.js +8 -8
  36. package/dist/util/SplitChunkSize.d.ts +5 -0
  37. package/dist/util/SplitChunkSize.js +18 -0
  38. package/package.json +6 -6
  39. package/dist/lite-tapable/index.d.ts +0 -146
  40. package/dist/lite-tapable/index.js +0 -752
@@ -113,7 +113,7 @@ const entryDescription = zod_1.z.strictObject({
113
113
  const entryUnnamed = entryItem;
114
114
  const entryObject = zod_1.z.record(entryItem.or(entryDescription));
115
115
  const entryStatic = entryObject.or(entryUnnamed);
116
- const entry = entryStatic.or(zod_1.z.function().returns(entryStatic));
116
+ const entry = entryStatic.or(zod_1.z.function().returns(entryStatic.or(zod_1.z.promise(entryStatic))));
117
117
  //#endregion
118
118
  //#region Output
119
119
  const path = zod_1.z.string();
@@ -333,6 +333,7 @@ const cssModuleParserOptions = zod_1.z.strictObject({
333
333
  const dynamicImportMode = zod_1.z.enum(["eager", "lazy", "weak", "lazy-once"]);
334
334
  const dynamicImportPreload = zod_1.z.union([zod_1.z.boolean(), zod_1.z.number()]);
335
335
  const dynamicImportPrefetch = zod_1.z.union([zod_1.z.boolean(), zod_1.z.number()]);
336
+ const dynamicImportFetchPriority = zod_1.z.enum(["low", "high", "auto"]);
336
337
  const javascriptParserUrl = zod_1.z.union([zod_1.z.literal("relative"), zod_1.z.boolean()]);
337
338
  const exprContextCritical = zod_1.z.boolean();
338
339
  const wrappedContextCritical = zod_1.z.boolean();
@@ -349,6 +350,7 @@ const javascriptParserOptions = zod_1.z.strictObject({
349
350
  dynamicImportMode: dynamicImportMode.optional(),
350
351
  dynamicImportPreload: dynamicImportPreload.optional(),
351
352
  dynamicImportPrefetch: dynamicImportPrefetch.optional(),
353
+ dynamicImportFetchPriority: dynamicImportFetchPriority.optional(),
352
354
  url: javascriptParserUrl.optional(),
353
355
  exprContextCritical: exprContextCritical.optional(),
354
356
  wrappedContextCritical: wrappedContextCritical.optional(),
@@ -748,7 +750,7 @@ const optimizationSplitChunksChunks = zod_1.z
748
750
  .function()
749
751
  .args(zod_1.z.instanceof(Chunk_1.Chunk, { message: "Input not instance of Chunk" }))
750
752
  .returns(zod_1.z.boolean()));
751
- const optimizationSplitChunksSizes = zod_1.z.number();
753
+ const optimizationSplitChunksSizes = zod_1.z.number().or(zod_1.z.record(zod_1.z.number()));
752
754
  const optimizationSplitChunksDefaultSizeTypes = zod_1.z.array(zod_1.z.string());
753
755
  const sharedOptimizationSplitChunksCacheGroup = {
754
756
  chunks: optimizationSplitChunksChunks.optional(),
package/dist/exports.d.ts CHANGED
@@ -39,7 +39,6 @@ export declare const util: {
39
39
  };
40
40
  export { default as EntryOptionPlugin } from "./lib/EntryOptionPlugin";
41
41
  export { type OutputFileSystem } from "./util/fs";
42
- export { cleanupGlobalTrace as experimental_cleanupGlobalTrace, registerGlobalTrace as experimental_registerGlobalTrace } from "@rspack/binding";
43
42
  export type { BannerPluginArgument } from "./builtin-plugin";
44
43
  export type { ProvidePluginOptions } from "./builtin-plugin";
45
44
  export type { DefinePluginOptions } from "./builtin-plugin";
@@ -149,3 +148,11 @@ export { EvalSourceMapDevToolPlugin } from "./builtin-plugin";
149
148
  export { EvalDevToolModulePlugin } from "./builtin-plugin";
150
149
  export { CssExtractRspackPlugin } from "./builtin-plugin";
151
150
  export type { SwcLoaderEnvConfig, SwcLoaderEsParserConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderOptions, SwcLoaderParserConfig, SwcLoaderTransformConfig, SwcLoaderTsParserConfig } from "./builtin-loader/swc/index";
151
+ import { cleanupGlobalTrace, registerGlobalTrace } from "@rspack/binding";
152
+ interface Experiments {
153
+ globalTrace: {
154
+ register: typeof registerGlobalTrace;
155
+ cleanup: typeof cleanupGlobalTrace;
156
+ };
157
+ }
158
+ export declare const experiments: Experiments;
package/dist/exports.js CHANGED
@@ -26,8 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.LightningCssMinimizerRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.web = exports.NormalModuleReplacementPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.EnvironmentPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.DynamicEntryPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.IgnorePlugin = exports.BannerPlugin = exports.experimental_registerGlobalTrace = exports.experimental_cleanupGlobalTrace = exports.EntryOptionPlugin = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.Stats = exports.RuntimeGlobals = exports.NormalModule = exports.MultiStats = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compiler = exports.Compilation = exports.version = exports.rspackVersion = void 0;
30
- exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = void 0;
29
+ exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.LightningCssMinimizerRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.web = exports.NormalModuleReplacementPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.EnvironmentPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.DynamicEntryPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.IgnorePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.Stats = exports.RuntimeGlobals = exports.NormalModule = exports.MultiStats = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compiler = exports.Compilation = exports.version = exports.rspackVersion = void 0;
30
+ exports.experiments = void 0;
31
31
  const { version: rspackVersion, webpackVersion } = require("../package.json");
32
32
  exports.rspackVersion = rspackVersion;
33
33
  exports.version = webpackVersion;
@@ -69,9 +69,6 @@ const createHash_1 = require("./util/createHash");
69
69
  exports.util = { createHash: createHash_1.createHash, cleverMerge: cleverMerge_1.cachedCleverMerge };
70
70
  var EntryOptionPlugin_1 = require("./lib/EntryOptionPlugin");
71
71
  Object.defineProperty(exports, "EntryOptionPlugin", { enumerable: true, get: function () { return __importDefault(EntryOptionPlugin_1).default; } });
72
- var binding_1 = require("@rspack/binding");
73
- Object.defineProperty(exports, "experimental_cleanupGlobalTrace", { enumerable: true, get: function () { return binding_1.cleanupGlobalTrace; } });
74
- Object.defineProperty(exports, "experimental_registerGlobalTrace", { enumerable: true, get: function () { return binding_1.registerGlobalTrace; } });
75
72
  var builtin_plugin_1 = require("./builtin-plugin");
76
73
  Object.defineProperty(exports, "BannerPlugin", { enumerable: true, get: function () { return builtin_plugin_1.BannerPlugin; } });
77
74
  var builtin_plugin_2 = require("./builtin-plugin");
@@ -167,3 +164,11 @@ var builtin_plugin_27 = require("./builtin-plugin");
167
164
  Object.defineProperty(exports, "EvalDevToolModulePlugin", { enumerable: true, get: function () { return builtin_plugin_27.EvalDevToolModulePlugin; } });
168
165
  var builtin_plugin_28 = require("./builtin-plugin");
169
166
  Object.defineProperty(exports, "CssExtractRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_28.CssExtractRspackPlugin; } });
167
+ ///// Experiments Stuff /////
168
+ const binding_1 = require("@rspack/binding");
169
+ exports.experiments = {
170
+ globalTrace: {
171
+ register: binding_1.registerGlobalTrace,
172
+ cleanup: binding_1.cleanupGlobalTrace
173
+ }
174
+ };
@@ -56,13 +56,13 @@ declare class Cache {
56
56
  declare namespace Cache {
57
57
  export { STAGE_MEMORY, STAGE_DEFAULT, STAGE_DISK, STAGE_NETWORK, WebpackError, Etag, CallbackCache, GotHandler };
58
58
  }
59
- import { AsyncSeriesBailHook } from "tapable";
59
+ import { AsyncSeriesBailHook } from "@rspack/lite-tapable";
60
60
  type Etag = {
61
61
  toString: () => string;
62
62
  };
63
63
  type GotHandler = (result: any, callback: (arg0: Error | undefined) => void) => void;
64
- import { AsyncParallelHook } from "tapable";
65
- import { SyncHook } from "tapable";
64
+ import { AsyncParallelHook } from "@rspack/lite-tapable";
65
+ import { SyncHook } from "@rspack/lite-tapable";
66
66
  type CallbackCache<T> = (err?: (WebpackError | null) | undefined, result?: T | undefined) => void;
67
67
  declare var STAGE_MEMORY: number;
68
68
  declare var STAGE_DEFAULT: number;
package/dist/lib/Cache.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Author Tobias Koppers @sokra
4
4
  */
5
5
  "use strict";
6
- const { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } = require("tapable");
6
+ const { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } = require("@rspack/lite-tapable");
7
7
  const { makeWebpackError, makeWebpackErrorCallback } = require("./HookWebpackError.js");
8
8
  /** @typedef {import("./WebpackError")} WebpackError */
9
9
  /**
@@ -214,17 +214,21 @@ const runSyncOrAsync = (0, util_1.promisify)(function runSyncOrAsync(fn, context
214
214
  })();
215
215
  if (isSync) {
216
216
  isDone = true;
217
- // @ts-expect-error
218
- if (result === undefined)
219
- return callback();
217
+ if (result === undefined) {
218
+ // @ts-expect-error
219
+ callback();
220
+ return;
221
+ }
220
222
  if (result &&
221
223
  typeof result === "object" &&
222
224
  typeof result.then === "function") {
223
- return result.then(function (r) {
225
+ result.then(function (r) {
224
226
  callback(null, [r]);
225
227
  }, callback);
228
+ return;
226
229
  }
227
- return callback(null, [result]);
230
+ callback(null, [result]);
231
+ return;
228
232
  }
229
233
  }
230
234
  catch (e) {
package/dist/rspack.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Callback } from "tapable";
1
+ import { Callback } from "@rspack/lite-tapable";
2
2
  import { Compiler } from "./Compiler";
3
3
  import { MultiCompiler, MultiRspackOptions } from "./MultiCompiler";
4
4
  import MultiStats from "./MultiStats";
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding";
11
- import { HookMap, SyncBailHook, SyncWaterfallHook } from "tapable";
11
+ import { HookMap, SyncBailHook, SyncWaterfallHook } from "@rspack/lite-tapable";
12
12
  import type { Compilation } from "../Compilation";
13
13
  import { GroupConfig } from "../util/smartGrouping";
14
14
  export type KnownStatsFactoryContext = {
@@ -34,7 +34,7 @@ type Hooks = Readonly<{
34
34
  ((arg1: any, arg2: any) => number)[],
35
35
  StatsFactoryContext
36
36
  ], undefined>>;
37
- result: HookMap<SyncWaterfallHook<[any[], StatsFactoryContext], undefined>>;
37
+ result: HookMap<SyncWaterfallHook<[any[], StatsFactoryContext]>>;
38
38
  merge: HookMap<SyncBailHook<[any[], StatsFactoryContext], undefined>>;
39
39
  getItemName: HookMap<SyncBailHook<[any, StatsFactoryContext], string | undefined>>;
40
40
  getItemFactory: HookMap<SyncBailHook<[any, StatsFactoryContext], undefined>>;
@@ -1,39 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsFactory = void 0;
4
- const tapable_1 = require("tapable");
4
+ const lite_tapable_1 = require("@rspack/lite-tapable");
5
5
  const comparators_1 = require("../util/comparators");
6
6
  const smartGrouping_1 = require("../util/smartGrouping");
7
7
  class StatsFactory {
8
8
  constructor() {
9
9
  this.hooks = Object.freeze({
10
- extract: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
10
+ extract: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
11
11
  "object",
12
12
  "data",
13
13
  "context"
14
14
  ])),
15
- filter: new tapable_1.HookMap(() => new tapable_1.SyncBailHook(["item", "context", "index", "unfilteredIndex"])),
16
- sort: new tapable_1.HookMap(() => new tapable_1.SyncBailHook(["comparators", "context"])),
17
- filterSorted: new tapable_1.HookMap(() => new tapable_1.SyncBailHook(["item", "context", "index", "unfilteredIndex"])),
18
- groupResults: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
15
+ filter: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook(["item", "context", "index", "unfilteredIndex"])),
16
+ sort: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook(["comparators", "context"])),
17
+ filterSorted: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook(["item", "context", "index", "unfilteredIndex"])),
18
+ groupResults: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
19
19
  "groupConfigs",
20
20
  "context"
21
21
  ])),
22
- sortResults: new tapable_1.HookMap(() => new tapable_1.SyncBailHook(["comparators", "context"])),
23
- filterResults: new tapable_1.HookMap(() => new tapable_1.SyncBailHook(["item", "context", "index", "unfilteredIndex"])),
24
- merge: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
22
+ sortResults: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook(["comparators", "context"])),
23
+ filterResults: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook(["item", "context", "index", "unfilteredIndex"])),
24
+ merge: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
25
25
  "items",
26
26
  "context"
27
27
  ])),
28
- result: new tapable_1.HookMap(() => new tapable_1.SyncWaterfallHook([
28
+ result: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncWaterfallHook([
29
29
  "result",
30
30
  "context"
31
31
  ])),
32
- getItemName: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
32
+ getItemName: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
33
33
  "item",
34
34
  "context"
35
35
  ])),
36
- getItemFactory: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
36
+ getItemFactory: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
37
37
  "item",
38
38
  "context"
39
39
  ]))
@@ -1,4 +1,4 @@
1
- import { HookMap, SyncBailHook, SyncWaterfallHook } from "tapable";
1
+ import { HookMap, SyncBailHook, SyncWaterfallHook } from "@rspack/lite-tapable";
2
2
  import type { StatsAsset, StatsChunk, StatsChunkGroup, StatsCompilation, StatsModule, StatsModuleReason } from "./statsFactoryUtils";
3
3
  type PrintedElement = {
4
4
  element: string;
@@ -1,35 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsPrinter = void 0;
4
- const tapable_1 = require("tapable");
4
+ const lite_tapable_1 = require("@rspack/lite-tapable");
5
5
  class StatsPrinter {
6
6
  constructor() {
7
7
  this.hooks = Object.freeze({
8
- sortElements: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
8
+ sortElements: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
9
9
  "elements",
10
10
  "context"
11
11
  ])),
12
- printElements: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
12
+ printElements: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
13
13
  "printedElements",
14
14
  "context"
15
15
  ])),
16
- sortItems: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
16
+ sortItems: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
17
17
  "items",
18
18
  "context"
19
19
  ])),
20
- getItemName: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
20
+ getItemName: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
21
21
  "item",
22
22
  "context"
23
23
  ])),
24
- printItems: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
24
+ printItems: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
25
25
  "printedItems",
26
26
  "context"
27
27
  ])),
28
- print: new tapable_1.HookMap(() => new tapable_1.SyncBailHook([
28
+ print: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncBailHook([
29
29
  "object",
30
30
  "context"
31
31
  ])),
32
- result: new tapable_1.HookMap(() => new tapable_1.SyncWaterfallHook([
32
+ result: new lite_tapable_1.HookMap(() => new lite_tapable_1.SyncWaterfallHook([
33
33
  "result",
34
34
  "context"
35
35
  ]))
@@ -0,0 +1,5 @@
1
+ import { RawSplitChunkSizes } from "@rspack/binding";
2
+ declare class JsSplitChunkSizes {
3
+ static __to_binding(sizes?: number | Record<string, number>): number | RawSplitChunkSizes | undefined;
4
+ }
5
+ export { JsSplitChunkSizes };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsSplitChunkSizes = void 0;
4
+ class JsSplitChunkSizes {
5
+ static __to_binding(sizes) {
6
+ if (typeof sizes === "number") {
7
+ return sizes;
8
+ }
9
+ else if (sizes && typeof sizes === "object") {
10
+ const chunkSizes = {
11
+ sizes: sizes
12
+ };
13
+ return chunkSizes;
14
+ }
15
+ return sizes;
16
+ }
17
+ }
18
+ exports.JsSplitChunkSizes = JsSplitChunkSizes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -79,14 +79,14 @@
79
79
  "webpack-sources": "3.2.3",
80
80
  "zod": "^3.21.4",
81
81
  "zod-validation-error": "1.3.1",
82
- "@rspack/core": "1.0.0-alpha.0",
83
- "@rspack/plugin-minify": "^1.0.0-alpha.0"
82
+ "@rspack/core": "1.0.0-alpha.1",
83
+ "@rspack/plugin-minify": "^1.0.0-alpha.1"
84
84
  },
85
85
  "dependencies": {
86
- "@module-federation/runtime-tools": "0.1.6",
86
+ "@module-federation/runtime-tools": "0.2.3",
87
87
  "caniuse-lite": "^1.0.30001616",
88
- "tapable": "2.2.1",
89
- "@rspack/binding": "1.0.0-alpha.0"
88
+ "@rspack/binding": "1.0.0-alpha.1",
89
+ "@rspack/lite-tapable": "1.0.0-alpha.1"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@swc/helpers": ">=0.5.1"
@@ -1,146 +0,0 @@
1
- type FixedSizeArray<T extends number, U> = T extends 0 ? void[] : ReadonlyArray<U> & {
2
- 0: U;
3
- length: T;
4
- };
5
- type Measure<T extends number> = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 ? T : never;
6
- type Append<T extends any[], U> = {
7
- 0: [U];
8
- 1: [T[0], U];
9
- 2: [T[0], T[1], U];
10
- 3: [T[0], T[1], T[2], U];
11
- 4: [T[0], T[1], T[2], T[3], U];
12
- 5: [T[0], T[1], T[2], T[3], T[4], U];
13
- 6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
14
- 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
15
- 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
16
- }[Measure<T["length"]>];
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;
20
- declare class UnsetAdditionalOptions {
21
- _UnsetAdditionalOptions: true;
22
- }
23
- type IfSet<X> = X extends UnsetAdditionalOptions ? {} : X;
24
- type Callback<E, T> = (error: E | null, result?: T) => void;
25
- type InnerCallback<E, T> = (error?: E | null | false, result?: T) => void;
26
- type FullTap = Tap & {
27
- type: "sync" | "async" | "promise";
28
- fn: Function;
29
- };
30
- type Tap = TapOptions & {
31
- name: string;
32
- };
33
- type TapOptions = {
34
- before?: string;
35
- stage?: number;
36
- };
37
- export type Options<AdditionalOptions = UnsetAdditionalOptions> = string | (Tap & IfSet<AdditionalOptions>);
38
- export interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
39
- name?: string;
40
- tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
41
- call?: (...args: any[]) => void;
42
- loop?: (...args: any[]) => void;
43
- error?: (err: Error) => void;
44
- result?: (result: R) => void;
45
- done?: () => void;
46
- register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
47
- }
48
- type ArgumentNames<T extends any[]> = FixedSizeArray<T["length"], string>;
49
- export declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
50
- args?: ArgumentNames<AsArray<T>>;
51
- name?: string;
52
- taps: (FullTap & IfSet<AdditionalOptions>)[];
53
- interceptors: HookInterceptor<T, R, AdditionalOptions>[];
54
- constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
55
- intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>): void;
56
- _runRegisterInterceptors(options: FullTap & IfSet<AdditionalOptions>): FullTap & IfSet<AdditionalOptions>;
57
- _runCallInterceptors(...args: any[]): void;
58
- _runErrorInterceptors(e: Error): void;
59
- _runTapInterceptors(tap: FullTap & IfSet<AdditionalOptions>): void;
60
- _runDoneInterceptors(): void;
61
- _runResultInterceptors(r: R): void;
62
- isUsed(): boolean;
63
- queryStageRange(stageRange: StageRange): QueriedHook<T, R, AdditionalOptions>;
64
- callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
65
- callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
66
- promiseStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): Promise<R>;
67
- promise(...args: AsArray<T>): Promise<R>;
68
- tap(options: Options<AdditionalOptions>, fn: Fn<T, R>): void;
69
- _tap(type: "sync" | "async" | "promise", options: Options<AdditionalOptions>, fn: Function): void;
70
- _insert(item: FullTap & IfSet<AdditionalOptions>): void;
71
- }
72
- export type StageRange = readonly [number, number];
73
- export declare const minStage: number;
74
- export declare const maxStage: number;
75
- export declare const safeStage: (stage: number) => number;
76
- export declare class QueriedHook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
77
- stageRange: StageRange;
78
- hook: Hook<T, R, AdditionalOptions>;
79
- tapsInRange: (FullTap & IfSet<AdditionalOptions>)[];
80
- constructor(stageRange: StageRange, hook: Hook<T, R, AdditionalOptions>);
81
- isUsed(): boolean;
82
- call(...args: AsArray<T>): R;
83
- callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
84
- promise(...args: AsArray<T>): Promise<R>;
85
- }
86
- export declare class SyncHook<T, R = void, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
87
- callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
88
- call(...args: AsArray<T>): R;
89
- callStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): R;
90
- tapAsync(): never;
91
- tapPromise(): never;
92
- }
93
- export declare class SyncBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
94
- callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
95
- call(...args: AsArray<T>): R;
96
- callStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): R;
97
- tapAsync(): never;
98
- tapPromise(): never;
99
- }
100
- export declare class AsyncParallelHook<T, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, void, AdditionalOptions> {
101
- callAsyncStageRange(queried: QueriedHook<T, void, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, void>>): void;
102
- tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
103
- tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
104
- }
105
- export declare class AsyncSeriesHook<T, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, void, AdditionalOptions> {
106
- callAsyncStageRange(queried: QueriedHook<T, void, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, void>>): void;
107
- tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
108
- tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
109
- }
110
- export declare class AsyncSeriesBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
111
- callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
112
- tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
113
- tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
114
- }
115
- export declare class AsyncSeriesWaterfallHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
116
- constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
117
- callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
118
- tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
119
- tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
120
- }
121
- export type HookMapKey = any;
122
- export type HookFactory<H> = (key: HookMapKey, hook?: H) => H;
123
- export interface HookMapInterceptor<H> {
124
- factory?: HookFactory<H>;
125
- }
126
- export declare class HookMap<H extends Hook<any, any, any>> {
127
- _map: Map<HookMapKey, H>;
128
- _factory: HookFactory<H>;
129
- name?: string;
130
- _interceptors: HookMapInterceptor<H>[];
131
- constructor(factory: HookFactory<H>, name?: string);
132
- get(key: HookMapKey): H | undefined;
133
- for(key: HookMapKey): H;
134
- intercept(interceptor: HookMapInterceptor<H>): void;
135
- isUsed(): boolean;
136
- queryStageRange(stageRange: StageRange): QueriedHookMap<H>;
137
- }
138
- export declare class QueriedHookMap<H extends Hook<any, any, any>> {
139
- stageRange: StageRange;
140
- hookMap: HookMap<H>;
141
- constructor(stageRange: StageRange, hookMap: HookMap<H>);
142
- get(key: HookMapKey): QueriedHook<any, any, any> | undefined;
143
- for(key: HookMapKey): QueriedHook<any, any, any>;
144
- isUsed(): boolean;
145
- }
146
- export {};