@rspack/core 1.0.0-alpha.5 → 1.0.0-beta.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 (181) hide show
  1. package/compiled/zod/index.d.ts +138 -52
  2. package/compiled/zod/index.js +300 -103
  3. package/compiled/zod/package.json +1 -1
  4. package/compiled/zod-validation-error/index.js +6 -6
  5. package/dist/Compilation.d.ts +22 -4
  6. package/dist/Compilation.js +64 -49
  7. package/dist/Compiler.d.ts +11 -10
  8. package/dist/Compiler.js +42 -42
  9. package/dist/ErrorHelpers.js +2 -4
  10. package/dist/Module.d.ts +1 -0
  11. package/dist/Module.js +3 -6
  12. package/dist/ModuleTypeConstants.d.ts +45 -69
  13. package/dist/ModuleTypeConstants.js +24 -77
  14. package/dist/NormalModule.d.ts +1 -0
  15. package/dist/NormalModule.js +1 -0
  16. package/dist/Stats.js +4 -6
  17. package/dist/Template.d.ts +31 -147
  18. package/dist/Template.js +40 -236
  19. package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
  20. package/dist/builtin-loader/lightningcss/index.js +175 -0
  21. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/BannerPlugin.d.ts +25 -49
  26. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/DefinePlugin.js +9 -13
  34. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/EntryPlugin.d.ts +4 -3
  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 +29 -5
  46. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +9 -9
  51. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  55. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
  59. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  70. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  74. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  75. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/SplitChunksPlugin.js +5 -15
  79. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  81. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
  82. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  84. package/dist/builtin-plugin/base.d.ts +1 -1
  85. package/dist/builtin-plugin/base.js +1 -3
  86. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
  87. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
  88. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
  89. package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
  90. package/dist/builtin-plugin/css-extract/loader.d.ts +8 -3
  91. package/dist/builtin-plugin/css-extract/loader.js +28 -17
  92. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  93. package/dist/config/adapter.d.ts +1 -1
  94. package/dist/config/adapter.js +39 -25
  95. package/dist/config/adapterRuleUse.d.ts +5 -5
  96. package/dist/config/adapterRuleUse.js +23 -1
  97. package/dist/config/browserslistTargetHandler.d.ts +17 -15
  98. package/dist/config/browserslistTargetHandler.js +27 -33
  99. package/dist/config/defaults.js +27 -31
  100. package/dist/config/normalization.d.ts +8 -3
  101. package/dist/config/normalization.js +7 -5
  102. package/dist/config/target.d.ts +48 -109
  103. package/dist/config/target.js +50 -86
  104. package/dist/config/zod.d.ts +2660 -2305
  105. package/dist/config/zod.js +38 -19
  106. package/dist/container/ContainerPlugin.d.ts +7 -7
  107. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  108. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  109. package/dist/container/options.js +1 -1
  110. package/dist/exports.d.ts +4 -4
  111. package/dist/exports.js +2 -2
  112. package/dist/lib/AbstractMethodError.d.ts +12 -3
  113. package/dist/lib/AbstractMethodError.js +29 -21
  114. package/dist/lib/Cache.d.ts +40 -46
  115. package/dist/lib/Cache.js +43 -78
  116. package/dist/lib/CacheFacade.d.ts +119 -143
  117. package/dist/lib/CacheFacade.js +123 -123
  118. package/dist/lib/EntryOptionPlugin.d.ts +19 -2
  119. package/dist/lib/EntryOptionPlugin.js +22 -6
  120. package/dist/lib/EnvironmentPlugin.d.ts +17 -10
  121. package/dist/lib/EnvironmentPlugin.js +16 -15
  122. package/dist/lib/HookWebpackError.d.ts +27 -33
  123. package/dist/lib/HookWebpackError.js +33 -34
  124. package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
  125. package/dist/lib/{ignoreWarningsPlugin.js → IgnoreWarningsPlugin.js} +17 -0
  126. package/dist/lib/LoaderOptionsPlugin.d.ts +18 -9
  127. package/dist/lib/LoaderOptionsPlugin.js +38 -14
  128. package/dist/lib/LoaderTargetPlugin.d.ts +17 -8
  129. package/dist/lib/LoaderTargetPlugin.js +17 -15
  130. package/dist/lib/ModuleFilenameHelpers.d.ts +10 -1
  131. package/dist/lib/ModuleFilenameHelpers.js +10 -3
  132. package/dist/lib/NormalModuleReplacementPlugin.d.ts +15 -5
  133. package/dist/lib/NormalModuleReplacementPlugin.js +15 -5
  134. package/dist/lib/WebpackError.d.ts +29 -22
  135. package/dist/lib/WebpackError.js +17 -29
  136. package/dist/lib/cache/getLazyHashedEtag.d.ts +24 -24
  137. package/dist/lib/cache/getLazyHashedEtag.js +20 -23
  138. package/dist/lib/cache/mergeEtags.d.ts +15 -9
  139. package/dist/lib/cache/mergeEtags.js +23 -22
  140. package/dist/lib/formatLocation.d.ts +13 -8
  141. package/dist/lib/formatLocation.js +20 -20
  142. package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
  143. package/dist/loader-runner/LoaderLoadingError.js +3 -5
  144. package/dist/loader-runner/index.js +7 -9
  145. package/dist/loader-runner/loadLoader.d.ts +11 -2
  146. package/dist/loader-runner/loadLoader.js +17 -19
  147. package/dist/logging/createConsoleLogger.js +2 -6
  148. package/dist/logging/truncateArgs.js +5 -9
  149. package/dist/node/nodeConsole.js +1 -3
  150. package/dist/rspackOptionsApply.js +2 -2
  151. package/dist/stats/DefaultStatsFactoryPlugin.js +18 -8
  152. package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
  153. package/dist/stats/DefaultStatsPrinterPlugin.js +11 -16
  154. package/dist/stats/StatsFactory.js +13 -17
  155. package/dist/stats/StatsPrinter.js +7 -9
  156. package/dist/util/AssetInfo.js +11 -7
  157. package/dist/util/SplitChunkSize.js +1 -1
  158. package/dist/util/cleverMerge.d.ts +33 -57
  159. package/dist/util/cleverMerge.js +89 -145
  160. package/dist/util/comparators.d.ts +1 -1
  161. package/dist/util/comparators.js +3 -5
  162. package/dist/util/createHash.d.ts +4 -3
  163. package/dist/util/createHash.js +31 -45
  164. package/dist/util/fs.js +9 -13
  165. package/dist/util/hash/BatchedHash.d.ts +24 -9
  166. package/dist/util/hash/BatchedHash.js +16 -13
  167. package/dist/util/hash/index.d.ts +9 -9
  168. package/dist/util/hash/index.js +14 -11
  169. package/dist/util/hash/md4.d.ts +29 -2
  170. package/dist/util/hash/md4.js +7 -3
  171. package/dist/util/hash/wasm-hash.d.ts +52 -5
  172. package/dist/util/hash/wasm-hash.js +19 -22
  173. package/dist/util/hash/xxhash64.d.ts +29 -2
  174. package/dist/util/hash/xxhash64.js +7 -3
  175. package/dist/util/identifier.js +9 -15
  176. package/dist/util/index.js +1 -1
  177. package/dist/util/memoize.js +7 -9
  178. package/package.json +9 -8
  179. package/compiled/enhanced-resolve/index.js +0 -5566
  180. package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
  181. package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
@@ -4,6 +4,11 @@ exports.rspackOptions = exports.externalsType = void 0;
4
4
  const zod_1 = require("../../compiled/zod");
5
5
  const Chunk_1 = require("../Chunk");
6
6
  const Module_1 = require("../Module");
7
+ const filenameTemplate = zod_1.z.string();
8
+ const filename = filenameTemplate.or(zod_1.z
9
+ .function()
10
+ .args(zod_1.z.custom(), zod_1.z.custom().optional())
11
+ .returns(zod_1.z.string()));
7
12
  //#region Name
8
13
  const name = zod_1.z.string();
9
14
  //#endregion
@@ -26,8 +31,7 @@ const falsy = zod_1.z.union([
26
31
  ]);
27
32
  //#endregion
28
33
  //#region Entry
29
- const rawPublicPath = zod_1.z.string();
30
- const publicPath = zod_1.z.literal("auto").or(rawPublicPath);
34
+ const publicPath = zod_1.z.literal("auto").or(filename);
31
35
  const baseUri = zod_1.z.string();
32
36
  const chunkLoadingType = zod_1.z
33
37
  .enum(["jsonp", "import-scripts", "require", "async-node", "import"])
@@ -89,12 +93,8 @@ const libraryOptions = zod_1.z.strictObject({
89
93
  umdNamedDefine: umdNamedDefine.optional()
90
94
  });
91
95
  const library = libraryName.or(libraryOptions).optional();
92
- const filenameTemplate = zod_1.z.string();
93
- const filename = filenameTemplate.or(zod_1.z
94
- .function()
95
- .args(zod_1.z.custom(), zod_1.z.custom().optional())
96
- .returns(zod_1.z.string()));
97
- const entryFilename = filenameTemplate;
96
+ const layer = zod_1.z.string().or(zod_1.z.null());
97
+ const entryFilename = filename;
98
98
  const entryRuntime = zod_1.z.literal(false).or(zod_1.z.string());
99
99
  const entryItem = zod_1.z.string().or(zod_1.z.array(zod_1.z.string()));
100
100
  const entryDependOn = zod_1.z.string().or(zod_1.z.array(zod_1.z.string()));
@@ -108,7 +108,8 @@ const entryDescription = zod_1.z.strictObject({
108
108
  wasmLoading: wasmLoading.optional(),
109
109
  filename: entryFilename.optional(),
110
110
  library: libraryOptions.optional(),
111
- dependOn: entryDependOn.optional()
111
+ dependOn: entryDependOn.optional(),
112
+ layer: layer.optional()
112
113
  });
113
114
  const entryUnnamed = entryItem;
114
115
  const entryObject = zod_1.z.record(entryItem.or(entryDescription));
@@ -139,6 +140,7 @@ const strictModuleErrorHandling = zod_1.z.boolean();
139
140
  const globalObject = zod_1.z.string();
140
141
  const enabledWasmLoadingTypes = zod_1.z.array(wasmLoadingType);
141
142
  const importFunctionName = zod_1.z.string();
143
+ const importMetaName = zod_1.z.string();
142
144
  const iife = zod_1.z.boolean();
143
145
  const enabledChunkLoadingTypes = zod_1.z.array(chunkLoadingType);
144
146
  const chunkFormat = zod_1.z.literal(false).or(zod_1.z.string());
@@ -200,6 +202,7 @@ const output = zod_1.z.strictObject({
200
202
  strictModuleErrorHandling: strictModuleErrorHandling.optional(),
201
203
  globalObject: globalObject.optional(),
202
204
  importFunctionName: importFunctionName.optional(),
205
+ importMetaName: importMetaName.optional(),
203
206
  iife: iife.optional(),
204
207
  wasmLoading: wasmLoading.optional(),
205
208
  enabledWasmLoadingTypes: enabledWasmLoadingTypes.optional(),
@@ -221,6 +224,8 @@ const output = zod_1.z.strictObject({
221
224
  devtoolNamespace: devtoolNamespace.optional(),
222
225
  devtoolModuleFilenameTemplate: devtoolModuleFilenameTemplate.optional(),
223
226
  devtoolFallbackModuleFilenameTemplate: devtoolFallbackModuleFilenameTemplate.optional(),
227
+ chunkLoadTimeout: zod_1.z.number().optional(),
228
+ charset: zod_1.z.boolean().optional(),
224
229
  environment: environment.optional()
225
230
  });
226
231
  //#endregion
@@ -290,6 +295,7 @@ const baseRuleSetRule = zod_1.z.strictObject({
290
295
  exclude: ruleSetCondition.optional(),
291
296
  include: ruleSetCondition.optional(),
292
297
  issuer: ruleSetCondition.optional(),
298
+ issuerLayer: ruleSetCondition.optional(),
293
299
  dependency: ruleSetCondition.optional(),
294
300
  resource: ruleSetCondition.optional(),
295
301
  resourceFragment: ruleSetCondition.optional(),
@@ -297,7 +303,9 @@ const baseRuleSetRule = zod_1.z.strictObject({
297
303
  scheme: ruleSetCondition.optional(),
298
304
  mimetype: ruleSetCondition.optional(),
299
305
  descriptionData: zod_1.z.record(ruleSetCondition).optional(),
306
+ with: zod_1.z.record(ruleSetCondition).optional(),
300
307
  type: zod_1.z.string().optional(),
308
+ layer: zod_1.z.string().optional(),
301
309
  loader: ruleSetLoader.optional(),
302
310
  options: ruleSetLoaderOptions.optional(),
303
311
  use: ruleSetUse.optional(),
@@ -351,6 +359,7 @@ const javascriptParserOptions = zod_1.z.strictObject({
351
359
  dynamicImportPreload: dynamicImportPreload.optional(),
352
360
  dynamicImportPrefetch: dynamicImportPrefetch.optional(),
353
361
  dynamicImportFetchPriority: dynamicImportFetchPriority.optional(),
362
+ importMeta: zod_1.z.boolean().optional(),
354
363
  url: javascriptParserUrl.optional(),
355
364
  exprContextCritical: exprContextCritical.optional(),
356
365
  wrappedContextCritical: wrappedContextCritical.optional(),
@@ -390,7 +399,7 @@ const assetInlineGeneratorOptions = zod_1.z.strictObject({
390
399
  });
391
400
  const assetResourceGeneratorOptions = zod_1.z.strictObject({
392
401
  emit: zod_1.z.boolean().optional(),
393
- filename: filenameTemplate.optional(),
402
+ filename: filename.optional(),
394
403
  publicPath: publicPath.optional()
395
404
  });
396
405
  const assetGeneratorOptions = assetInlineGeneratorOptions.merge(assetResourceGeneratorOptions);
@@ -519,7 +528,12 @@ const externalItemObjectUnknown = zod_1.z.record(externalItemValue);
519
528
  const externalItemFunctionData = zod_1.z.strictObject({
520
529
  context: zod_1.z.string().optional(),
521
530
  dependencyType: zod_1.z.string().optional(),
522
- request: zod_1.z.string().optional()
531
+ request: zod_1.z.string().optional(),
532
+ contextInfo: zod_1.z
533
+ .strictObject({
534
+ issuer: zod_1.z.string()
535
+ })
536
+ .optional()
523
537
  });
524
538
  const externalItem = zod_1.z
525
539
  .string()
@@ -617,12 +631,19 @@ const snapshotOptions = zod_1.z.strictObject({});
617
631
  const cacheOptions = zod_1.z.boolean();
618
632
  //#endregion
619
633
  //#region Stats
634
+ const statsPresets = zod_1.z.enum([
635
+ "normal",
636
+ "none",
637
+ "verbose",
638
+ "errors-only",
639
+ "errors-warnings",
640
+ "minimal",
641
+ "detailed",
642
+ "summary"
643
+ ]);
620
644
  const statsOptions = zod_1.z.strictObject({
621
645
  all: zod_1.z.boolean().optional(),
622
- preset: zod_1.z
623
- .boolean()
624
- .or(zod_1.z.enum(["normal", "none", "verbose", "errors-only", "errors-warnings"]))
625
- .optional(),
646
+ preset: zod_1.z.boolean().or(statsPresets).optional(),
626
647
  assets: zod_1.z.boolean().optional(),
627
648
  chunks: zod_1.z.boolean().optional(),
628
649
  modules: zod_1.z.boolean().optional(),
@@ -713,10 +734,7 @@ const statsOptions = zod_1.z.strictObject({
713
734
  errorStack: zod_1.z.boolean().optional(),
714
735
  moduleTrace: zod_1.z.boolean().optional()
715
736
  });
716
- const statsValue = zod_1.z
717
- .enum(["none", "errors-only", "errors-warnings", "normal", "verbose"])
718
- .or(zod_1.z.boolean())
719
- .or(statsOptions);
737
+ const statsValue = zod_1.z.boolean().or(statsPresets).or(statsOptions);
720
738
  const plugin = zod_1.z.union([
721
739
  zod_1.z.custom(),
722
740
  zod_1.z.custom(),
@@ -847,6 +865,7 @@ const experiments = zod_1.z.strictObject({
847
865
  outputModule: zod_1.z.boolean().optional(),
848
866
  topLevelAwait: zod_1.z.boolean().optional(),
849
867
  css: zod_1.z.boolean().optional(),
868
+ layers: zod_1.z.boolean().optional(),
850
869
  futureDefaults: zod_1.z.boolean().optional(),
851
870
  rspackFuture: rspackFutureOptions.optional()
852
871
  });
@@ -28,19 +28,19 @@ export declare class ContainerPlugin extends RspackBuiltinPlugin {
28
28
  shareScope: string;
29
29
  library: {
30
30
  type: string;
31
+ name?: string | string[] | {
32
+ commonjs?: string | undefined;
33
+ amd?: string | undefined;
34
+ root?: string | string[] | undefined;
35
+ } | undefined;
31
36
  amdContainer?: string | undefined;
32
37
  auxiliaryComment?: string | {
33
- amd?: string | undefined;
34
38
  commonjs?: string | undefined;
35
- commonjs2?: string | undefined;
39
+ amd?: string | undefined;
36
40
  root?: string | undefined;
41
+ commonjs2?: string | undefined;
37
42
  } | undefined;
38
43
  export?: string | string[] | undefined;
39
- name?: string | string[] | {
40
- amd?: string | undefined;
41
- commonjs?: string | undefined;
42
- root?: string | string[] | undefined;
43
- } | undefined;
44
44
  umdNamedDefine?: boolean | undefined;
45
45
  };
46
46
  runtime: string | false | undefined;
@@ -21,7 +21,7 @@ export type RemotesConfig = {
21
21
  export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
22
22
  name: BuiltinPluginName;
23
23
  _options: {
24
- remoteType: "promise" | "module" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "global" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "system" | "script" | "node-commonjs";
24
+ remoteType: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "script" | "node-commonjs";
25
25
  remotes: [string, {
26
26
  external: string[];
27
27
  shareScope: string;
@@ -3,7 +3,7 @@ export declare const ModuleFederationRuntimePlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
5
  _args: [];
6
- affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
6
+ affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
7
  raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
@@ -28,7 +28,7 @@ const process = (options, normalizeSimple, normalizeOptions, fn) => {
28
28
  if (!options) {
29
29
  return;
30
30
  }
31
- else if (Array.isArray(options)) {
31
+ if (Array.isArray(options)) {
32
32
  array(options);
33
33
  }
34
34
  else if (typeof options === "object") {
package/dist/exports.d.ts CHANGED
@@ -18,8 +18,7 @@ export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule,
18
18
  export { Stats } from "./Stats";
19
19
  import * as ModuleFilenameHelpers from "./lib/ModuleFilenameHelpers";
20
20
  export { ModuleFilenameHelpers };
21
- import Template = require("./Template");
22
- export { Template };
21
+ export { Template } from "./Template";
23
22
  export declare const WebpackError: ErrorConstructor;
24
23
  export type { Watching } from "./Watching";
25
24
  import sources = require("../compiled/webpack-sources");
@@ -34,8 +33,8 @@ type Config = {
34
33
  export declare const config: Config;
35
34
  export type * from "./config";
36
35
  export declare const util: {
37
- createHash: (algorithm: any) => any;
38
- cleverMerge: <T, O>(first: T, second: O) => T | O | (T & O);
36
+ createHash: (algorithm: (string & {}) | "debug" | "xxhash64" | "md4" | "native-md4" | (new () => import("./util/hash").default)) => import("./util/hash").default;
37
+ cleverMerge: <First, Second>(first: First, second: Second) => First | Second | (First & Second);
39
38
  };
40
39
  export { default as EntryOptionPlugin } from "./lib/EntryOptionPlugin";
41
40
  export { type OutputFileSystem } from "./util/fs";
@@ -148,6 +147,7 @@ export { EvalSourceMapDevToolPlugin } from "./builtin-plugin";
148
147
  export { EvalDevToolModulePlugin } from "./builtin-plugin";
149
148
  export { CssExtractRspackPlugin } from "./builtin-plugin";
150
149
  export type { SwcLoaderEnvConfig, SwcLoaderEsParserConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderOptions, SwcLoaderParserConfig, SwcLoaderTransformConfig, SwcLoaderTsParserConfig } from "./builtin-loader/swc/index";
150
+ export { type LoaderOptions as LightningcssLoaderOptions, type FeatureOptions as LightningcssFeatureOptions } from "./builtin-loader/lightningcss/index";
151
151
  import { cleanupGlobalTrace, registerGlobalTrace } from "@rspack/binding";
152
152
  interface Experiments {
153
153
  globalTrace: {
package/dist/exports.js CHANGED
@@ -52,8 +52,8 @@ Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { r
52
52
  const ModuleFilenameHelpers = __importStar(require("./lib/ModuleFilenameHelpers"));
53
53
  exports.ModuleFilenameHelpers = ModuleFilenameHelpers;
54
54
  // API extractor not working with some re-exports, see: https://github.com/microsoft/fluentui/issues/20694
55
- const Template = require("./Template");
56
- exports.Template = Template;
55
+ var Template_1 = require("./Template");
56
+ Object.defineProperty(exports, "Template", { enumerable: true, get: function () { return Template_1.Template; } });
57
57
  exports.WebpackError = Error;
58
58
  const sources = require("../compiled/webpack-sources");
59
59
  exports.sources = sources;
@@ -1,4 +1,13 @@
1
- export = AbstractMethodError;
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/AbstractMethodError.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ import WebpackError from "./WebpackError";
2
11
  /**
3
12
  * Error for abstract method
4
13
  * @example
@@ -9,7 +18,7 @@ export = AbstractMethodError;
9
18
  * }
10
19
  *
11
20
  */
12
- declare class AbstractMethodError extends WebpackError {
21
+ export declare class AbstractMethodError extends WebpackError {
13
22
  constructor();
14
23
  }
15
- import WebpackError = require("./WebpackError");
24
+ export default AbstractMethodError;
@@ -1,29 +1,36 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Ivan Kopeykin @vankop
4
- */
5
1
  "use strict";
6
- const WebpackError = require("./WebpackError");
2
+ /**
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/AbstractMethodError.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AbstractMethodError = void 0;
16
+ const WebpackError_1 = __importDefault(require("./WebpackError"));
7
17
  const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/;
8
18
  /**
9
- * @param {string=} method method name
10
- * @returns {string} message
19
+ * @param method method name
20
+ * @returns message
11
21
  */
12
22
  function createMessage(method) {
13
23
  return `Abstract method${method ? " " + method : ""}. Must be overridden.`;
14
24
  }
15
- /**
16
- * @constructor
17
- */
18
- function Message() {
19
- /** @type {string} */
20
- // @ts-expect-error
21
- this.stack = undefined;
22
- Error.captureStackTrace(this);
23
- /** @type {RegExpMatchArray} */
24
- // @ts-expect-error
25
- const match = this.stack.split("\n")[3].match(CURRENT_METHOD_REGEXP);
26
- this.message = match && match[1] ? createMessage(match[1]) : createMessage();
25
+ class Message extends Error {
26
+ constructor() {
27
+ super();
28
+ this.stack = undefined;
29
+ Error.captureStackTrace(this);
30
+ const match = this.stack.split("\n")[3].match(CURRENT_METHOD_REGEXP);
31
+ this.message =
32
+ match && match[1] ? createMessage(match[1]) : createMessage();
33
+ }
27
34
  }
28
35
  /**
29
36
  * Error for abstract method
@@ -35,10 +42,11 @@ function Message() {
35
42
  * }
36
43
  *
37
44
  */
38
- class AbstractMethodError extends WebpackError {
45
+ class AbstractMethodError extends WebpackError_1.default {
39
46
  constructor() {
40
47
  super(new Message().message);
41
48
  this.name = "AbstractMethodError";
42
49
  }
43
50
  }
44
- module.exports = AbstractMethodError;
51
+ exports.AbstractMethodError = AbstractMethodError;
52
+ exports.default = AbstractMethodError;
@@ -1,71 +1,65 @@
1
- export = Cache;
2
- declare class Cache {
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/Cache.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ import { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } from "@rspack/lite-tapable";
11
+ import type { WebpackError } from "./WebpackError";
12
+ export interface Etag {
13
+ toString(): string;
14
+ }
15
+ export type CallbackCache<T> = (err?: WebpackError | null, result?: T) => void;
16
+ type GotHandler<T = any> = (result: any | null, callback: (error: Error) => void) => void;
17
+ export declare class Cache {
18
+ static STAGE_DISK: number;
19
+ static STAGE_MEMORY: number;
20
+ static STAGE_DEFAULT: number;
21
+ static STAGE_NETWORK: number;
3
22
  hooks: {
4
- /** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>} */
5
23
  get: AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>;
6
- /** @type {AsyncParallelHook<[string, Etag | null, any]>} */
7
24
  store: AsyncParallelHook<[string, Etag | null, any]>;
8
- /** @type {AsyncParallelHook<[Iterable<string>]>} */
9
25
  storeBuildDependencies: AsyncParallelHook<[Iterable<string>]>;
10
- /** @type {SyncHook<[]>} */
11
26
  beginIdle: SyncHook<[]>;
12
- /** @type {AsyncParallelHook<[]>} */
13
27
  endIdle: AsyncParallelHook<[]>;
14
- /** @type {AsyncParallelHook<[]>} */
15
28
  shutdown: AsyncParallelHook<[]>;
16
29
  };
30
+ constructor();
17
31
  /**
18
- * @template T
19
- * @param {string} identifier the cache identifier
20
- * @param {Etag | null} etag the etag
21
- * @param {CallbackCache<T>} callback signals when the value is retrieved
22
- * @returns {void}
32
+ * @param identifier the cache identifier
33
+ * @param etag the etag
34
+ * @param callback signals when the value is retrieved
35
+ * @returns
23
36
  */
24
37
  get<T>(identifier: string, etag: Etag | null, callback: CallbackCache<T>): void;
25
38
  /**
26
- * @template T
27
- * @param {string} identifier the cache identifier
28
- * @param {Etag | null} etag the etag
29
- * @param {T} data the value to store
30
- * @param {CallbackCache<void>} callback signals when the value is stored
31
- * @returns {void}
39
+ * @param identifier the cache identifier
40
+ * @param etag the etag
41
+ * @param data the value to store
42
+ * @param callback signals when the value is stored
43
+ * @returns
32
44
  */
33
- store<T_1>(identifier: string, etag: Etag | null, data: T_1, callback: CallbackCache<void>): void;
45
+ store<T>(identifier: string, etag: Etag | null, data: T, callback: CallbackCache<void>): void;
34
46
  /**
35
47
  * After this method has succeeded the cache can only be restored when build dependencies are
36
- * @param {Iterable<string>} dependencies list of all build dependencies
37
- * @param {CallbackCache<void>} callback signals when the dependencies are stored
38
- * @returns {void}
48
+ * @param dependencies list of all build dependencies
49
+ * @param callback signals when the dependencies are stored
50
+ * @returns
39
51
  */
40
52
  storeBuildDependencies(dependencies: Iterable<string>, callback: CallbackCache<void>): void;
41
- /**
42
- * @returns {void}
43
- */
44
53
  beginIdle(): void;
45
54
  /**
46
- * @param {CallbackCache<void>} callback signals when the call finishes
47
- * @returns {void}
55
+ * @param callback signals when the call finishes
56
+ * @returns
48
57
  */
49
58
  endIdle(callback: CallbackCache<void>): void;
50
59
  /**
51
- * @param {CallbackCache<void>} callback signals when the call finishes
52
- * @returns {void}
60
+ * @param callback signals when the call finishes
61
+ * @returns
53
62
  */
54
63
  shutdown(callback: CallbackCache<void>): void;
55
64
  }
56
- declare namespace Cache {
57
- export { STAGE_MEMORY, STAGE_DEFAULT, STAGE_DISK, STAGE_NETWORK, WebpackError, Etag, CallbackCache, GotHandler };
58
- }
59
- import { AsyncSeriesBailHook } from "@rspack/lite-tapable";
60
- type Etag = {
61
- toString: () => string;
62
- };
63
- type GotHandler = (result: any, callback: (arg0: Error | undefined) => void) => void;
64
- import { AsyncParallelHook } from "@rspack/lite-tapable";
65
- import { SyncHook } from "@rspack/lite-tapable";
66
- type CallbackCache<T> = (err?: (WebpackError | null) | undefined, result?: T | undefined) => void;
67
- declare var STAGE_MEMORY: number;
68
- declare var STAGE_DEFAULT: number;
69
- declare var STAGE_DISK: number;
70
- declare var STAGE_NETWORK: number;
71
- type WebpackError = import("./WebpackError");
65
+ export default Cache;
package/dist/lib/Cache.js CHANGED
@@ -1,72 +1,50 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
1
  "use strict";
6
- const { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } = require("@rspack/lite-tapable");
7
- const { makeWebpackError, makeWebpackErrorCallback } = require("./HookWebpackError.js");
8
- /** @typedef {import("./WebpackError")} WebpackError */
9
2
  /**
10
- * @typedef {Object} Etag
11
- * @property {function(): string} toString
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/Cache.js
5
+ *
6
+ * MIT Licensed
7
+ * Author Tobias Koppers @sokra
8
+ * Copyright (c) JS Foundation and other contributors
9
+ * https://github.com/webpack/webpack/blob/main/LICENSE
12
10
  */
13
- /**
14
- * @template T
15
- * @callback CallbackCache
16
- * @param {(WebpackError | null)=} err
17
- * @param {T=} result
18
- * @returns {void}
19
- */
20
- /**
21
- * @callback GotHandler
22
- * @param {any} result
23
- * @param {function(Error=): void} callback
24
- * @returns {void}
25
- */
26
- // @ts-expect-error
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Cache = void 0;
13
+ const lite_tapable_1 = require("@rspack/lite-tapable");
14
+ const HookWebpackError_1 = require("./HookWebpackError");
27
15
  const needCalls = (times, callback) => {
28
- // @ts-expect-error
29
16
  return err => {
30
17
  if (--times === 0) {
31
- return callback(err);
18
+ return callback();
32
19
  }
33
20
  if (err && times > 0) {
34
21
  times = 0;
35
- return callback(err);
22
+ return callback();
36
23
  }
37
24
  };
38
25
  };
39
26
  class Cache {
40
27
  constructor() {
41
28
  this.hooks = {
42
- /** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>} */
43
- get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
44
- /** @type {AsyncParallelHook<[string, Etag | null, any]>} */
45
- store: new AsyncParallelHook(["identifier", "etag", "data"]),
46
- /** @type {AsyncParallelHook<[Iterable<string>]>} */
47
- storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
48
- /** @type {SyncHook<[]>} */
49
- beginIdle: new SyncHook([]),
50
- /** @type {AsyncParallelHook<[]>} */
51
- endIdle: new AsyncParallelHook([]),
52
- /** @type {AsyncParallelHook<[]>} */
53
- shutdown: new AsyncParallelHook([])
29
+ get: new lite_tapable_1.AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
30
+ store: new lite_tapable_1.AsyncParallelHook(["identifier", "etag", "data"]),
31
+ storeBuildDependencies: new lite_tapable_1.AsyncParallelHook(["dependencies"]),
32
+ beginIdle: new lite_tapable_1.SyncHook([]),
33
+ endIdle: new lite_tapable_1.AsyncParallelHook([]),
34
+ shutdown: new lite_tapable_1.AsyncParallelHook([])
54
35
  };
55
36
  }
56
37
  /**
57
- * @template T
58
- * @param {string} identifier the cache identifier
59
- * @param {Etag | null} etag the etag
60
- * @param {CallbackCache<T>} callback signals when the value is retrieved
61
- * @returns {void}
38
+ * @param identifier the cache identifier
39
+ * @param etag the etag
40
+ * @param callback signals when the value is retrieved
41
+ * @returns
62
42
  */
63
43
  get(identifier, etag, callback) {
64
- // @ts-expect-error
65
44
  const gotHandlers = [];
66
- // @ts-expect-error
67
45
  this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {
68
46
  if (err) {
69
- callback(makeWebpackError(err, "Cache.hooks.get"));
47
+ callback((0, HookWebpackError_1.makeWebpackError)(err, "Cache.hooks.get"));
70
48
  return;
71
49
  }
72
50
  if (result === null) {
@@ -74,13 +52,11 @@ class Cache {
74
52
  }
75
53
  if (gotHandlers.length > 1) {
76
54
  const innerCallback = needCalls(gotHandlers.length, () => callback(null, result));
77
- // @ts-expect-error
78
55
  for (const gotHandler of gotHandlers) {
79
56
  gotHandler(result, innerCallback);
80
57
  }
81
58
  }
82
59
  else if (gotHandlers.length === 1) {
83
- // @ts-expect-error
84
60
  gotHandlers[0](result, () => callback(null, result));
85
61
  }
86
62
  else {
@@ -89,56 +65,45 @@ class Cache {
89
65
  });
90
66
  }
91
67
  /**
92
- * @template T
93
- * @param {string} identifier the cache identifier
94
- * @param {Etag | null} etag the etag
95
- * @param {T} data the value to store
96
- * @param {CallbackCache<void>} callback signals when the value is stored
97
- * @returns {void}
68
+ * @param identifier the cache identifier
69
+ * @param etag the etag
70
+ * @param data the value to store
71
+ * @param callback signals when the value is stored
72
+ * @returns
98
73
  */
99
74
  store(identifier, etag, data, callback) {
100
- this.hooks.store.callAsync(identifier, etag, data,
101
- // @ts-expect-error
102
- makeWebpackErrorCallback(callback, "Cache.hooks.store"));
75
+ this.hooks.store.callAsync(identifier, etag, data, (0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.store"));
103
76
  }
104
77
  /**
105
78
  * After this method has succeeded the cache can only be restored when build dependencies are
106
- * @param {Iterable<string>} dependencies list of all build dependencies
107
- * @param {CallbackCache<void>} callback signals when the dependencies are stored
108
- * @returns {void}
79
+ * @param dependencies list of all build dependencies
80
+ * @param callback signals when the dependencies are stored
81
+ * @returns
109
82
  */
110
83
  storeBuildDependencies(dependencies, callback) {
111
- this.hooks.storeBuildDependencies.callAsync(dependencies,
112
- // @ts-expect-error
113
- makeWebpackErrorCallback(callback, "Cache.hooks.storeBuildDependencies"));
84
+ this.hooks.storeBuildDependencies.callAsync(dependencies, (0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.storeBuildDependencies"));
114
85
  }
115
- /**
116
- * @returns {void}
117
- */
118
86
  beginIdle() {
119
87
  this.hooks.beginIdle.call();
120
88
  }
121
89
  /**
122
- * @param {CallbackCache<void>} callback signals when the call finishes
123
- * @returns {void}
90
+ * @param callback signals when the call finishes
91
+ * @returns
124
92
  */
125
93
  endIdle(callback) {
126
- this.hooks.endIdle.callAsync(
127
- // @ts-expect-error
128
- makeWebpackErrorCallback(callback, "Cache.hooks.endIdle"));
94
+ this.hooks.endIdle.callAsync((0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.endIdle"));
129
95
  }
130
96
  /**
131
- * @param {CallbackCache<void>} callback signals when the call finishes
132
- * @returns {void}
97
+ * @param callback signals when the call finishes
98
+ * @returns
133
99
  */
134
100
  shutdown(callback) {
135
- this.hooks.shutdown.callAsync(
136
- // @ts-expect-error
137
- makeWebpackErrorCallback(callback, "Cache.hooks.shutdown"));
101
+ this.hooks.shutdown.callAsync((0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.shutdown"));
138
102
  }
139
103
  }
104
+ Cache.STAGE_DISK = 10;
140
105
  Cache.STAGE_MEMORY = -10;
141
106
  Cache.STAGE_DEFAULT = 0;
142
- Cache.STAGE_DISK = 10;
143
107
  Cache.STAGE_NETWORK = 20;
144
- module.exports = Cache;
108
+ exports.Cache = Cache;
109
+ exports.default = Cache;