@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
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isUseSimpleSourceMap = exports.isUseSourceMap = exports.createRawModuleRuleUses = exports.BUILTIN_LOADER_PREFIX = void 0;
4
4
  const builtin_loader_1 = require("../builtin-loader");
5
+ const lightningcss_1 = require("../builtin-loader/lightningcss");
5
6
  const loader_runner_1 = require("../loader-runner");
6
7
  const util_1 = require("../util");
8
+ const browserslist = require("../../compiled/browserslist");
7
9
  exports.BUILTIN_LOADER_PREFIX = "builtin:";
8
10
  function createRawModuleRuleUses(uses, path, options) {
9
11
  const normalizeRuleSetUseItem = (item) => typeof item === "string" ? { loader: item } : item;
@@ -13,7 +15,7 @@ function createRawModuleRuleUses(uses, path, options) {
13
15
  return createRawModuleRuleUsesImpl(allUses, path, options);
14
16
  }
15
17
  exports.createRawModuleRuleUses = createRawModuleRuleUses;
16
- const getSwcLoaderOptions = (o, options) => {
18
+ const getSwcLoaderOptions = (o, _) => {
17
19
  if (o && typeof o === "object" && o.rspackExperiments) {
18
20
  const expr = o.rspackExperiments;
19
21
  if (expr.import || expr.pluginImport) {
@@ -22,10 +24,30 @@ const getSwcLoaderOptions = (o, options) => {
22
24
  }
23
25
  return o;
24
26
  };
27
+ const getLightningcssLoaderOptions = (o, _) => {
28
+ if (o && typeof o === "object") {
29
+ if (o.targets && typeof o.targets === "string") {
30
+ o.targets = (0, lightningcss_1.browserslistToTargets)(browserslist(o.targets));
31
+ }
32
+ if (o.targets && Array.isArray(o.targets)) {
33
+ o.targets = (0, lightningcss_1.browserslistToTargets)(browserslist(o.targets));
34
+ }
35
+ if (o.include && typeof o.include === "object") {
36
+ o.include = (0, lightningcss_1.toFeatures)(o.include);
37
+ }
38
+ if (o.exclude && typeof o.exclude === "object") {
39
+ o.exclude = (0, lightningcss_1.toFeatures)(o.exclude);
40
+ }
41
+ }
42
+ return o;
43
+ };
25
44
  function getBuiltinLoaderOptions(identifier, o, options) {
26
45
  if (identifier.startsWith(`${exports.BUILTIN_LOADER_PREFIX}swc-loader`)) {
27
46
  return getSwcLoaderOptions(o, options);
28
47
  }
48
+ if (identifier.startsWith(`${exports.BUILTIN_LOADER_PREFIX}lightningcss-loader`)) {
49
+ return getLightningcssLoaderOptions(o, options);
50
+ }
29
51
  return o;
30
52
  }
31
53
  function createRawModuleRuleUsesImpl(uses, path, options) {
@@ -1,19 +1,21 @@
1
- export type ApiTargetProperties = import("./target").ApiTargetProperties;
2
- export type EcmaTargetProperties = import("./target").EcmaTargetProperties;
3
- export type PlatformTargetProperties = import("./target").PlatformTargetProperties;
4
- export type BrowserslistHandlerConfig = {
5
- configPath?: string | undefined;
6
- env?: string | undefined;
7
- query?: string | undefined;
8
- };
9
1
  /**
10
- * @param {string[]} browsers supported browsers list
11
- * @returns {EcmaTargetProperties & PlatformTargetProperties & ApiTargetProperties} target properties
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/browserslistTargetHandler.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Sergey Melyukov @smelukov
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
12
9
  */
13
- export function resolve(browsers: string[]): EcmaTargetProperties & PlatformTargetProperties & ApiTargetProperties;
10
+ import type { ApiTargetProperties, EcmaTargetProperties, PlatformTargetProperties } from "./target";
14
11
  /**
15
- * @param {string | null | undefined} input input string
16
- * @param {string} context the context directory
17
- * @returns {string[] | undefined} selected browsers
12
+ * @param input input string
13
+ * @param context the context directory
14
+ * @returns selected browsers
18
15
  */
19
- export function load(input: string | null | undefined, context: string): string[] | undefined;
16
+ export declare const load: (input: string | null | undefined, context: string) => string[] | undefined;
17
+ /**
18
+ * @param browsers supported browsers list
19
+ * @returns target properties
20
+ */
21
+ export declare const resolve: (browsers: string[]) => EcmaTargetProperties & PlatformTargetProperties & ApiTargetProperties;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * The following code is modified based on
3
4
  * https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/browserslistTargetHandler.js
@@ -7,43 +8,38 @@
7
8
  * Copyright (c) JS Foundation and other contributors
8
9
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
10
  */
10
- "use strict";
11
- const browserslist = require("../../compiled/browserslist");
12
- const path = require("node:path");
13
- /** @typedef {import("./target").ApiTargetProperties} ApiTargetProperties */
14
- /** @typedef {import("./target").EcmaTargetProperties} EcmaTargetProperties */
15
- /** @typedef {import("./target").PlatformTargetProperties} PlatformTargetProperties */
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.resolve = exports.load = void 0;
16
+ const node_path_1 = __importDefault(require("node:path"));
17
+ const browserslist_1 = __importDefault(require("../../compiled/browserslist"));
16
18
  // [[C:]/path/to/config][:env]
17
19
  const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
18
20
  /**
19
- * @typedef {Object} BrowserslistHandlerConfig
20
- * @property {string=} configPath
21
- * @property {string=} env
22
- * @property {string=} query
23
- */
24
- /**
25
- * @param {string | null | undefined} input input string
26
- * @param {string} context the context directory
27
- * @returns {BrowserslistHandlerConfig} config
21
+ * @param input input string
22
+ * @param context the context directory
23
+ * @returns config
28
24
  */
29
25
  const parse = (input, context) => {
30
26
  if (!input) {
31
27
  return {};
32
28
  }
33
- if (path.isAbsolute(input)) {
29
+ if (node_path_1.default.isAbsolute(input)) {
34
30
  const [, configPath, env] = inputRx.exec(input) || [];
35
31
  return { configPath, env };
36
32
  }
37
- const config = browserslist.findConfig(context);
33
+ const config = browserslist_1.default.findConfig(context);
38
34
  if (config && Object.keys(config).includes(input)) {
39
35
  return { env: input };
40
36
  }
41
37
  return { query: input };
42
38
  };
43
39
  /**
44
- * @param {string | null | undefined} input input string
45
- * @param {string} context the context directory
46
- * @returns {string[] | undefined} selected browsers
40
+ * @param input input string
41
+ * @param context the context directory
42
+ * @returns selected browsers
47
43
  */
48
44
  const load = (input, context) => {
49
45
  const { configPath, env, query } = parse(input, context);
@@ -53,26 +49,27 @@ const load = (input, context) => {
53
49
  const config = query
54
50
  ? query
55
51
  : configPath
56
- ? browserslist.loadConfig({
52
+ ? browserslist_1.default.loadConfig({
57
53
  config: configPath,
58
54
  env
59
55
  })
60
- : browserslist.loadConfig({ path: context, env });
56
+ : browserslist_1.default.loadConfig({ path: context, env });
61
57
  if (!config)
62
58
  return;
63
- return browserslist(config);
59
+ return (0, browserslist_1.default)(config);
64
60
  };
61
+ exports.load = load;
65
62
  /**
66
- * @param {string[]} browsers supported browsers list
67
- * @returns {EcmaTargetProperties & PlatformTargetProperties & ApiTargetProperties} target properties
63
+ * @param browsers supported browsers list
64
+ * @returns target properties
68
65
  */
69
- const resolve = browsers => {
66
+ const resolve = (browsers) => {
70
67
  /**
71
68
  * Checks all against a version number
72
- * @param {Record<string, number | [number, number]>} versions first supported version
73
- * @returns {boolean} true if supports
69
+ * @param versions first supported version
70
+ * @returns true if supports
74
71
  */
75
- const rawChecker = versions => {
72
+ const rawChecker = (versions) => {
76
73
  return browsers.every(v => {
77
74
  const [name, parsedVersion] = v.split(" ");
78
75
  if (!name)
@@ -344,7 +341,4 @@ const resolve = browsers => {
344
341
  require: nodeProperty
345
342
  };
346
343
  };
347
- module.exports = {
348
- resolve,
349
- load
350
- };
344
+ exports.resolve = resolve;
@@ -17,12 +17,12 @@ const node_assert_1 = __importDefault(require("node:assert"));
17
17
  const node_fs_1 = __importDefault(require("node:fs"));
18
18
  const node_path_1 = __importDefault(require("node:path"));
19
19
  const ModuleTypeConstants_1 = require("../ModuleTypeConstants");
20
+ const Template_1 = require("../Template");
20
21
  const builtin_plugin_1 = require("../builtin-plugin");
21
22
  const util_1 = require("../util");
22
23
  const assertNotNil_1 = require("../util/assertNotNil");
23
24
  const cleverMerge_1 = require("../util/cleverMerge");
24
25
  const target_1 = require("./target");
25
- const Template = require("../Template");
26
26
  const applyRspackOptionsDefaults = (options) => {
27
27
  F(options, "context", () => process.cwd());
28
28
  F(options, "target", () => {
@@ -126,6 +126,7 @@ const applyExperimentsDefaults = (experiments) => {
126
126
  D(experiments, "lazyCompilation", false);
127
127
  D(experiments, "asyncWebAssembly", experiments.futureDefaults);
128
128
  D(experiments, "css", experiments.futureDefaults ? true : undefined);
129
+ D(experiments, "layers", false);
129
130
  D(experiments, "topLevelAwait", true);
130
131
  // IGNORE(experiments.rspackFuture): Rspack specific configuration
131
132
  D(experiments, "rspackFuture", {});
@@ -152,6 +153,7 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
152
153
  D(parserOptions, "strictExportPresence", fallback?.strictExportPresence ?? false);
153
154
  D(parserOptions, "worker", fallback?.worker ?? ["..."]);
154
155
  D(parserOptions, "overrideStrict", fallback?.overrideStrict ?? undefined);
156
+ D(parserOptions, "importMeta", fallback?.importMeta ?? true);
155
157
  };
156
158
  const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
157
159
  (0, assertNotNil_1.assertNotNill)(module.parser);
@@ -188,8 +190,8 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
188
190
  // IGNORE(module.generator): already check to align in 2024.6.27
189
191
  F(module.generator, "css", () => ({}));
190
192
  (0, assertNotNil_1.assertNotNill)(module.generator.css);
191
- D(module.generator["css"], "exportsOnly", !targetProperties || !targetProperties.document);
192
- D(module.generator["css"], "esModule", true);
193
+ D(module.generator.css, "exportsOnly", !targetProperties || !targetProperties.document);
194
+ D(module.generator.css, "esModule", true);
193
195
  F(module.generator, "css/auto", () => ({}));
194
196
  (0, assertNotNil_1.assertNotNill)(module.generator["css/auto"]);
195
197
  D(module.generator["css/auto"], "exportsOnly", !targetProperties || !targetProperties.document);
@@ -316,16 +318,10 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
316
318
  type: "asset/resource"
317
319
  }
318
320
  ]
319
- }
320
- // {
321
- // assert: { type: "json" },
322
- // type: "json"
323
- // },
324
- // {
325
- // with: { type: "json" },
326
- // type: "json"
327
- // }
328
- );
321
+ }, {
322
+ with: { type: "json" },
323
+ type: "json"
324
+ });
329
325
  return rules;
330
326
  });
331
327
  };
@@ -340,10 +336,10 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
340
336
  if (Array.isArray(libraryName)) {
341
337
  return libraryName.join(".");
342
338
  }
343
- else if (typeof libraryName === "object") {
339
+ if (typeof libraryName === "object") {
344
340
  return getLibraryName(libraryName.root);
345
341
  }
346
- else if (typeof libraryName === "string") {
342
+ if (typeof libraryName === "string") {
347
343
  return libraryName;
348
344
  }
349
345
  return "";
@@ -406,8 +402,7 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
406
402
  });
407
403
  D(output, "hotUpdateChunkFilename", `[id].[fullhash].hot-update.${output.module ? "mjs" : "js"}`);
408
404
  D(output, "hotUpdateMainFilename", "[runtime].[fullhash].hot-update.json");
409
- const uniqueNameId = Template.toIdentifier(
410
- /** @type {NonNullable<Output["uniqueName"]>} */ output.uniqueName);
405
+ const uniqueNameId = Template_1.Template.toIdentifier(output.uniqueName);
411
406
  F(output, "hotUpdateGlobal", () => "webpackHotUpdate" + uniqueNameId);
412
407
  F(output, "chunkLoadingGlobal", () => "webpackChunk" + uniqueNameId);
413
408
  D(output, "assetModuleFilename", "[hash][ext][query]");
@@ -437,20 +432,18 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
437
432
  "JSONP Array push can be chosen when 'document' is available.\n" +
438
433
  helpMessage);
439
434
  }
440
- else {
441
- if (tp.document)
442
- return "array-push";
443
- if (tp.require)
444
- return "commonjs";
445
- if (tp.nodeBuiltins)
446
- return "commonjs";
447
- if (tp.importScripts)
448
- return "array-push";
449
- throw new Error("For the selected environment is no default script chunk format available:\n" +
450
- "JSONP Array push can be chosen when 'document' or 'importScripts' is available.\n" +
451
- "CommonJs exports can be chosen when 'require' or node builtins are available.\n" +
452
- helpMessage);
453
- }
435
+ if (tp.document)
436
+ return "array-push";
437
+ if (tp.require)
438
+ return "commonjs";
439
+ if (tp.nodeBuiltins)
440
+ return "commonjs";
441
+ if (tp.importScripts)
442
+ return "array-push";
443
+ throw new Error("For the selected environment is no default script chunk format available:\n" +
444
+ "JSONP Array push can be chosen when 'document' or 'importScripts' is available.\n" +
445
+ "CommonJs exports can be chosen when 'require' or node builtins are available.\n" +
446
+ helpMessage);
454
447
  }
455
448
  throw new Error("Chunk format can't be selected by default when no target is specified");
456
449
  });
@@ -533,12 +526,15 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
533
526
  return "self";
534
527
  });
535
528
  D(output, "importFunctionName", "import");
529
+ D(output, "importMetaName", "import.meta");
536
530
  // IGNORE(output.clean): The default value of `output.clean` in webpack is undefined, but it has the same effect as false.
537
531
  F(output, "clean", () => !!output.clean);
538
532
  D(output, "crossOriginLoading", false);
539
533
  D(output, "workerPublicPath", "");
540
534
  D(output, "sourceMapFilename", "[file].map[query]");
541
535
  F(output, "scriptType", () => (output.module ? "module" : false));
536
+ D(output, "charset", true);
537
+ D(output, "chunkLoadTimeout", 120000);
542
538
  const { trustedTypes } = output;
543
539
  if (trustedTypes) {
544
540
  F(trustedTypes, "policyName", () => output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, "_") || "webpack");
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type { Compilation } from "../Compilation";
11
- import type { AssetModuleFilename, Bail, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LazyCompilationOptions, LibraryOptions, Loader, Mode, Name, NoParseOption, Node, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./zod";
11
+ import type { AssetModuleFilename, AsyncChunks, Bail, BaseUri, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, ImportMetaName, InfrastructureLogging, Layer, LazyCompilationOptions, LibraryOptions, Loader, Mode, Name, NoParseOption, Node, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./zod";
12
12
  export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
13
13
  export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
14
14
  export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
@@ -19,12 +19,13 @@ export interface EntryDescriptionNormalized {
19
19
  import?: string[];
20
20
  runtime?: EntryRuntime;
21
21
  chunkLoading?: ChunkLoading;
22
- asyncChunks?: boolean;
22
+ asyncChunks?: AsyncChunks;
23
23
  publicPath?: PublicPath;
24
- baseUri?: string;
24
+ baseUri?: BaseUri;
25
25
  filename?: EntryFilename;
26
26
  library?: LibraryOptions;
27
27
  dependOn?: string[];
28
+ layer?: Layer;
28
29
  }
29
30
  export interface OutputNormalized {
30
31
  path?: Path;
@@ -48,6 +49,7 @@ export interface OutputNormalized {
48
49
  strictModuleErrorHandling?: StrictModuleErrorHandling;
49
50
  globalObject?: GlobalObject;
50
51
  importFunctionName?: ImportFunctionName;
52
+ importMetaName?: ImportMetaName;
51
53
  iife?: Iife;
52
54
  wasmLoading?: WasmLoading;
53
55
  enabledWasmLoadingTypes?: EnabledWasmLoadingTypes;
@@ -70,6 +72,8 @@ export interface OutputNormalized {
70
72
  devtoolModuleFilenameTemplate?: DevtoolModuleFilenameTemplate;
71
73
  devtoolFallbackModuleFilenameTemplate?: DevtoolFallbackModuleFilenameTemplate;
72
74
  environment?: Environment;
75
+ charset?: boolean;
76
+ chunkLoadTimeout?: number;
73
77
  }
74
78
  export interface ModuleOptionsNormalized {
75
79
  defaultRules?: RuleSetRules;
@@ -84,6 +88,7 @@ export interface ExperimentsNormalized {
84
88
  outputModule?: boolean;
85
89
  topLevelAwait?: boolean;
86
90
  css?: boolean;
91
+ layers?: boolean;
87
92
  futureDefaults?: boolean;
88
93
  rspackFuture?: RspackFutureOptions;
89
94
  }
@@ -17,11 +17,9 @@ const getNormalizedRspackOptions = (config) => {
17
17
  if (typeof ignore === "function") {
18
18
  return ignore;
19
19
  }
20
- else {
21
- return (warning) => {
22
- return ignore.test(warning.message);
23
- };
24
- }
20
+ return (warning) => {
21
+ return ignore.test(warning.message);
22
+ };
25
23
  })
26
24
  : undefined,
27
25
  name: config.name,
@@ -77,6 +75,7 @@ const getNormalizedRspackOptions = (config) => {
77
75
  : ["..."],
78
76
  globalObject: output.globalObject,
79
77
  importFunctionName: output.importFunctionName,
78
+ importMetaName: output.importMetaName,
80
79
  iife: output.iife,
81
80
  module: output.module,
82
81
  sourceMapFilename: output.sourceMapFilename,
@@ -117,6 +116,8 @@ const getNormalizedRspackOptions = (config) => {
117
116
  devtoolNamespace: output.devtoolNamespace,
118
117
  devtoolModuleFilenameTemplate: output.devtoolModuleFilenameTemplate,
119
118
  devtoolFallbackModuleFilenameTemplate: output.devtoolFallbackModuleFilenameTemplate,
119
+ chunkLoadTimeout: output.chunkLoadTimeout,
120
+ charset: output.charset,
120
121
  environment: cloneObject(output.environment)
121
122
  };
122
123
  }),
@@ -240,6 +241,7 @@ const getNormalizedEntryStatic = (entry) => {
240
241
  asyncChunks: value.asyncChunks,
241
242
  filename: value.filename,
242
243
  library: value.library,
244
+ layer: value.layer,
243
245
  dependOn: Array.isArray(value.dependOn)
244
246
  ? value.dependOn
245
247
  : value.dependOn
@@ -1,150 +1,89 @@
1
+ /**
2
+ * @param context the context directory
3
+ * @returns default target
4
+ */
5
+ export declare const getDefaultTarget: (context: string) => "browserslist" | "web";
1
6
  export type PlatformTargetProperties = {
2
- /**
3
- * web platform, importing of http(s) and std: is available
4
- */
7
+ /** web platform, importing of http(s) and std: is available */
5
8
  web: boolean | null;
6
- /**
7
- * browser platform, running in a normal web browser
8
- */
9
+ /** browser platform, running in a normal web browser */
9
10
  browser: boolean | null;
10
- /**
11
- * (Web)Worker platform, running in a web/shared/service worker
12
- */
11
+ /** (Web)Worker platform, running in a web/shared/service worker */
13
12
  webworker: boolean | null;
14
- /**
15
- * node platform, require of node built-in modules is available
16
- */
13
+ /** node platform, require of node built-in modules is available */
17
14
  node: boolean | null;
18
- /**
19
- * nwjs platform, require of legacy nw.gui is available
20
- */
15
+ /** nwjs platform, require of legacy nw.gui is available */
21
16
  nwjs: boolean | null;
22
- /**
23
- * electron platform, require of some electron built-in modules is available
24
- */
17
+ /** electron platform, require of some electron built-in modules is available */
25
18
  electron: boolean | null;
26
19
  };
27
20
  export type ElectronContextTargetProperties = {
28
- /**
29
- * in main context
30
- */
21
+ /** in main context */
31
22
  electronMain: boolean | null;
32
- /**
33
- * in preload context
34
- */
23
+ /** in preload context */
35
24
  electronPreload: boolean | null;
36
- /**
37
- * in renderer context with node integration
38
- */
25
+ /** in renderer context with node integration */
39
26
  electronRenderer: boolean | null;
40
27
  };
41
28
  export type ApiTargetProperties = {
42
- /**
43
- * has require function available
44
- */
29
+ /** has require function available */
45
30
  require: boolean | null;
46
- /**
47
- * has node.js built-in modules available
48
- */
31
+ /** has node.js built-in modules available */
49
32
  nodeBuiltins: boolean | null;
50
- /**
51
- * node.js allows to use `node:` prefix for core modules
52
- */
33
+ /** node.js allows to use `node:` prefix for core modules */
53
34
  nodePrefixForCoreModules: boolean | null;
54
- /**
55
- * has document available (allows script tags)
56
- */
35
+ /** has document available (allows script tags) */
57
36
  document: boolean | null;
58
- /**
59
- * has importScripts available
60
- */
37
+ /** has importScripts available */
61
38
  importScripts: boolean | null;
62
- /**
63
- * has importScripts available when creating a worker
64
- */
39
+ /** has importScripts available when creating a worker */
65
40
  importScriptsInWorker: boolean | null;
66
- /**
67
- * has fetch function available for WebAssembly
68
- */
41
+ /** has fetch function available for WebAssembly */
69
42
  fetchWasm: boolean | null;
70
- /**
71
- * has global variable available
72
- */
43
+ /** has global variable available */
73
44
  global: boolean | null;
74
45
  };
75
46
  export type EcmaTargetProperties = {
76
- /**
77
- * has globalThis variable available
78
- */
47
+ /** has globalThis variable available */
79
48
  globalThis: boolean | null;
80
- /**
81
- * big int literal syntax is available
82
- */
49
+ /** big int literal syntax is available */
83
50
  bigIntLiteral: boolean | null;
84
- /**
85
- * const and let variable declarations are available
86
- */
51
+ /** const and let variable declarations are available */
87
52
  const: boolean | null;
88
- /**
89
- * arrow functions are available
90
- */
53
+ /** arrow functions are available */
91
54
  arrowFunction: boolean | null;
92
- /**
93
- * for of iteration is available
94
- */
55
+ /** for of iteration is available */
95
56
  forOf: boolean | null;
96
- /**
97
- * destructuring is available
98
- */
57
+ /** destructuring is available */
99
58
  destructuring: boolean | null;
100
- /**
101
- * async import() is available
102
- */
59
+ /** async import() is available */
103
60
  dynamicImport: boolean | null;
104
- /**
105
- * async import() is available when creating a worker
106
- */
61
+ /** async import() is available when creating a worker */
107
62
  dynamicImportInWorker: boolean | null;
108
- /**
109
- * ESM syntax is available (when in module)
110
- */
63
+ /** ESM syntax is available (when in module) */
111
64
  module: boolean | null;
112
- /**
113
- * optional chaining is available
114
- */
65
+ /** optional chaining is available */
115
66
  optionalChaining: boolean | null;
116
- /**
117
- * template literal is available
118
- */
67
+ /** template literal is available */
119
68
  templateLiteral: boolean | null;
120
- /**
121
- * async functions and await are available
122
- */
69
+ /** async functions and await are available */
123
70
  asyncFunction: boolean | null;
124
71
  };
72
+ type Never<T> = {
73
+ [P in keyof T]?: never;
74
+ };
75
+ type Mix<A, B> = (A & Never<B>) | (Never<A> & B) | (A & B);
76
+ type TargetProperties = Mix<Mix<PlatformTargetProperties, ElectronContextTargetProperties>, Mix<ApiTargetProperties, EcmaTargetProperties>>;
125
77
  /**
126
- * <T>
127
- */
128
- export type Never<T> = { [P in keyof T]?: undefined; };
129
- /**
130
- * <A, B>
131
- */
132
- export type Mix<A, B> = (A & Never<B>) | (Never<A> & B) | (A & B);
133
- export type TargetProperties = Mix<Mix<PlatformTargetProperties, ElectronContextTargetProperties>, Mix<ApiTargetProperties, EcmaTargetProperties>>;
134
- /**
135
- * @param {string} context the context directory
136
- * @returns {"browserslist" | "web"} default target
137
- */
138
- export function getDefaultTarget(context: string): "browserslist" | "web";
139
- /**
140
- * @param {string} target the target
141
- * @param {string} context the context directory
142
- * @returns {TargetProperties} target properties
78
+ * @param target the target
79
+ * @param context the context directory
80
+ * @returns target properties
143
81
  */
144
- export function getTargetProperties(target: string, context: string): TargetProperties;
82
+ export declare const getTargetProperties: (target: string, context: string) => TargetProperties;
145
83
  /**
146
- * @param {string[]} targets the targets
147
- * @param {string} context the context directory
148
- * @returns {TargetProperties} target properties
84
+ * @param targets the targets
85
+ * @param context the context directory
86
+ * @returns target properties
149
87
  */
150
- export function getTargetsProperties(targets: string[], context: string): TargetProperties;
88
+ export declare const getTargetsProperties: (targets: string[], context: string) => TargetProperties;
89
+ export {};