@rspack/core 1.0.0-beta.0 → 1.0.0-beta.2

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 (177) hide show
  1. package/dist/ChunkGroup.d.ts +1 -0
  2. package/dist/ChunkGroup.js +3 -0
  3. package/dist/Compilation.d.ts +19 -1
  4. package/dist/Compiler.d.ts +11 -10
  5. package/dist/Compiler.js +16 -16
  6. package/dist/ExecuteModulePlugin.d.ts +0 -1
  7. package/dist/ExecuteModulePlugin.js +0 -1
  8. package/dist/Module.d.ts +2 -2
  9. package/dist/Module.js +1 -1
  10. package/dist/MultiCompiler.js +1 -1
  11. package/dist/NormalModule.d.ts +1 -0
  12. package/dist/NormalModule.js +1 -0
  13. package/dist/Resolver.d.ts +1 -2
  14. package/dist/RspackError.js +1 -1
  15. package/dist/Stats.js +22 -2
  16. package/dist/Template.js +2 -2
  17. package/dist/builtin-loader/lightningcss/index.js +1 -1
  18. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  21. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/BannerPlugin.d.ts +31 -31
  23. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/DefinePlugin.js +1 -1
  31. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +3 -3
  36. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
  37. package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
  38. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
  39. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
  40. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/EntryPlugin.d.ts +3 -2
  42. package/dist/builtin-plugin/EntryPlugin.js +1 -0
  43. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/ExternalsPlugin.d.ts +5 -5
  46. package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
  47. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +9 -9
  52. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
  56. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  57. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -11
  60. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  70. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  74. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  75. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  79. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +2 -3
  81. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  82. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/base.d.ts +1 -1
  84. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +3 -5
  85. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +7 -5
  86. package/dist/builtin-plugin/css-extract/loader.d.ts +8 -3
  87. package/dist/builtin-plugin/css-extract/loader.js +27 -22
  88. package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
  89. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  90. package/dist/config/adapter.js +16 -2
  91. package/dist/config/adapterRuleUse.d.ts +2 -6
  92. package/dist/config/adapterRuleUse.js +10 -9
  93. package/dist/config/defaults.js +28 -42
  94. package/dist/config/normalization.d.ts +7 -3
  95. package/dist/config/normalization.js +7 -2
  96. package/dist/config/zod.d.ts +1634 -1093
  97. package/dist/config/zod.js +31 -2
  98. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  99. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  100. package/dist/container/default.runtime.js +1 -1
  101. package/dist/exports.d.ts +1 -1
  102. package/dist/lib/AbstractMethodError.d.ts +12 -3
  103. package/dist/lib/AbstractMethodError.js +29 -22
  104. package/dist/lib/Cache.d.ts +40 -46
  105. package/dist/lib/Cache.js +43 -78
  106. package/dist/lib/CacheFacade.d.ts +119 -143
  107. package/dist/lib/CacheFacade.js +123 -124
  108. package/dist/lib/Dependency.d.ts +23 -0
  109. package/dist/lib/Dependency.js +11 -0
  110. package/dist/lib/EntryOptionPlugin.d.ts +19 -2
  111. package/dist/lib/EntryOptionPlugin.js +22 -6
  112. package/dist/lib/EnvironmentPlugin.d.ts +17 -10
  113. package/dist/lib/EnvironmentPlugin.js +16 -17
  114. package/dist/lib/HookWebpackError.d.ts +27 -33
  115. package/dist/lib/HookWebpackError.js +33 -34
  116. package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
  117. package/dist/lib/{ignoreWarningsPlugin.js → IgnoreWarningsPlugin.js} +17 -0
  118. package/dist/lib/LoaderOptionsPlugin.d.ts +18 -9
  119. package/dist/lib/LoaderOptionsPlugin.js +38 -14
  120. package/dist/lib/LoaderTargetPlugin.d.ts +17 -8
  121. package/dist/lib/LoaderTargetPlugin.js +17 -15
  122. package/dist/lib/ModuleFilenameHelpers.d.ts +10 -1
  123. package/dist/lib/ModuleFilenameHelpers.js +10 -1
  124. package/dist/lib/NormalModuleReplacementPlugin.d.ts +15 -5
  125. package/dist/lib/NormalModuleReplacementPlugin.js +15 -5
  126. package/dist/lib/WebpackError.d.ts +23 -22
  127. package/dist/lib/WebpackError.js +15 -35
  128. package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
  129. package/dist/lib/cache/MemoryCachePlugin.js +40 -0
  130. package/dist/lib/cache/getLazyHashedEtag.d.ts +24 -24
  131. package/dist/lib/cache/getLazyHashedEtag.js +20 -23
  132. package/dist/lib/cache/mergeEtags.d.ts +15 -9
  133. package/dist/lib/cache/mergeEtags.js +18 -11
  134. package/dist/lib/formatLocation.d.ts +14 -9
  135. package/dist/lib/formatLocation.js +17 -15
  136. package/dist/loader-runner/index.js +6 -7
  137. package/dist/loader-runner/loadLoader.js +8 -11
  138. package/dist/logging/Logger.js +3 -3
  139. package/dist/logging/createConsoleLogger.d.ts +26 -6
  140. package/dist/logging/createConsoleLogger.js +21 -58
  141. package/dist/logging/runtime.d.ts +4 -10
  142. package/dist/logging/runtime.js +8 -23
  143. package/dist/logging/truncateArgs.d.ts +4 -4
  144. package/dist/logging/truncateArgs.js +5 -10
  145. package/dist/node/NodeEnvironmentPlugin.js +2 -2
  146. package/dist/node/NodeWatchFileSystem.js +6 -6
  147. package/dist/node/nodeConsole.d.ts +7 -21
  148. package/dist/node/nodeConsole.js +29 -36
  149. package/dist/rspackOptionsApply.d.ts +0 -1
  150. package/dist/rspackOptionsApply.js +10 -9
  151. package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
  152. package/dist/sharing/ProvideSharedPlugin.js +26 -17
  153. package/dist/sharing/SharePlugin.d.ts +3 -0
  154. package/dist/sharing/SharePlugin.js +4 -1
  155. package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
  156. package/dist/stats/DefaultStatsPresetPlugin.js +1 -2
  157. package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
  158. package/dist/stats/StatsFactory.d.ts +2 -1
  159. package/dist/stats/StatsFactory.js +2 -6
  160. package/dist/stats/statsFactoryUtils.d.ts +63 -23
  161. package/dist/util/SizeFormatHelpers.js +1 -1
  162. package/dist/util/bindingVersionCheck.js +3 -3
  163. package/dist/util/cleverMerge.js +3 -2
  164. package/dist/util/comparators.d.ts +2 -2
  165. package/dist/util/comparators.js +5 -4
  166. package/dist/util/createHash.js +1 -1
  167. package/dist/util/fs.js +2 -2
  168. package/dist/util/identifier.js +2 -2
  169. package/dist/util/index.js +1 -1
  170. package/dist/util/memoize.js +1 -4
  171. package/dist/util/smartGrouping.js +4 -6
  172. package/dist/util/webpack.d.ts +1 -1
  173. package/dist/util/webpack.js +2 -1
  174. package/module.d.ts +1 -1
  175. package/package.json +3 -3
  176. package/compiled/enhanced-resolve/index.js +0 -5566
  177. package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
@@ -206,7 +206,7 @@ const SIMPLE_PRINTERS = {
206
206
  "module.codeGenerated": (codeGenerated, { formatFlag, yellow }) => codeGenerated ? yellow(formatFlag("code generated")) : undefined,
207
207
  "module.buildTimeExecuted": (buildTimeExecuted, { formatFlag, green }) => buildTimeExecuted ? green(formatFlag("build time executed")) : undefined,
208
208
  "module.cached": (cached, { formatFlag, green }) => cached ? green(formatFlag("cached")) : undefined,
209
- "module.assets": (assets, { formatFlag, magenta }) => assets && assets.length
209
+ "module.assets": (assets, { formatFlag, magenta }) => assets?.length
210
210
  ? magenta(formatFlag(`${assets.length} ${plural(assets.length, "asset", "assets")}`))
211
211
  : undefined,
212
212
  "module.warnings": (warnings, { formatFlag, yellow }) => warnings === true
@@ -700,7 +700,7 @@ const joinInBrackets = (items) => {
700
700
  return res.join("");
701
701
  };
702
702
  const indent = (str, prefix, noPrefixInFirstLine) => {
703
- const rem = str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
703
+ const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
704
704
  if (noPrefixInFirstLine)
705
705
  return rem;
706
706
  const ind = str[0] === "\n" ? "" : prefix;
@@ -722,7 +722,7 @@ const joinExplicitNewLine = (items, indenter) => {
722
722
  first = false;
723
723
  const noJoiner = firstInLine || content.startsWith("\n");
724
724
  firstInLine = content.endsWith("\n");
725
- return noJoiner ? content : " " + content;
725
+ return noJoiner ? content : ` ${content}`;
726
726
  })
727
727
  .filter(Boolean)
728
728
  .join("")
@@ -803,20 +803,19 @@ const SIMPLE_ELEMENT_JOINERS = {
803
803
  },
804
804
  chunk: items => {
805
805
  let hasEntry = false;
806
- return ("chunk " +
807
- joinExplicitNewLine(items.filter(item => {
808
- switch (item.element) {
809
- case "entry":
810
- if (item.content)
811
- hasEntry = true;
812
- break;
813
- case "initial":
814
- if (hasEntry)
815
- return false;
816
- break;
817
- }
818
- return true;
819
- }), " "));
806
+ return `chunk ${joinExplicitNewLine(items.filter(item => {
807
+ switch (item.element) {
808
+ case "entry":
809
+ if (item.content)
810
+ hasEntry = true;
811
+ break;
812
+ case "initial":
813
+ if (hasEntry)
814
+ return false;
815
+ break;
816
+ }
817
+ return true;
818
+ }), " ")}`;
820
819
  },
821
820
  "chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`,
822
821
  chunkGroup: items => joinExplicitNewLine(items, " "),
@@ -856,11 +855,11 @@ const SIMPLE_ELEMENT_JOINERS = {
856
855
  },
857
856
  "module.profile": joinInBrackets,
858
857
  moduleIssuer: joinOneLine,
859
- chunkOrigin: items => "> " + joinOneLine(items),
858
+ chunkOrigin: items => `> ${joinOneLine(items)}`,
860
859
  "errors[].error": joinError(true),
861
860
  "warnings[].error": joinError(false),
862
861
  loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(),
863
- moduleTraceItem: items => " @ " + joinOneLine(items),
862
+ moduleTraceItem: items => ` @ ${joinOneLine(items)}`,
864
863
  moduleTraceDependency: joinOneLine
865
864
  };
866
865
  const AVAILABLE_COLORS = {
@@ -7,7 +7,7 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
- import type { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding";
10
+ import type { JsStats, JsStatsCompilation, JsStatsError, JsStatsWarning } from "@rspack/binding";
11
11
  import { HookMap, SyncBailHook, SyncWaterfallHook } from "@rspack/lite-tapable";
12
12
  import type { Compilation } from "../Compilation";
13
13
  import { type GroupConfig } from "../util/smartGrouping";
@@ -17,6 +17,7 @@ export type KnownStatsFactoryContext = {
17
17
  compilation?: Compilation | undefined;
18
18
  cachedGetErrors?: ((arg0: Compilation) => JsStatsError[]) | undefined;
19
19
  cachedGetWarnings?: ((arg0: Compilation) => JsStatsWarning[]) | undefined;
20
+ getStatsCompilation: (compilation: Compilation) => JsStatsCompilation;
20
21
  getInner: (compilation: Compilation) => JsStats;
21
22
  };
22
23
  export type StatsFactoryContext = KnownStatsFactoryContext & Record<string, any>;
@@ -121,9 +121,7 @@ class StatsFactory {
121
121
  const comparators = [];
122
122
  this._forEachLevel(this.hooks.sort, this._caches.sort, type, h => h.call(comparators, context));
123
123
  if (comparators.length > 0) {
124
- items.sort(
125
- // @ts-expect-error number of arguments is correct
126
- (0, comparators_1.concatComparators)(...comparators));
124
+ items.sort((0, comparators_1.concatComparators)(...comparators));
127
125
  }
128
126
  // run filter on sorted items
129
127
  const items2 = this._forEachLevelFilter(this.hooks.filterSorted, this._caches.filterSorted, type, items, (h, r, idx, i) => h.call(r, context, idx, i), false);
@@ -147,9 +145,7 @@ class StatsFactory {
147
145
  const comparators2 = [];
148
146
  this._forEachLevel(this.hooks.sortResults, this._caches.sortResults, type, h => h.call(comparators2, context));
149
147
  if (comparators2.length > 0) {
150
- resultItems.sort(
151
- // @ts-expect-error number of arguments is correct
152
- (0, comparators_1.concatComparators)(...comparators2));
148
+ resultItems.sort((0, comparators_1.concatComparators)(...comparators2));
153
149
  }
154
150
  // group result items
155
151
  const groupConfigs = [];
@@ -1,27 +1,58 @@
1
+ /// <reference types="node" />
1
2
  import type * as binding from "@rspack/binding";
2
3
  import type { Compilation, NormalizedStatsOptions } from "../Compilation";
3
4
  import { type Comparator } from "../util/comparators";
4
5
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
5
- type Writable<T> = {
6
- -readonly [K in keyof T]: T[K];
7
- };
8
6
  export type KnownStatsChunkGroup = binding.JsStatsChunkGroup;
9
- export type KnownStatsChunk = Omit<Writable<binding.JsStatsChunk>, "sizes"> & {
7
+ export type KnownStatsChunk = Omit<binding.JsStatsChunk, "sizes" | "origins"> & {
10
8
  sizes: Record<string, number>;
9
+ origins: StatsChunkOrigin[];
11
10
  };
12
11
  export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related">;
13
12
  export type StatsChunkGroup = binding.JsStatsChunkGroup & Record<string, any>;
14
13
  export type KnownStatsAsset = Omit<binding.JsStatsAsset, "info">;
15
14
  export type StatsAsset = KnownStatsAsset & Record<string, any>;
16
15
  export type StatsChunk = KnownStatsChunk & Record<string, any>;
17
- export type KnownStatsModule = Omit<Writable<binding.JsStatsModule>, "usedExports" | "providedExports" | "optimizationBailout" | "sizes"> & {
18
- profile?: StatsProfile;
19
- usedExports?: null | string[] | boolean;
20
- providedExports?: null | string[];
21
- optimizationBailout?: null | string[];
22
- sizes: Record<string, number>;
16
+ export type KnownStatsModule = {
17
+ type: string;
18
+ moduleType: string;
19
+ layer?: string;
20
+ identifier?: string;
21
+ name?: string;
22
+ nameForCondition?: string;
23
23
  index?: number;
24
24
  index2?: number;
25
+ preOrderIndex?: number;
26
+ postOrderIndex?: number;
27
+ size: number;
28
+ sizes: Record<string, number>;
29
+ cacheable?: boolean;
30
+ built: boolean;
31
+ codeGenerated: boolean;
32
+ buildTimeExecuted: boolean;
33
+ cached: boolean;
34
+ optional?: boolean;
35
+ orphan?: boolean;
36
+ id?: string;
37
+ issuerId?: string;
38
+ chunks?: string[];
39
+ assets?: string[];
40
+ dependent?: boolean;
41
+ issuer?: string;
42
+ issuerName?: string;
43
+ issuerPath?: StatsModuleIssuer[];
44
+ failed?: boolean;
45
+ errors?: number;
46
+ warnings?: number;
47
+ profile?: StatsProfile;
48
+ reasons?: StatsModuleReason[];
49
+ usedExports?: boolean | string[] | null;
50
+ providedExports?: string[] | null;
51
+ optimizationBailout?: string[] | null;
52
+ depth?: number;
53
+ modules?: StatsModule[];
54
+ filteredModules?: number;
55
+ source?: string | Buffer;
25
56
  };
26
57
  export type StatsProfile = KnownStatsProfile & Record<string, any>;
27
58
  export type KnownStatsProfile = {
@@ -30,9 +61,15 @@ export type KnownStatsProfile = {
30
61
  building: number;
31
62
  };
32
63
  export type StatsModule = KnownStatsModule & Record<string, any>;
33
- export type StatsModuleIssuer = binding.JsStatsModuleIssuer & Record<string, any>;
34
- export type StatsError = binding.JsStatsError & Record<string, any>;
35
- export type StatsWarnings = binding.JsStatsWarning & Record<string, any>;
64
+ export type StatsModuleIssuer = Omit<binding.JsStatsModuleIssuer, "identifier"> & {
65
+ identifier?: string;
66
+ } & Record<string, any>;
67
+ export type StatsError = Omit<binding.JsStatsError, "moduleIdentifier"> & {
68
+ moduleIdentifier?: string;
69
+ } & Record<string, any>;
70
+ export type StatsWarnings = Omit<binding.JsStatsWarning, "moduleIdentifier"> & {
71
+ moduleIdentifier?: string;
72
+ } & Record<string, any>;
36
73
  export type StatsModuleTraceItem = {
37
74
  originIdentifier?: string;
38
75
  originName?: string;
@@ -41,7 +78,18 @@ export type StatsModuleTraceItem = {
41
78
  originId?: string;
42
79
  moduleId?: string;
43
80
  };
44
- export type StatsModuleReason = Writable<binding.JsStatsModuleReason> & Record<string, any>;
81
+ export type StatsModuleReason = Omit<binding.JsStatsModuleReason, "moduleIdentifier"> & {
82
+ moduleIdentifier?: string;
83
+ } & Record<string, any>;
84
+ export type KnownStatsChunkOrigin = {
85
+ module: string;
86
+ moduleIdentifier: string;
87
+ moduleName: string;
88
+ loc: string;
89
+ request: string;
90
+ moduleId?: string;
91
+ };
92
+ export type StatsChunkOrigin = KnownStatsChunkOrigin & Record<string, any>;
45
93
  export type KnownStatsCompilation = {
46
94
  /**
47
95
  * webpack version.
@@ -86,14 +134,6 @@ export type KnownStatsLoggingEntry = {
86
134
  args?: any[] | undefined;
87
135
  time?: number | undefined;
88
136
  };
89
- export type KnownStatsChunkOrigin = {
90
- module?: string | undefined;
91
- moduleIdentifier?: string | undefined;
92
- moduleName?: string | undefined;
93
- loc?: string | undefined;
94
- request?: string | undefined;
95
- moduleId?: (string | number) | undefined;
96
- };
97
137
  type ExtractorsByOption<T, O> = {
98
138
  [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void;
99
139
  };
@@ -117,7 +157,7 @@ export type SimpleExtractors = {
117
157
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
118
158
  chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
119
159
  error: ExtractorsByOption<binding.JsStatsError, StatsError>;
120
- warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>;
160
+ warning: ExtractorsByOption<binding.JsStatsWarning, StatsWarnings>;
121
161
  moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>;
122
162
  };
123
163
  export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];
@@ -19,6 +19,6 @@ const formatSize = (size) => {
19
19
  }
20
20
  const abbreviations = ["bytes", "KiB", "MiB", "GiB"];
21
21
  const index = Math.floor(Math.log(size) / Math.log(1024));
22
- return `${+(size / Math.pow(1024, index)).toPrecision(3)} ${abbreviations[index]}`;
22
+ return `${+(size / 1024 ** index).toPrecision(3)} ${abbreviations[index]}`;
23
23
  };
24
24
  exports.formatSize = formatSize;
@@ -64,12 +64,12 @@ const getAddonPlatformArchAbi = () => {
64
64
  const abi = NodePlatformArchToAbi[platform][arch];
65
65
  if (abi === undefined)
66
66
  return new Error(`unsupported cpu arch: ${arch}`);
67
- binding += "-" + arch;
67
+ binding += `-${arch}`;
68
68
  if (typeof abi === "string") {
69
- binding += abi.length ? "-" + abi : "";
69
+ binding += abi.length ? `-${abi}` : "";
70
70
  }
71
71
  else if (typeof abi === "object") {
72
- binding += "-" + abi[isMusl() ? "musl" : "gnu"];
72
+ binding += `-${abi[isMusl() ? "musl" : "gnu"]}`;
73
73
  }
74
74
  else {
75
75
  return new Error(`unsupported abi: ${abi}`);
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveByProperty = exports.removeOperations = exports.cleverMerge = exports.cachedSetProperty = exports.cachedCleverMerge = exports.DELETE = void 0;
4
+ const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
4
5
  const mergeCache = new WeakMap();
5
6
  const setPropertyCache = new WeakMap();
6
7
  exports.DELETE = Symbol("DELETE");
7
- const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
8
8
  /**
9
9
  * Merges two given objects and caches the result to avoid computation if same objects passed as arguments again.
10
10
  * @example
@@ -299,7 +299,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
299
299
  // second value override everything
300
300
  // = second.base + second.byProperty
301
301
  return secondEntry;
302
- case VALUE_TYPE_UNDEFINED:
302
+ case VALUE_TYPE_UNDEFINED: {
303
303
  if (!firstEntry.byProperty) {
304
304
  // = first.base + second.byProperty
305
305
  return {
@@ -323,6 +323,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
323
323
  byProperty: firstEntry.byProperty,
324
324
  byValues: newByValues
325
325
  };
326
+ }
326
327
  default: {
327
328
  if (!firstEntry.byProperty) {
328
329
  // The simple case
@@ -11,10 +11,10 @@ import type { JsStatsChunk as Chunk } from "@rspack/binding";
11
11
  import type { ChunkGroup } from "../ChunkGroup";
12
12
  export type Comparator = <T>(arg0: T, arg1: T) => -1 | 0 | 1;
13
13
  type Selector<A, B> = (input: A) => B;
14
- export declare const concatComparators: (c1: Comparator, c2: Comparator, ...cRest: Comparator[]) => Comparator;
14
+ export declare const concatComparators: (...comps: Array<Comparator>) => Comparator;
15
15
  export declare const compareIds: (a: string | number, b: string | number) => -1 | 0 | 1;
16
16
  export declare const compareChunksById: (a: Chunk, b: Chunk) => -1 | 0 | 1;
17
17
  export declare const compareChunkGroupsByIndex: (a: ChunkGroup, b: ChunkGroup) => -1 | 0 | 1;
18
18
  export declare const compareSelect: <T, R>(getter: Selector<T, R>, comparator: Comparator) => Comparator;
19
- export declare const compareNumbers: (a: number, b: number) => 0 | 1 | -1;
19
+ export declare const compareNumbers: (a: number, b: number) => 1 | 0 | -1;
20
20
  export {};
@@ -31,14 +31,15 @@ class TwoKeyWeakMap {
31
31
  }
32
32
  }
33
33
  const concatComparatorsCache = new TwoKeyWeakMap();
34
- const concatComparators = (c1, c2, ...cRest) => {
34
+ const concatComparators = (...comps) => {
35
+ const [c1, c2, ...cRest] = comps;
36
+ if (c2 === undefined) {
37
+ return c1;
38
+ }
35
39
  if (cRest.length > 0) {
36
40
  const [c3, ...cRest2] = cRest;
37
41
  return (0, exports.concatComparators)(c1, (0, exports.concatComparators)(c2, c3, ...cRest2));
38
42
  }
39
- if (c2 === undefined) {
40
- return c1;
41
- }
42
43
  const cacheEntry = concatComparatorsCache.get(c1, c2);
43
44
  if (cacheEntry !== undefined)
44
45
  return cacheEntry;
@@ -127,7 +127,7 @@ class DebugHash extends hash_1.default {
127
127
  * @returns digest
128
128
  */
129
129
  digest(encoding) {
130
- return ("debug-digest-" + Buffer.from(this.string).toString(encoding || "hex"));
130
+ return `debug-digest-${Buffer.from(this.string).toString(encoding || "hex")}`;
131
131
  }
132
132
  }
133
133
  /**
package/dist/util/fs.js CHANGED
@@ -56,7 +56,7 @@ function rmrf(fs, p, callback) {
56
56
  }
57
57
  exports.rmrf = rmrf;
58
58
  const join = (fs, rootPath, filename) => {
59
- if (fs && fs.join) {
59
+ if (fs?.join) {
60
60
  return fs.join(rootPath, filename);
61
61
  }
62
62
  if (node_path_1.default.posix.isAbsolute(rootPath)) {
@@ -68,7 +68,7 @@ const join = (fs, rootPath, filename) => {
68
68
  throw new Error(`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`);
69
69
  };
70
70
  const dirname = (fs, absPath) => {
71
- if (fs && fs.dirname) {
71
+ if (fs?.dirname) {
72
72
  return fs.dirname(absPath);
73
73
  }
74
74
  if (node_path_1.default.posix.isAbsolute(absPath)) {
@@ -312,8 +312,8 @@ const getUndoPath = (filename, outputPath, enforceRelative) => {
312
312
  const j = outputPath.lastIndexOf("\\");
313
313
  const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
314
314
  if (pos < 0)
315
- return outputPath + "/";
316
- append = outputPath.slice(pos + 1) + "/" + append;
315
+ return `${outputPath}/`;
316
+ append = `${outputPath.slice(pos + 1)}/${append}`;
317
317
  outputPath = outputPath.slice(0, pos);
318
318
  }
319
319
  }
@@ -73,7 +73,7 @@ function concatErrorMsgAndStack(err) {
73
73
  }
74
74
  exports.concatErrorMsgAndStack = concatErrorMsgAndStack;
75
75
  function indent(str, prefix) {
76
- const rem = str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
76
+ const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
77
77
  return prefix + rem;
78
78
  }
79
79
  exports.indent = indent;
@@ -3,18 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.memoizeValue = exports.memoizeFn = exports.memoize = void 0;
4
4
  const memoize = (fn) => {
5
5
  let cache = false;
6
- // @ts-expect-error
7
- let result = undefined;
6
+ let result;
8
7
  return () => {
9
8
  if (cache) {
10
- // @ts-expect-error
11
9
  return result;
12
10
  }
13
11
  result = fn();
14
12
  cache = true;
15
13
  // Allow to clean up memory for fn
16
14
  // and all dependent resources
17
- // @ts-expect-error
18
15
  fn = undefined;
19
16
  return result;
20
17
  };
@@ -78,13 +78,11 @@ const smartGrouping = (items, groupConfigs) => {
78
78
  if (options === undefined) {
79
79
  const groupConfig = group.config;
80
80
  state.options = options =
81
- (groupConfig.getOptions &&
82
- groupConfig.getOptions(group.name, Array.from(items, ({ item }) => item))) ||
83
- false;
81
+ groupConfig.getOptions?.(group.name, Array.from(items, ({ item }) => item)) || false;
84
82
  }
85
- const force = options && options.force;
83
+ const force = options !== false && options.force;
86
84
  if (!force) {
87
- if (bestGroupOptions && bestGroupOptions.force)
85
+ if (bestGroupOptions !== false && bestGroupOptions?.force)
88
86
  continue;
89
87
  if (used)
90
88
  continue;
@@ -92,7 +90,7 @@ const smartGrouping = (items, groupConfigs) => {
92
90
  continue;
93
91
  }
94
92
  }
95
- const targetGroupCount = (options && options.targetGroupCount) || 4;
93
+ const targetGroupCount = (options !== false && options.targetGroupCount) || 4;
96
94
  const sizeValue = force
97
95
  ? items.size
98
96
  : Math.min(items.size, (totalSize * 2) / targetGroupCount +
@@ -1,4 +1,4 @@
1
1
  declare const _default: {
2
- readonly createHash: any;
2
+ readonly createHash: (algorithm: (string & {}) | "debug" | "xxhash64" | "md4" | "native-md4" | (new () => import("./hash").default)) => import("./hash").default;
3
3
  };
4
4
  export default _default;
@@ -4,9 +4,10 @@
4
4
  // const { NormalModuleReplacementPlugin, WebpackError, util } = compiler.webpack;
5
5
  // ```
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ const createHash_1 = require("./createHash");
7
8
  exports.default = {
8
9
  get createHash() {
9
- return require("./createHash");
10
+ return createHash_1.createHash;
10
11
  }
11
12
  // get comparators() {
12
13
  // return require("./comparators");
package/module.d.ts CHANGED
@@ -109,7 +109,7 @@ declare namespace Rspack {
109
109
  onErrored?: (event: ErroredEvent) => void;
110
110
  }
111
111
 
112
- const enum HotUpdateStatus {
112
+ enum HotUpdateStatus {
113
113
  idle = "idle",
114
114
  check = "check",
115
115
  prepare = "prepare",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.2",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -59,8 +59,8 @@
59
59
  "dependencies": {
60
60
  "@module-federation/runtime-tools": "0.2.3",
61
61
  "caniuse-lite": "^1.0.30001616",
62
- "@rspack/binding": "1.0.0-beta.0",
63
- "@rspack/lite-tapable": "1.0.0-beta.0"
62
+ "@rspack/lite-tapable": "1.0.0-beta.2",
63
+ "@rspack/binding": "1.0.0-beta.2"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@swc/helpers": ">=0.5.1"