@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
@@ -1,3 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getTargetsProperties = exports.getTargetProperties = exports.getDefaultTarget = void 0;
1
27
  /**
2
28
  * The following code is modified based on
3
29
  * https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/target.js
@@ -7,87 +33,33 @@
7
33
  * Copyright (c) JS Foundation and other contributors
8
34
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
35
  */
10
- "use strict";
11
- const { memoize } = require("../util/memoize");
12
- const getBrowserslistTargetHandler = memoize(() => require("./browserslistTargetHandler"));
36
+ const memoize_1 = require("../util/memoize");
37
+ const browserslistTargetHandler = __importStar(require("./browserslistTargetHandler"));
38
+ const getBrowserslistTargetHandler = (0, memoize_1.memoize)(() => browserslistTargetHandler);
13
39
  /**
14
- * @param {string} context the context directory
15
- * @returns {"browserslist" | "web"} default target
40
+ * @param context the context directory
41
+ * @returns default target
16
42
  */
17
- const getDefaultTarget = context => {
43
+ const getDefaultTarget = (context) => {
18
44
  const browsers = getBrowserslistTargetHandler().load(null, context);
19
45
  return browsers ? "browserslist" : "web";
20
46
  };
47
+ exports.getDefaultTarget = getDefaultTarget;
21
48
  /**
22
- * @typedef {Object} PlatformTargetProperties
23
- * @property {boolean | null} web web platform, importing of http(s) and std: is available
24
- * @property {boolean | null} browser browser platform, running in a normal web browser
25
- * @property {boolean | null} webworker (Web)Worker platform, running in a web/shared/service worker
26
- * @property {boolean | null} node node platform, require of node built-in modules is available
27
- * @property {boolean | null} nwjs nwjs platform, require of legacy nw.gui is available
28
- * @property {boolean | null} electron electron platform, require of some electron built-in modules is available
29
- */
30
- /**
31
- * @typedef {Object} ElectronContextTargetProperties
32
- * @property {boolean | null} electronMain in main context
33
- * @property {boolean | null} electronPreload in preload context
34
- * @property {boolean | null} electronRenderer in renderer context with node integration
35
- */
36
- /**
37
- * @typedef {Object} ApiTargetProperties
38
- * @property {boolean | null} require has require function available
39
- * @property {boolean | null} nodeBuiltins has node.js built-in modules available
40
- * @property {boolean | null} nodePrefixForCoreModules node.js allows to use `node:` prefix for core modules
41
- * @property {boolean | null} document has document available (allows script tags)
42
- * @property {boolean | null} importScripts has importScripts available
43
- * @property {boolean | null} importScriptsInWorker has importScripts available when creating a worker
44
- * @property {boolean | null} fetchWasm has fetch function available for WebAssembly
45
- * @property {boolean | null} global has global variable available
46
- */
47
- /**
48
- * @typedef {Object} EcmaTargetProperties
49
- * @property {boolean | null} globalThis has globalThis variable available
50
- * @property {boolean | null} bigIntLiteral big int literal syntax is available
51
- * @property {boolean | null} const const and let variable declarations are available
52
- * @property {boolean | null} arrowFunction arrow functions are available
53
- * @property {boolean | null} forOf for of iteration is available
54
- * @property {boolean | null} destructuring destructuring is available
55
- * @property {boolean | null} dynamicImport async import() is available
56
- * @property {boolean | null} dynamicImportInWorker async import() is available when creating a worker
57
- * @property {boolean | null} module ESM syntax is available (when in module)
58
- * @property {boolean | null} optionalChaining optional chaining is available
59
- * @property {boolean | null} templateLiteral template literal is available
60
- * @property {boolean | null} asyncFunction async functions and await are available
61
- */
62
- ///** @typedef {PlatformTargetProperties | ApiTargetProperties | EcmaTargetProperties | PlatformTargetProperties & ApiTargetProperties | PlatformTargetProperties & EcmaTargetProperties | ApiTargetProperties & EcmaTargetProperties} TargetProperties */
63
- /**
64
- * @template T
65
- * @typedef {{ [P in keyof T]?: never }} Never<T>
66
- */
67
- /**
68
- * @template A
69
- * @template B
70
- * @typedef {(A & Never<B>) | (Never<A> & B) | (A & B)} Mix<A, B>
71
- */
72
- /** @typedef {Mix<Mix<PlatformTargetProperties, ElectronContextTargetProperties>, Mix<ApiTargetProperties, EcmaTargetProperties>>} TargetProperties */
73
- /**
74
- * @param {string} major major version
75
- * @param {string | undefined} minor minor version
76
- * @returns {(vMajor: number, vMinor?: number) => boolean | undefined} check if version is greater or equal
49
+ * @param major major version
50
+ * @param minor minor version
51
+ * @returns check if version is greater or equal
77
52
  */
78
53
  const versionDependent = (major, minor) => {
79
54
  if (!major) {
80
- return () => /** @type {undefined} */ (undefined);
55
+ return () => undefined;
81
56
  }
82
- /** @type {number} */
83
57
  const nMajor = +major;
84
- /** @type {number} */
85
58
  const nMinor = minor ? +minor : 0;
86
59
  return (vMajor, vMinor = 0) => {
87
60
  return nMajor > vMajor || (nMajor === vMajor && nMinor >= vMinor);
88
61
  };
89
62
  };
90
- /** @type {[string, string, RegExp, (...args: string[]) => Partial<TargetProperties>][]} */
91
63
  const TARGETS = [
92
64
  [
93
65
  "browserslist / browserslist:env / browserslist:query / browserslist:path-to-config / browserslist:path-to-config:env",
@@ -291,9 +263,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
291
263
  ]
292
264
  ];
293
265
  /**
294
- * @param {string} target the target
295
- * @param {string} context the context directory
296
- * @returns {TargetProperties} target properties
266
+ * @param target the target
267
+ * @param context the context directory
268
+ * @returns target properties
297
269
  */
298
270
  const getTargetProperties = (target, context) => {
299
271
  for (const [, , regExp, handler] of TARGETS) {
@@ -302,24 +274,19 @@ const getTargetProperties = (target, context) => {
302
274
  const [, ...args] = match;
303
275
  const result = handler(...args, context);
304
276
  if (result)
305
- return /** @type {TargetProperties} */ (result);
277
+ return result;
306
278
  }
307
279
  }
308
280
  throw new Error(`Unknown target '${target}'. The following targets are supported:\n${TARGETS.map(([name, description]) => `* ${name}: ${description}`).join("\n")}`);
309
281
  };
310
- /**
311
- * @param {TargetProperties[]} targetProperties array of target properties
312
- * @returns {TargetProperties} merged target properties
313
- */
314
- const mergeTargetProperties = targetProperties => {
315
- /** @type {Set<keyof TargetProperties>} */
282
+ exports.getTargetProperties = getTargetProperties;
283
+ const mergeTargetProperties = (targetProperties) => {
316
284
  const keys = new Set();
317
285
  for (const tp of targetProperties) {
318
286
  for (const key of Object.keys(tp)) {
319
- keys.add(/** @type {keyof TargetProperties} */ (key));
287
+ keys.add(key);
320
288
  }
321
289
  }
322
- /** @type {Object} */
323
290
  const result = {};
324
291
  for (const key of keys) {
325
292
  let hasTrue = false;
@@ -336,19 +303,16 @@ const mergeTargetProperties = targetProperties => {
336
303
  }
337
304
  }
338
305
  if (hasTrue || hasFalse)
339
- /** @type {TargetProperties} */
340
- (result)[key] = hasFalse && hasTrue ? null : hasTrue ? true : false;
306
+ result[key] = hasFalse && hasTrue ? null : hasTrue;
341
307
  }
342
- return /** @type {TargetProperties} */ (result);
308
+ return result;
343
309
  };
344
310
  /**
345
- * @param {string[]} targets the targets
346
- * @param {string} context the context directory
347
- * @returns {TargetProperties} target properties
311
+ * @param targets the targets
312
+ * @param context the context directory
313
+ * @returns target properties
348
314
  */
349
315
  const getTargetsProperties = (targets, context) => {
350
- return mergeTargetProperties(targets.map(t => getTargetProperties(t, context)));
316
+ return mergeTargetProperties(targets.map(t => (0, exports.getTargetProperties)(t, context)));
351
317
  };
352
- exports.getDefaultTarget = getDefaultTarget;
353
- exports.getTargetProperties = getTargetProperties;
354
318
  exports.getTargetsProperties = getTargetsProperties;