webpack 5.86.0 → 5.87.0

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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (105) hide show
  1. package/README.md +5 -2
  2. package/lib/CaseSensitiveModulesWarning.js +3 -1
  3. package/lib/ChunkGroup.js +1 -0
  4. package/lib/Compiler.js +3 -1
  5. package/lib/ConcatenationScope.js +2 -2
  6. package/lib/ConditionalInitFragment.js +11 -1
  7. package/lib/ConstPlugin.js +57 -29
  8. package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
  9. package/lib/ModuleDependencyError.js +4 -2
  10. package/lib/ModuleDependencyWarning.js +4 -2
  11. package/lib/ModuleGraph.js +31 -24
  12. package/lib/ModuleGraphConnection.js +19 -6
  13. package/lib/ModuleInfoHeaderPlugin.js +9 -2
  14. package/lib/ModuleNotFoundError.js +5 -2
  15. package/lib/ModuleStoreError.js +2 -1
  16. package/lib/ModuleTypeConstants.js +7 -0
  17. package/lib/MultiWatching.js +4 -0
  18. package/lib/RuntimeGlobals.js +5 -0
  19. package/lib/RuntimePlugin.js +2 -1
  20. package/lib/RuntimeTemplate.js +20 -2
  21. package/lib/WebpackError.js +6 -5
  22. package/lib/WebpackOptionsApply.js +1 -1
  23. package/lib/WebpackOptionsDefaulter.js +10 -3
  24. package/lib/config/defaults.js +31 -2
  25. package/lib/css/CssModulesPlugin.js +5 -2
  26. package/lib/css/CssParser.js +12 -0
  27. package/lib/dependencies/ConstDependency.js +2 -2
  28. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
  29. package/lib/dependencies/ImportParserPlugin.js +25 -1
  30. package/lib/ids/SyncModuleIdsPlugin.js +1 -0
  31. package/lib/javascript/BasicEvaluatedExpression.js +23 -15
  32. package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
  33. package/lib/javascript/JavascriptParser.js +118 -58
  34. package/lib/javascript/JavascriptParserHelpers.js +37 -15
  35. package/lib/performance/SizeLimitsPlugin.js +7 -4
  36. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +3 -1
  37. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
  38. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +5 -2
  39. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +3 -1
  40. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +3 -1
  41. package/lib/rules/BasicEffectRulePlugin.js +4 -0
  42. package/lib/rules/BasicMatcherRulePlugin.js +5 -0
  43. package/lib/rules/RuleSetCompiler.js +3 -3
  44. package/lib/rules/UseEffectRulePlugin.js +6 -4
  45. package/lib/runtime/AsyncModuleRuntimeModule.js +4 -1
  46. package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -1
  47. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  48. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +4 -1
  49. package/lib/runtime/CompatRuntimeModule.js +6 -1
  50. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +4 -1
  51. package/lib/runtime/CreateScriptRuntimeModule.js +3 -1
  52. package/lib/runtime/CreateScriptUrlRuntimeModule.js +3 -1
  53. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +4 -1
  54. package/lib/runtime/EnsureChunkRuntimeModule.js +14 -3
  55. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -9
  56. package/lib/runtime/GetFullHashRuntimeModule.js +3 -2
  57. package/lib/runtime/GetMainFilenameRuntimeModule.js +4 -1
  58. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +3 -1
  59. package/lib/runtime/HasOwnPropertyRuntimeModule.js +4 -1
  60. package/lib/runtime/LoadScriptRuntimeModule.js +63 -47
  61. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +4 -1
  62. package/lib/runtime/OnChunksLoadedRuntimeModule.js +3 -1
  63. package/lib/runtime/PublicPathRuntimeModule.js +3 -1
  64. package/lib/runtime/RelativeUrlRuntimeModule.js +4 -1
  65. package/lib/runtime/RuntimeIdRuntimeModule.js +5 -1
  66. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -2
  67. package/lib/runtime/StartupEntrypointRuntimeModule.js +2 -1
  68. package/lib/serialization/ObjectMiddleware.js +6 -3
  69. package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
  70. package/lib/sharing/ConsumeSharedRuntimeModule.js +13 -4
  71. package/lib/sharing/ProvideSharedDependency.js +11 -0
  72. package/lib/sharing/ProvideSharedModule.js +4 -0
  73. package/lib/sharing/ProvideSharedPlugin.js +22 -21
  74. package/lib/sharing/ShareRuntimeModule.js +11 -4
  75. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  76. package/lib/sharing/utils.js +32 -5
  77. package/lib/util/AsyncQueue.js +4 -2
  78. package/lib/util/ParallelismFactorCalculator.js +10 -0
  79. package/lib/util/Semaphore.js +1 -1
  80. package/lib/util/createHash.js +30 -9
  81. package/lib/util/deprecation.js +10 -3
  82. package/lib/util/deterministicGrouping.js +50 -11
  83. package/lib/util/findGraphRoots.js +4 -2
  84. package/lib/util/memoize.js +3 -3
  85. package/lib/util/processAsyncTree.js +7 -1
  86. package/lib/util/registerExternalSerializer.js +1 -1
  87. package/lib/util/runtime.js +14 -1
  88. package/lib/util/smartGrouping.js +1 -1
  89. package/lib/validateSchema.js +6 -2
  90. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  91. package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
  92. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -6
  93. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -1
  94. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
  95. package/lib/wasm-sync/WebAssemblyParser.js +6 -2
  96. package/lib/web/JsonpChunkLoadingRuntimeModule.js +13 -3
  97. package/lib/webpack.js +11 -2
  98. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +14 -15
  99. package/module.d.ts +1 -0
  100. package/package.json +4 -4
  101. package/schemas/WebpackOptions.check.js +1 -1
  102. package/schemas/WebpackOptions.json +39 -5
  103. package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
  104. package/schemas/plugins/css/CssParserOptions.json +1 -1
  105. package/types.d.ts +433 -184
@@ -16,6 +16,7 @@ class ModuleStoreError extends WebpackError {
16
16
  */
17
17
  constructor(module, err) {
18
18
  let message = "Module storing failed: ";
19
+ /** @type {string | undefined} */
19
20
  let details = undefined;
20
21
  if (err !== null && typeof err === "object") {
21
22
  if (typeof err.stack === "string" && err.stack) {
@@ -33,7 +34,7 @@ class ModuleStoreError extends WebpackError {
33
34
  super(message);
34
35
 
35
36
  this.name = "ModuleStoreError";
36
- this.details = details;
37
+ this.details = /** @type {string | undefined} */ (details);
37
38
  this.module = module;
38
39
  this.error = err;
39
40
  }
@@ -60,6 +60,12 @@ const CSS_MODULE_TYPE_GLOBAL = "css/global";
60
60
  */
61
61
  const CSS_MODULE_TYPE_MODULE = "css/module";
62
62
 
63
+ /**
64
+ * @type {Readonly<"css/auto">}
65
+ * This is the module type used for CSS files, the module will be parsed as CSS modules if it's filename contains `.module.` or `.modules.`.
66
+ */
67
+ const CSS_MODULE_TYPE_AUTO = "css/auto";
68
+
63
69
  /**
64
70
  * @type {Readonly<"asset">}
65
71
  * This is the module type used for automatically choosing between `asset/inline`, `asset/resource` based on asset size limit (8096).
@@ -152,6 +158,7 @@ exports.WEBASSEMBLY_MODULE_TYPE_SYNC = WEBASSEMBLY_MODULE_TYPE_SYNC;
152
158
  exports.CSS_MODULE_TYPE = CSS_MODULE_TYPE;
153
159
  exports.CSS_MODULE_TYPE_GLOBAL = CSS_MODULE_TYPE_GLOBAL;
154
160
  exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE;
161
+ exports.CSS_MODULE_TYPE_AUTO = CSS_MODULE_TYPE_AUTO;
155
162
  exports.WEBPACK_MODULE_TYPE_RUNTIME = WEBPACK_MODULE_TYPE_RUNTIME;
156
163
  exports.WEBPACK_MODULE_TYPE_FALLBACK = WEBPACK_MODULE_TYPE_FALLBACK;
157
164
  exports.WEBPACK_MODULE_TYPE_REMOTE = WEBPACK_MODULE_TYPE_REMOTE;
@@ -27,6 +27,10 @@ class MultiWatching {
27
27
  this.compiler = compiler;
28
28
  }
29
29
 
30
+ /**
31
+ * @param {Callback<void>=} callback signals when the build has completed again
32
+ * @returns {void}
33
+ */
30
34
  invalidate(callback) {
31
35
  if (callback) {
32
36
  asyncLib.each(
@@ -188,6 +188,11 @@ exports.createScriptUrl = "__webpack_require__.tu";
188
188
  */
189
189
  exports.getTrustedTypesPolicy = "__webpack_require__.tt";
190
190
 
191
+ /**
192
+ * a flag when a chunk has a fetch priority
193
+ */
194
+ exports.hasFetchPriority = "has fetch priority";
195
+
191
196
  /**
192
197
  * the chunk name of the chunk with the runtime
193
198
  */
@@ -377,9 +377,10 @@ class RuntimePlugin {
377
377
  if (withCreateScriptUrl) {
378
378
  set.add(RuntimeGlobals.createScriptUrl);
379
379
  }
380
+ const withFetchPriority = set.has(RuntimeGlobals.hasFetchPriority);
380
381
  compilation.addRuntimeModule(
381
382
  chunk,
382
- new LoadScriptRuntimeModule(withCreateScriptUrl)
383
+ new LoadScriptRuntimeModule(withCreateScriptUrl, withFetchPriority)
383
384
  );
384
385
  return true;
385
386
  });
@@ -939,11 +939,29 @@ class RuntimeTemplate {
939
939
  if (chunks.length === 1) {
940
940
  const chunkId = JSON.stringify(chunks[0].id);
941
941
  runtimeRequirements.add(RuntimeGlobals.ensureChunk);
942
- return `${RuntimeGlobals.ensureChunk}(${comment}${chunkId})`;
942
+
943
+ const fetchPriority = chunkGroup.options.fetchPriority;
944
+
945
+ if (fetchPriority) {
946
+ runtimeRequirements.add(RuntimeGlobals.hasFetchPriority);
947
+ }
948
+
949
+ return `${RuntimeGlobals.ensureChunk}(${comment}${chunkId}${
950
+ fetchPriority ? `, ${JSON.stringify(fetchPriority)}` : ""
951
+ })`;
943
952
  } else if (chunks.length > 0) {
944
953
  runtimeRequirements.add(RuntimeGlobals.ensureChunk);
954
+
955
+ const fetchPriority = chunkGroup.options.fetchPriority;
956
+
957
+ if (fetchPriority) {
958
+ runtimeRequirements.add(RuntimeGlobals.hasFetchPriority);
959
+ }
960
+
945
961
  const requireChunkId = chunk =>
946
- `${RuntimeGlobals.ensureChunk}(${JSON.stringify(chunk.id)})`;
962
+ `${RuntimeGlobals.ensureChunk}(${JSON.stringify(chunk.id)}${
963
+ fetchPriority ? `, ${JSON.stringify(fetchPriority)}` : ""
964
+ })`;
947
965
  return `Promise.all(${comment.trim()}[${chunks
948
966
  .map(requireChunkId)
949
967
  .join(", ")}])`;
@@ -22,16 +22,17 @@ class WebpackError extends Error {
22
22
  constructor(message) {
23
23
  super(message);
24
24
 
25
+ /** @type {string | undefined} */
25
26
  this.details = undefined;
26
- /** @type {Module} */
27
+ /** @type {Module | undefined | null} */
27
28
  this.module = undefined;
28
- /** @type {DependencyLocation} */
29
+ /** @type {DependencyLocation | undefined} */
29
30
  this.loc = undefined;
30
- /** @type {boolean} */
31
+ /** @type {boolean | undefined} */
31
32
  this.hideStack = undefined;
32
- /** @type {Chunk} */
33
+ /** @type {Chunk | undefined} */
33
34
  this.chunk = undefined;
34
- /** @type {string} */
35
+ /** @type {string | undefined} */
35
36
  this.file = undefined;
36
37
  }
37
38
 
@@ -566,7 +566,7 @@ class WebpackOptionsApply extends OptionsApply {
566
566
  for (const minimizer of options.optimization.minimizer) {
567
567
  if (typeof minimizer === "function") {
568
568
  minimizer.call(compiler, compiler);
569
- } else if (minimizer !== "...") {
569
+ } else if (minimizer !== "..." && minimizer) {
570
570
  minimizer.apply(compiler);
571
571
  }
572
572
  }
@@ -8,11 +8,18 @@
8
8
  const { applyWebpackOptionsDefaults } = require("./config/defaults");
9
9
  const { getNormalizedWebpackOptions } = require("./config/normalization");
10
10
 
11
+ /** @typedef {import("./config/normalization").WebpackOptions} WebpackOptions */
12
+ /** @typedef {import("./config/normalization").WebpackOptionsNormalized} WebpackOptionsNormalized */
13
+
11
14
  class WebpackOptionsDefaulter {
15
+ /**
16
+ * @param {WebpackOptions} options webpack options
17
+ * @returns {WebpackOptionsNormalized} normalized webpack options
18
+ */
12
19
  process(options) {
13
- options = getNormalizedWebpackOptions(options);
14
- applyWebpackOptionsDefaults(options);
15
- return options;
20
+ const normalizedOptions = getNormalizedWebpackOptions(options);
21
+ applyWebpackOptionsDefaults(normalizedOptions);
22
+ return normalizedOptions;
16
23
  }
17
24
  }
18
25
 
@@ -298,7 +298,10 @@ const applyWebpackOptionsDefaults = options => {
298
298
  cache,
299
299
  context: /** @type {Context} */ (options.context),
300
300
  targetProperties,
301
- mode: /** @type {Mode} */ (options.mode)
301
+ mode: /** @type {Mode} */ (options.mode),
302
+ css:
303
+ /** @type {NonNullable<ExperimentsNormalized["css"]>} */
304
+ (options.experiments.css)
302
305
  }),
303
306
  options.resolve
304
307
  );
@@ -533,6 +536,7 @@ const applyJavascriptParserOptionsDefaults = (
533
536
  D(parserOptions, "dynamicImportMode", "lazy");
534
537
  D(parserOptions, "dynamicImportPrefetch", false);
535
538
  D(parserOptions, "dynamicImportPreload", false);
539
+ D(parserOptions, "dynamicImportFetchPriority", false);
536
540
  D(parserOptions, "createRequire", isNode);
537
541
  if (futureDefaults) D(parserOptions, "exportsPresence", "error");
538
542
  };
@@ -1398,9 +1402,16 @@ const applyOptimizationDefaults = (
1398
1402
  * @param {string} options.context build context
1399
1403
  * @param {TargetProperties | false} options.targetProperties target properties
1400
1404
  * @param {Mode} options.mode mode
1405
+ * @param {CssExperimentOptions|false} options.css is css enabled
1401
1406
  * @returns {ResolveOptions} resolve options
1402
1407
  */
1403
- const getResolveDefaults = ({ cache, context, targetProperties, mode }) => {
1408
+ const getResolveDefaults = ({
1409
+ cache,
1410
+ context,
1411
+ targetProperties,
1412
+ mode,
1413
+ css
1414
+ }) => {
1404
1415
  /** @type {string[]} */
1405
1416
  const conditions = ["webpack"];
1406
1417
 
@@ -1468,6 +1479,24 @@ const getResolveDefaults = ({ cache, context, targetProperties, mode }) => {
1468
1479
  }
1469
1480
  };
1470
1481
 
1482
+ if (css) {
1483
+ const styleConditions = [];
1484
+
1485
+ styleConditions.push("webpack");
1486
+ styleConditions.push(mode === "development" ? "development" : "production");
1487
+ styleConditions.push("style");
1488
+
1489
+ resolveOptions.byDependency["css-import"] = {
1490
+ // We avoid using any main files because we have to be consistent with CSS `@import`
1491
+ // and CSS `@import` does not handle `main` files in directories,
1492
+ // you should always specify the full URL for styles
1493
+ mainFiles: [],
1494
+ mainFields: ["style", "..."],
1495
+ conditionNames: styleConditions,
1496
+ extensions: [".css"]
1497
+ };
1498
+ }
1499
+
1471
1500
  return resolveOptions;
1472
1501
  };
1473
1502
 
@@ -11,7 +11,8 @@ const HotUpdateChunk = require("../HotUpdateChunk");
11
11
  const {
12
12
  CSS_MODULE_TYPE,
13
13
  CSS_MODULE_TYPE_GLOBAL,
14
- CSS_MODULE_TYPE_MODULE
14
+ CSS_MODULE_TYPE_MODULE,
15
+ CSS_MODULE_TYPE_AUTO
15
16
  } = require("../ModuleTypeConstants");
16
17
  const RuntimeGlobals = require("../RuntimeGlobals");
17
18
  const SelfModuleFactory = require("../SelfModuleFactory");
@@ -149,7 +150,8 @@ class CssModulesPlugin {
149
150
  for (const type of [
150
151
  CSS_MODULE_TYPE,
151
152
  CSS_MODULE_TYPE_GLOBAL,
152
- CSS_MODULE_TYPE_MODULE
153
+ CSS_MODULE_TYPE_MODULE,
154
+ CSS_MODULE_TYPE_AUTO
153
155
  ]) {
154
156
  normalModuleFactory.hooks.createParser
155
157
  .for(type)
@@ -158,6 +160,7 @@ class CssModulesPlugin {
158
160
 
159
161
  switch (type) {
160
162
  case CSS_MODULE_TYPE:
163
+ case CSS_MODULE_TYPE_AUTO:
161
164
  return new CssParser();
162
165
  case CSS_MODULE_TYPE_GLOBAL:
163
166
  return new CssParser({
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const ModuleDependencyWarning = require("../ModuleDependencyWarning");
9
+ const { CSS_MODULE_TYPE_AUTO } = require("../ModuleTypeConstants");
9
10
  const Parser = require("../Parser");
10
11
  const WebpackError = require("../WebpackError");
11
12
  const ConstDependency = require("../dependencies/ConstDependency");
@@ -15,6 +16,7 @@ const CssLocalIdentifierDependency = require("../dependencies/CssLocalIdentifier
15
16
  const CssSelfLocalIdentifierDependency = require("../dependencies/CssSelfLocalIdentifierDependency");
16
17
  const CssUrlDependency = require("../dependencies/CssUrlDependency");
17
18
  const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
19
+ const { parseResource } = require("../util/identifier");
18
20
  const walkCssTokens = require("./walkCssTokens");
19
21
 
20
22
  /** @typedef {import("../Parser").ParserState} ParserState */
@@ -37,6 +39,7 @@ const IMAGE_SET_FUNCTION = /^(-\w+-)?image-set$/i;
37
39
  const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(-\w+-)?keyframes$/;
38
40
  const OPTIONALLY_VENDOR_PREFIXED_ANIMATION_PROPERTY =
39
41
  /^(-\w+-)?animation(-name)?$/i;
42
+ const IS_MODULES = /\.module(s)?\.\w+$/i;
40
43
 
41
44
  /**
42
45
  * @param {string} str url string
@@ -169,6 +172,15 @@ class CssParser extends Parser {
169
172
  }
170
173
 
171
174
  const module = state.module;
175
+ if (
176
+ module.type === CSS_MODULE_TYPE_AUTO &&
177
+ IS_MODULES.test(
178
+ parseResource(module.matchResource || module.resource).path
179
+ )
180
+ ) {
181
+ this.defaultMode = "local";
182
+ }
183
+
172
184
  const locConverter = new LocConverter(source);
173
185
  /** @type {Set<string>}*/
174
186
  const declaredCssVariables = new Set();
@@ -23,8 +23,8 @@ const NullDependency = require("./NullDependency");
23
23
  class ConstDependency extends NullDependency {
24
24
  /**
25
25
  * @param {string} expression the expression
26
- * @param {number|Range} range the source range
27
- * @param {string[]=} runtimeRequirements runtime requirements
26
+ * @param {number | Range} range the source range
27
+ * @param {(string[] | null)=} runtimeRequirements runtime requirements
28
28
  */
29
29
  constructor(expression, range, runtimeRequirements) {
30
30
  super();
@@ -219,6 +219,25 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
219
219
  }
220
220
  break;
221
221
  }
222
+ case "fetchPriority": {
223
+ const expr = parser.evaluateExpression(
224
+ /** @type {Expression} */ (prop.value)
225
+ );
226
+ if (
227
+ expr.isString() &&
228
+ ["high", "low", "auto"].includes(expr.string)
229
+ ) {
230
+ groupOptions.fetchPriority =
231
+ /** @type {RawChunkGroupOptions["fetchPriority"]} */ (
232
+ expr.string
233
+ );
234
+ } else {
235
+ errors.push(
236
+ createPropertyParseError(prop, '"high"|"low"|"auto"')
237
+ );
238
+ }
239
+ break;
240
+ }
222
241
  case "recursive": {
223
242
  const recursiveExpr = parser.evaluateExpression(
224
243
  /** @type {Expression} */ (prop.value)
@@ -47,7 +47,11 @@ class ImportParserPlugin {
47
47
  /** @type {RawChunkGroupOptions} */
48
48
  const groupOptions = {};
49
49
 
50
- const { dynamicImportPreload, dynamicImportPrefetch } = this.options;
50
+ const {
51
+ dynamicImportPreload,
52
+ dynamicImportPrefetch,
53
+ dynamicImportFetchPriority
54
+ } = this.options;
51
55
  if (dynamicImportPreload !== undefined && dynamicImportPreload !== false)
52
56
  groupOptions.preloadOrder =
53
57
  dynamicImportPreload === true ? 0 : dynamicImportPreload;
@@ -57,6 +61,11 @@ class ImportParserPlugin {
57
61
  )
58
62
  groupOptions.prefetchOrder =
59
63
  dynamicImportPrefetch === true ? 0 : dynamicImportPrefetch;
64
+ if (
65
+ dynamicImportFetchPriority !== undefined &&
66
+ dynamicImportFetchPriority !== false
67
+ )
68
+ groupOptions.fetchPriority = dynamicImportFetchPriority;
60
69
 
61
70
  const { options: importOptions, errors: commentErrors } =
62
71
  parser.parseCommentOptions(expr.range);
@@ -141,6 +150,21 @@ class ImportParserPlugin {
141
150
  );
142
151
  }
143
152
  }
153
+ if (importOptions.webpackFetchPriority !== undefined) {
154
+ if (
155
+ typeof importOptions.webpackFetchPriority === "string" &&
156
+ ["high", "low", "auto"].includes(importOptions.webpackFetchPriority)
157
+ ) {
158
+ groupOptions.fetchPriority = importOptions.webpackFetchPriority;
159
+ } else {
160
+ parser.state.module.addWarning(
161
+ new UnsupportedFeatureWarning(
162
+ `\`webpackFetchPriority\` expected true or "low", "high" or "auto", but received: ${importOptions.webpackFetchPriority}.`,
163
+ expr.loc
164
+ )
165
+ );
166
+ }
167
+ }
144
168
  if (importOptions.webpackInclude !== undefined) {
145
169
  if (
146
170
  !importOptions.webpackInclude ||
@@ -63,6 +63,7 @@ class SyncModuleIdsPlugin {
63
63
  if (this._write) {
64
64
  compiler.hooks.emitRecords.tapAsync(plugin, callback => {
65
65
  if (!data || !dataChanged) return callback();
66
+ /** @type {Object<string, string | number>} */
66
67
  const json = {};
67
68
  const sorted = Array.from(data).sort(([a], [b]) => (a < b ? -1 : 1));
68
69
  for (const [key, value] of sorted) {
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- /** @typedef {import("estree").Node} EsTreeNode */
8
+ /** @typedef {import("estree").Node} Node */
9
9
  /** @typedef {import("./JavascriptParser").Range} Range */
10
10
  /** @typedef {import("./JavascriptParser").VariableInfoInterface} VariableInfoInterface */
11
11
 
@@ -27,7 +27,7 @@ const TypeBigInt = 13;
27
27
  class BasicEvaluatedExpression {
28
28
  constructor() {
29
29
  this.type = TypeUnknown;
30
- /** @type {[number, number]} */
30
+ /** @type {[number, number] | undefined} */
31
31
  this.range = undefined;
32
32
  /** @type {boolean} */
33
33
  this.falsy = false;
@@ -57,23 +57,23 @@ class BasicEvaluatedExpression {
57
57
  this.items = undefined;
58
58
  /** @type {BasicEvaluatedExpression[] | undefined} */
59
59
  this.options = undefined;
60
- /** @type {BasicEvaluatedExpression | undefined} */
60
+ /** @type {BasicEvaluatedExpression | undefined | null} */
61
61
  this.prefix = undefined;
62
- /** @type {BasicEvaluatedExpression | undefined} */
62
+ /** @type {BasicEvaluatedExpression | undefined | null} */
63
63
  this.postfix = undefined;
64
- /** @type {BasicEvaluatedExpression[]} */
64
+ /** @type {BasicEvaluatedExpression[] | undefined} */
65
65
  this.wrappedInnerExpressions = undefined;
66
66
  /** @type {string | VariableInfoInterface | undefined} */
67
67
  this.identifier = undefined;
68
- /** @type {string | VariableInfoInterface} */
68
+ /** @type {string | VariableInfoInterface | undefined} */
69
69
  this.rootInfo = undefined;
70
- /** @type {() => string[]} */
70
+ /** @type {(() => string[]) | undefined} */
71
71
  this.getMembers = undefined;
72
- /** @type {() => boolean[]} */
72
+ /** @type {(() => boolean[]) | undefined} */
73
73
  this.getMembersOptionals = undefined;
74
- /** @type {() => Range[]} */
74
+ /** @type {(() => Range[]) | undefined} */
75
75
  this.getMemberRanges = undefined;
76
- /** @type {EsTreeNode} */
76
+ /** @type {Node | undefined} */
77
77
  this.expression = undefined;
78
78
  }
79
79
 
@@ -293,7 +293,9 @@ class BasicEvaluatedExpression {
293
293
  if (this.isRegExp()) return `${this.regExp}`;
294
294
  if (this.isArray()) {
295
295
  let array = [];
296
- for (const item of this.items) {
296
+ for (const item of /** @type {BasicEvaluatedExpression[]} */ (
297
+ this.items
298
+ )) {
297
299
  const itemStr = item.asString();
298
300
  if (itemStr === undefined) return undefined;
299
301
  array.push(itemStr);
@@ -303,7 +305,9 @@ class BasicEvaluatedExpression {
303
305
  if (this.isConstArray()) return `${this.array}`;
304
306
  if (this.isTemplateString()) {
305
307
  let str = "";
306
- for (const part of this.parts) {
308
+ for (const part of /** @type {BasicEvaluatedExpression[]} */ (
309
+ this.parts
310
+ )) {
307
311
  const partStr = part.asString();
308
312
  if (partStr === undefined) return undefined;
309
313
  str += partStr;
@@ -313,6 +317,10 @@ class BasicEvaluatedExpression {
313
317
  return undefined;
314
318
  }
315
319
 
320
+ /**
321
+ * @param {string} string value
322
+ * @returns {BasicEvaluatedExpression} basic evaluated expression
323
+ */
316
324
  setString(string) {
317
325
  this.type = TypeString;
318
326
  this.string = string;
@@ -410,8 +418,8 @@ class BasicEvaluatedExpression {
410
418
  /**
411
419
  * Wraps an array of expressions with a prefix and postfix expression.
412
420
  *
413
- * @param {BasicEvaluatedExpression | null} prefix Expression to be added before the innerExpressions
414
- * @param {BasicEvaluatedExpression} postfix Expression to be added after the innerExpressions
421
+ * @param {BasicEvaluatedExpression | null | undefined} prefix Expression to be added before the innerExpressions
422
+ * @param {BasicEvaluatedExpression | null | undefined} postfix Expression to be added after the innerExpressions
415
423
  * @param {BasicEvaluatedExpression[]} innerExpressions Expressions to be wrapped
416
424
  * @returns {this} this
417
425
  */
@@ -551,7 +559,7 @@ class BasicEvaluatedExpression {
551
559
  /**
552
560
  * Set the expression node for the expression.
553
561
  *
554
- * @param {EsTreeNode} expression expression
562
+ * @param {Node | undefined} expression expression
555
563
  * @returns {this} this
556
564
  */
557
565
  setExpression(expression) {
@@ -17,7 +17,9 @@ const {
17
17
  updateHashForEntryStartup
18
18
  } = require("./StartupHelpers");
19
19
 
20
+ /** @typedef {import("../Chunk")} Chunk */
20
21
  /** @typedef {import("../Compiler")} Compiler */
22
+ /** @typedef {import("../Entrypoint")} Entrypoint */
21
23
 
22
24
  class CommonJsChunkFormatPlugin {
23
25
  /**
@@ -66,7 +68,9 @@ class CommonJsChunkFormatPlugin {
66
68
  chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
67
69
  );
68
70
  if (entries.length > 0) {
69
- const runtimeChunk = entries[0][1].getRuntimeChunk();
71
+ const runtimeChunk =
72
+ /** @type {Entrypoint} */
73
+ (entries[0][1]).getRuntimeChunk();
70
74
  const currentOutputName = compilation
71
75
  .getPath(
72
76
  getChunkFilenameTemplate(chunk, compilation.outputOptions),
@@ -83,7 +87,7 @@ class CommonJsChunkFormatPlugin {
83
87
  compilation.outputOptions
84
88
  ),
85
89
  {
86
- chunk: runtimeChunk,
90
+ chunk: /** @type {Chunk} */ (runtimeChunk),
87
91
  contentHashType: "javascript"
88
92
  }
89
93
  )