@rspack/core 0.7.6-canary-1a0d77d-20240627143904 → 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 (87) hide show
  1. package/README.md +2 -2
  2. package/compiled/enhanced-resolve/index.js +11 -11
  3. package/compiled/webpack-sources/index.d.ts +130 -0
  4. package/compiled/webpack-sources/index.js +3520 -0
  5. package/compiled/webpack-sources/license +21 -0
  6. package/compiled/webpack-sources/package.json +1 -0
  7. package/dist/Chunk.d.ts +19 -14
  8. package/dist/Chunk.js +22 -17
  9. package/dist/ChunkGraph.d.ts +1 -1
  10. package/dist/ChunkGraph.js +5 -5
  11. package/dist/ChunkGroup.d.ts +17 -7
  12. package/dist/ChunkGroup.js +12 -2
  13. package/dist/Compilation.d.ts +31 -33
  14. package/dist/Compilation.js +33 -53
  15. package/dist/Compiler.d.ts +26 -28
  16. package/dist/Compiler.js +74 -26
  17. package/dist/ContextModuleFactory.d.ts +1 -1
  18. package/dist/ContextModuleFactory.js +1 -1
  19. package/dist/Entrypoint.d.ts +1 -1
  20. package/dist/Entrypoint.js +2 -2
  21. package/dist/Module.d.ts +12 -7
  22. package/dist/Module.js +1 -0
  23. package/dist/MultiCompiler.d.ts +11 -11
  24. package/dist/MultiCompiler.js +30 -13
  25. package/dist/NormalModule.d.ts +7 -4
  26. package/dist/NormalModule.js +27 -11
  27. package/dist/NormalModuleFactory.d.ts +3 -1
  28. package/dist/NormalModuleFactory.js +3 -23
  29. package/dist/ResolverFactory.d.ts +3 -3
  30. package/dist/ResolverFactory.js +1 -1
  31. package/dist/RspackError.d.ts +8 -0
  32. package/dist/RspackError.js +21 -0
  33. package/dist/Stats.d.ts +4 -2
  34. package/dist/Stats.js +6 -0
  35. package/dist/Template.d.ts +1 -1
  36. package/dist/Template.js +2 -2
  37. package/dist/Watching.d.ts +1 -1
  38. package/dist/builtin-loader/swc/index.d.ts +0 -4
  39. package/dist/builtin-loader/swc/index.js +1 -5
  40. package/dist/builtin-loader/swc/preact.d.ts +3 -4
  41. package/dist/builtin-loader/swc/types.d.ts +2 -17
  42. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -0
  43. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +1 -0
  44. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  46. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -1
  47. package/dist/builtin-plugin/SplitChunksPlugin.js +11 -2
  48. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +0 -28
  49. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +20 -69
  50. package/dist/builtin-plugin/css-extract/index.d.ts +2 -2
  51. package/dist/config/adapter.js +30 -16
  52. package/dist/config/adapterRuleUse.js +0 -11
  53. package/dist/config/defaults.js +22 -30
  54. package/dist/config/normalization.js +13 -5
  55. package/dist/config/zod.d.ts +753 -205
  56. package/dist/config/zod.js +27 -13
  57. package/dist/container/ModuleFederationPlugin.js +1 -1
  58. package/dist/container/default.runtime.js +1 -170
  59. package/dist/exports.d.ts +9 -2
  60. package/dist/exports.js +11 -6
  61. package/dist/lib/Cache.d.ts +3 -3
  62. package/dist/lib/Cache.js +1 -1
  63. package/dist/loader-runner/index.js +37 -12
  64. package/dist/rspack.d.ts +1 -1
  65. package/dist/rspackOptionsApply.js +3 -0
  66. package/dist/stats/DefaultStatsFactoryPlugin.js +35 -11
  67. package/dist/stats/DefaultStatsPrinterPlugin.js +2 -2
  68. package/dist/stats/StatsFactory.d.ts +2 -2
  69. package/dist/stats/StatsFactory.js +12 -12
  70. package/dist/stats/StatsPrinter.d.ts +1 -1
  71. package/dist/stats/StatsPrinter.js +8 -8
  72. package/dist/stats/statsFactoryUtils.d.ts +13 -4
  73. package/dist/util/SplitChunkSize.d.ts +5 -0
  74. package/dist/util/SplitChunkSize.js +18 -0
  75. package/dist/util/index.d.ts +2 -2
  76. package/dist/util/index.js +4 -3
  77. package/dist/util/memoize.js +5 -1
  78. package/dist/util/source.d.ts +1 -1
  79. package/dist/util/source.js +1 -1
  80. package/package.json +14 -9
  81. package/dist/builtin-loader/swc/emotion.d.ts +0 -17
  82. package/dist/builtin-loader/swc/emotion.js +0 -22
  83. package/dist/builtin-loader/swc/relay.d.ts +0 -5
  84. package/dist/builtin-loader/swc/relay.js +0 -48
  85. package/dist/container/default.runtime.d.ts +0 -2
  86. package/dist/lite-tapable/index.d.ts +0 -146
  87. package/dist/lite-tapable/index.js +0 -752
@@ -357,13 +357,13 @@ const SIMPLE_PRINTERS = {
357
357
  // chunkEntry ? formatFlag("entry") : undefined,
358
358
  // "error.chunkInitial": (chunkInitial, { formatFlag }) =>
359
359
  // chunkInitial ? formatFlag("initial") : undefined,
360
- // "error.file": (file, { bold }) => bold(file),
360
+ "error.file": (file, { bold }) => bold(file),
361
361
  "error.moduleName": (moduleName, { bold }) => {
362
362
  return moduleName.includes("!")
363
363
  ? `${bold(moduleName.replace(/^(\s|\S)*!/, ""))} (${moduleName})`
364
364
  : `${bold(moduleName)}`;
365
365
  },
366
- // "error.loc": (loc, { green }) => green(loc),
366
+ "error.loc": (loc, { green }) => green(loc),
367
367
  "error.message": (message, { bold, formatError }) => message.includes("\u001b[") ? message : bold(formatError(message)),
368
368
  // "error.details": (details, { formatError }) => formatError(details),
369
369
  // "error.stack": stack => stack,
@@ -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
  ]))
@@ -3,9 +3,16 @@ import type { Compilation, NormalizedStatsOptions } from "../Compilation";
3
3
  import { type Comparator } from "../util/comparators";
4
4
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
5
5
  export type KnownStatsChunkGroup = binding.JsStatsChunkGroup;
6
- export type KnownStatsChunk = binding.JsStatsChunk;
6
+ export type KnownStatsChunk = Omit<binding.JsStatsChunk, "sizes"> & {
7
+ sizes: Record<string, number>;
8
+ };
9
+ export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related"> & {
10
+ related: Record<string, string[]>;
11
+ };
7
12
  export type StatsChunkGroup = binding.JsStatsChunkGroup & Record<string, any>;
8
- export type KnownStatsAsset = binding.JsStatsAsset;
13
+ export type KnownStatsAsset = Omit<binding.JsStatsAsset, "info"> & {
14
+ info: KnownStatsAssetInfo;
15
+ };
9
16
  export type StatsAsset = KnownStatsAsset & Record<string, any>;
10
17
  export type StatsChunk = KnownStatsChunk & Record<string, any>;
11
18
  export type KnownStatsModule = Omit<binding.JsStatsModule, "usedExports" | "providedExports" | "optimizationBailout" | "sizes"> & {
@@ -14,12 +21,13 @@ export type KnownStatsModule = Omit<binding.JsStatsModule, "usedExports" | "prov
14
21
  providedExports?: null | string[];
15
22
  optimizationBailout?: null | string[];
16
23
  sizes: Record<string, number>;
24
+ index?: number;
25
+ index2?: number;
17
26
  };
18
27
  export type StatsProfile = KnownStatsProfile & Record<string, any>;
19
28
  export type KnownStatsProfile = {
20
29
  total: number;
21
30
  resolving: number;
22
- integration: number;
23
31
  building: number;
24
32
  };
25
33
  export type StatsModule = KnownStatsModule & Record<string, any>;
@@ -85,6 +93,7 @@ type ExtractorsByOption<T, O> = {
85
93
  type PreprocessedAsset = StatsAsset & {
86
94
  type: string;
87
95
  related: PreprocessedAsset[];
96
+ info: binding.JsStatsAssetInfo;
88
97
  };
89
98
  export type SimpleExtractors = {
90
99
  compilation: ExtractorsByOption<Compilation, StatsCompilation>;
@@ -95,7 +104,7 @@ export type SimpleExtractors = {
95
104
  moduleIssuer: ExtractorsByOption<binding.JsStatsModuleIssuer, StatsModuleIssuer>;
96
105
  profile: ExtractorsByOption<binding.JsStatsModuleProfile, StatsProfile>;
97
106
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
98
- chunk: ExtractorsByOption<StatsChunk, KnownStatsChunk>;
107
+ chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
99
108
  };
100
109
  export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];
101
110
  export declare const uniqueOrderedArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>, comparator: Comparator) => I[];
@@ -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;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { JsStatsError } from "@rspack/binding";
2
+ import type { JsRspackError, JsStatsError } from "@rspack/binding";
3
3
  import { LoaderObject } from "../loader-runner";
4
4
  export declare function mapValues(record: Record<string, string>, fn: (key: string) => string): {
5
5
  [k: string]: string;
@@ -10,7 +10,7 @@ export declare const toObject: (input: string | Buffer | object) => object;
10
10
  export declare function serializeObject(map: string | object | undefined | null): Buffer | undefined;
11
11
  export declare function isPromiseLike(value: unknown): value is Promise<any>;
12
12
  export declare function isJsStatsError(err: any): err is JsStatsError;
13
- export declare function concatErrorMsgAndStack(err: Error | JsStatsError | string): string;
13
+ export declare function concatErrorMsgAndStack(err: Error | JsRspackError | string): JsRspackError;
14
14
  export declare function indent(str: string, prefix: string): string;
15
15
  export declare function stringifyLoaderObject(o: LoaderObject): string;
16
16
  export declare function asArray<T>(item: T[]): T[];
@@ -61,12 +61,13 @@ function isJsStatsError(err) {
61
61
  exports.isJsStatsError = isJsStatsError;
62
62
  function concatErrorMsgAndStack(err) {
63
63
  if (typeof err === "string") {
64
- return err;
64
+ return new Error(err);
65
65
  }
66
66
  if ("stack" in err) {
67
- return err.stack || err.message;
67
+ err.message = err.stack || err.message;
68
+ return err;
68
69
  }
69
- return err.message;
70
+ return err;
70
71
  }
71
72
  exports.concatErrorMsgAndStack = concatErrorMsgAndStack;
72
73
  function indent(str, prefix) {
@@ -37,7 +37,11 @@ function memoizeValue(fn) {
37
37
  const getValue = (0, exports.memoize)(fn);
38
38
  return new Proxy({}, {
39
39
  get(_, property) {
40
- return getValue()[property];
40
+ let res = getValue()[property];
41
+ if (typeof res === "function") {
42
+ res = res.bind(getValue());
43
+ }
44
+ return res;
41
45
  },
42
46
  set(_, property, newValue) {
43
47
  getValue()[property] = newValue;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { JsCompatSource } from "@rspack/binding";
3
- import { Source } from "webpack-sources";
3
+ import { Source } from "../../compiled/webpack-sources";
4
4
  declare class JsSource extends Source {
5
5
  static __from_binding(source: JsCompatSource): Source;
6
6
  static __to_binding(source: Source): {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsSource = void 0;
4
- const webpack_sources_1 = require("webpack-sources");
4
+ const webpack_sources_1 = require("../../compiled/webpack-sources");
5
5
  const index_1 = require("./index");
6
6
  class JsSource extends webpack_sources_1.Source {
7
7
  static __from_binding(source) {
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.7.6-canary-1a0d77d-20240627143904",
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",
7
7
  "main": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "publishConfig": {
10
+ "access": "public",
11
+ "provenance": true
12
+ },
9
13
  "exports": {
10
14
  ".": {
11
15
  "default": "./dist/index.js"
@@ -72,17 +76,17 @@
72
76
  "tsc-alias": "^1.8.8",
73
77
  "wast-loader": "^1.11.4",
74
78
  "watchpack": "^2.4.0",
79
+ "webpack-sources": "3.2.3",
75
80
  "zod": "^3.21.4",
76
81
  "zod-validation-error": "1.3.1",
77
- "@rspack/core": "0.7.6-canary-1a0d77d-20240627143904",
78
- "@rspack/plugin-minify": "^0.7.6-canary-1a0d77d-20240627143904"
82
+ "@rspack/core": "1.0.0-alpha.1",
83
+ "@rspack/plugin-minify": "^1.0.0-alpha.1"
79
84
  },
80
85
  "dependencies": {
81
- "@module-federation/runtime-tools": "0.1.6",
86
+ "@module-federation/runtime-tools": "0.2.3",
82
87
  "caniuse-lite": "^1.0.30001616",
83
- "tapable": "2.2.1",
84
- "webpack-sources": "3.2.3",
85
- "@rspack/binding": "0.7.6-canary-1a0d77d-20240627143904"
88
+ "@rspack/binding": "1.0.0-alpha.1",
89
+ "@rspack/lite-tapable": "1.0.0-alpha.1"
86
90
  },
87
91
  "peerDependencies": {
88
92
  "@swc/helpers": ">=0.5.1"
@@ -93,9 +97,10 @@
93
97
  }
94
98
  },
95
99
  "scripts": {
96
- "build": "prebundle && tsc -b ./tsconfig.build.json && tsc-alias -p tsconfig.build.json",
97
- "build:force": "prebundle && tsc -b ./tsconfig.build.json --force && tsc-alias -p tsconfig.build.json",
100
+ "build": "prebundle && tsc -b ./tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run prepare-container-runtime",
101
+ "build:force": "prebundle && tsc -b ./tsconfig.build.json --force && tsc-alias -p tsconfig.build.json && npm run prepare-container-runtime",
98
102
  "dev": "prebundle && tsc -w",
103
+ "prepare-container-runtime": "node ./scripts/prepare-container-runtime.js",
99
104
  "doc-coverage": "node scripts/check-documentation-coverage.mjs",
100
105
  "api-extractor": "api-extractor run --verbose",
101
106
  "api-extractor:ci": "api-extractor run --verbose || diff temp/api.md etc/api.md"
@@ -1,17 +0,0 @@
1
- type EmotionConfigImportMap = {
2
- [packageName: string]: {
3
- [exportName: string]: {
4
- canonicalImport?: [string, string];
5
- };
6
- };
7
- };
8
- type EmotionConfig = {
9
- sourceMap?: boolean;
10
- autoLabel?: "never" | "dev-only" | "always";
11
- labelFormat?: string;
12
- importMap?: EmotionConfigImportMap;
13
- };
14
- type EmotionOptions = boolean | EmotionConfig | undefined;
15
- declare function resolveEmotion(emotion: EmotionOptions, isProduction: boolean): EmotionConfig | undefined;
16
- export { resolveEmotion };
17
- export type { EmotionOptions };
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveEmotion = void 0;
4
- function resolveEmotion(emotion, isProduction) {
5
- if (!emotion) {
6
- return undefined;
7
- }
8
- if (emotion === true) {
9
- emotion = {};
10
- }
11
- const autoLabel = emotion?.autoLabel ?? "dev-only";
12
- const emotionConfig = {
13
- enabled: true,
14
- // @ts-expect-error autoLabel is string for JavaScript interface, however is boolean for Rust interface
15
- autoLabel: autoLabel === "dev-only" ? !isProduction : autoLabel === "always",
16
- importMap: emotion?.importMap,
17
- labelFormat: emotion?.labelFormat ?? "[local]",
18
- sourcemap: isProduction ? false : emotion?.sourceMap ?? true
19
- };
20
- return emotionConfig;
21
- }
22
- exports.resolveEmotion = resolveEmotion;
@@ -1,5 +0,0 @@
1
- import type { RawRelayConfig } from "@rspack/binding";
2
- type RelayOptions = boolean | RawRelayConfig | undefined;
3
- declare function resolveRelay(relay: RelayOptions, rootDir: string): RawRelayConfig | undefined;
4
- export { resolveRelay };
5
- export type { RelayOptions };
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveRelay = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- function getRelayConfigFromProject(rootDir) {
9
- for (const configName of [
10
- "relay.config.json",
11
- "relay.config.js",
12
- "package.json"
13
- ]) {
14
- const configPath = path_1.default.join(rootDir, configName);
15
- try {
16
- let config = require(configPath);
17
- let finalConfig;
18
- if (configName === "package.json") {
19
- finalConfig = config?.relay;
20
- }
21
- else {
22
- finalConfig = config;
23
- }
24
- if (finalConfig) {
25
- return {
26
- language: finalConfig.language,
27
- artifactDirectory: finalConfig.artifactDirectory
28
- };
29
- }
30
- }
31
- catch (_) { }
32
- }
33
- }
34
- function resolveRelay(relay, rootDir) {
35
- if (!relay) {
36
- return undefined;
37
- }
38
- // Search relay config based on
39
- if (relay === true) {
40
- return (getRelayConfigFromProject(rootDir) || {
41
- language: "javascript"
42
- });
43
- }
44
- else {
45
- return relay;
46
- }
47
- }
48
- exports.resolveRelay = resolveRelay;
@@ -1,2 +0,0 @@
1
- declare function _exports(): void;
2
- export = _exports;
@@ -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 {};