webpack 5.62.1 → 5.62.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

@@ -2424,9 +2424,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2424
2424
  let statNew = 0;
2425
2425
  /**
2426
2426
  * @param {Module} module module
2427
- * @returns {{ modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[] }} references
2427
+ * @returns {{ id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[] }} references
2428
2428
  */
2429
2429
  const computeReferences = module => {
2430
+ const id = chunkGraph.getModuleId(module);
2430
2431
  /** @type {Map<Module, string | number | undefined>} */
2431
2432
  let modules = undefined;
2432
2433
  /** @type {(string | number)[] | undefined} */
@@ -2454,16 +2455,18 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2454
2455
  queue.push.apply(queue, block.blocks);
2455
2456
  }
2456
2457
  }
2457
- return { modules, blocks };
2458
+ return { id, modules, blocks };
2458
2459
  };
2459
2460
  /**
2460
2461
  * @param {Module} module module
2461
2462
  * @param {Object} references references
2463
+ * @param {string | number} references.id id
2462
2464
  * @param {Map<Module, string | number>=} references.modules modules
2463
2465
  * @param {(string | number)[]=} references.blocks blocks
2464
2466
  * @returns {boolean} ok?
2465
2467
  */
2466
- const compareReferences = (module, { modules, blocks }) => {
2468
+ const compareReferences = (module, { id, modules, blocks }) => {
2469
+ if (id !== chunkGraph.getModuleId(module)) return false;
2467
2470
  if (modules !== undefined) {
2468
2471
  for (const [module, id] of modules) {
2469
2472
  if (chunkGraph.getModuleId(module) !== id) return false;
@@ -2489,7 +2492,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2489
2492
  };
2490
2493
 
2491
2494
  for (const [module, memCache] of moduleMemCaches) {
2492
- /** @type {{ references: { modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[]}, memCache: WeakTupleMap<any[], any> }} */
2495
+ /** @type {{ references: { id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[]}, memCache: WeakTupleMap<any[], any> }} */
2493
2496
  const cache = memCache.get(key);
2494
2497
  if (cache === undefined) {
2495
2498
  const memCache2 = new WeakTupleMap();
@@ -218,7 +218,15 @@ class RuntimePlugin {
218
218
  compilation.hooks.runtimeRequirementInTree
219
219
  .for(RuntimeGlobals.systemContext)
220
220
  .tap("RuntimePlugin", chunk => {
221
- if (compilation.outputOptions.library.type === "system") {
221
+ const { outputOptions } = compilation;
222
+ const { library: globalLibrary } = outputOptions;
223
+ const entryOptions = chunk.getEntryOptions();
224
+ const libraryType =
225
+ entryOptions && entryOptions.library !== undefined
226
+ ? entryOptions.library.type
227
+ : globalLibrary.type;
228
+
229
+ if (libraryType === "system") {
222
230
  compilation.addRuntimeModule(
223
231
  chunk,
224
232
  new SystemContextRuntimeModule()
@@ -183,7 +183,8 @@ const applyWebpackOptionsDefaults = options => {
183
183
  applyModuleDefaults(options.module, {
184
184
  cache,
185
185
  syncWebAssembly: options.experiments.syncWebAssembly,
186
- asyncWebAssembly: options.experiments.asyncWebAssembly
186
+ asyncWebAssembly: options.experiments.asyncWebAssembly,
187
+ futureDefaults
187
188
  });
188
189
 
189
190
  applyOutputDefaults(options.output, {
@@ -428,9 +429,14 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
428
429
 
429
430
  /**
430
431
  * @param {JavascriptParserOptions} parserOptions parser options
432
+ * @param {Object} options options
433
+ * @param {boolean} options.futureDefaults is future defaults enabled
431
434
  * @returns {void}
432
435
  */
433
- const applyJavascriptParserOptionsDefaults = parserOptions => {
436
+ const applyJavascriptParserOptionsDefaults = (
437
+ parserOptions,
438
+ { futureDefaults }
439
+ ) => {
434
440
  D(parserOptions, "unknownContextRequest", ".");
435
441
  D(parserOptions, "unknownContextRegExp", false);
436
442
  D(parserOptions, "unknownContextRecursive", true);
@@ -443,6 +449,7 @@ const applyJavascriptParserOptionsDefaults = parserOptions => {
443
449
  D(parserOptions, "wrappedContextRecursive", true);
444
450
  D(parserOptions, "wrappedContextCritical", false);
445
451
  D(parserOptions, "strictThisContextOnImports", false);
452
+ if (futureDefaults) D(parserOptions, "exportsPresence", "error");
446
453
  };
447
454
 
448
455
  /**
@@ -451,11 +458,12 @@ const applyJavascriptParserOptionsDefaults = parserOptions => {
451
458
  * @param {boolean} options.cache is caching enabled
452
459
  * @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
453
460
  * @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
461
+ * @param {boolean} options.futureDefaults is future defaults enabled
454
462
  * @returns {void}
455
463
  */
456
464
  const applyModuleDefaults = (
457
465
  module,
458
- { cache, syncWebAssembly, asyncWebAssembly }
466
+ { cache, syncWebAssembly, asyncWebAssembly, futureDefaults }
459
467
  ) => {
460
468
  if (cache) {
461
469
  D(module, "unsafeCache", module => {
@@ -473,7 +481,9 @@ const applyModuleDefaults = (
473
481
  }
474
482
 
475
483
  F(module.parser, "javascript", () => ({}));
476
- applyJavascriptParserOptionsDefaults(module.parser.javascript);
484
+ applyJavascriptParserOptionsDefaults(module.parser.javascript, {
485
+ futureDefaults
486
+ });
477
487
 
478
488
  A(module, "defaultRules", () => {
479
489
  const esm = {
@@ -229,6 +229,7 @@ const getNormalizedWebpackOptions = config => {
229
229
  wrappedContextRegExp: module.wrappedContextRegExp,
230
230
  wrappedContextRecursive: module.wrappedContextRecursive,
231
231
  wrappedContextCritical: module.wrappedContextCritical,
232
+ // TODO webpack 6 remove
232
233
  strictExportPresence: module.strictExportPresence,
233
234
  strictThisContextOnImports: module.strictThisContextOnImports,
234
235
  ...parserOptions
@@ -23,10 +23,10 @@ const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency;
23
23
  module.exports = class HarmonyExportDependencyParserPlugin {
24
24
  constructor(options) {
25
25
  this.exportPresenceMode =
26
- options.reexportExportPresence !== undefined
27
- ? ExportPresenceModes.fromUserOption(options.reexportExportPresence)
28
- : options.exportPresence !== undefined
29
- ? ExportPresenceModes.fromUserOption(options.exportPresence)
26
+ options.reexportExportsPresence !== undefined
27
+ ? ExportPresenceModes.fromUserOption(options.reexportExportsPresence)
28
+ : options.exportsPresence !== undefined
29
+ ? ExportPresenceModes.fromUserOption(options.exportsPresence)
30
30
  : options.strictExportPresence
31
31
  ? ExportPresenceModes.ERROR
32
32
  : ExportPresenceModes.AUTO;
@@ -755,8 +755,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
755
755
  * @returns {WebpackError[]} warnings
756
756
  */
757
757
  getWarnings(moduleGraph) {
758
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
759
- if (exportPresence === ExportPresenceModes.WARN) {
758
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
759
+ if (exportsPresence === ExportPresenceModes.WARN) {
760
760
  return this._getErrors(moduleGraph);
761
761
  }
762
762
  return null;
@@ -768,8 +768,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
768
768
  * @returns {WebpackError[]} errors
769
769
  */
770
770
  getErrors(moduleGraph) {
771
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
772
- if (exportPresence === ExportPresenceModes.ERROR) {
771
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
772
+ if (exportsPresence === ExportPresenceModes.ERROR) {
773
773
  return this._getErrors(moduleGraph);
774
774
  }
775
775
  return null;
@@ -38,6 +38,8 @@ const ExportPresenceModes = {
38
38
  return ExportPresenceModes.ERROR;
39
39
  case "warn":
40
40
  return ExportPresenceModes.WARN;
41
+ case "auto":
42
+ return ExportPresenceModes.AUTO;
41
43
  case false:
42
44
  return ExportPresenceModes.NONE;
43
45
  default:
@@ -67,10 +67,10 @@ module.exports = class HarmonyImportDependencyParserPlugin {
67
67
  */
68
68
  constructor(options) {
69
69
  this.exportPresenceMode =
70
- options.importExportPresence !== undefined
71
- ? ExportPresenceModes.fromUserOption(options.importExportPresence)
72
- : options.exportPresence !== undefined
73
- ? ExportPresenceModes.fromUserOption(options.exportPresence)
70
+ options.importExportsPresence !== undefined
71
+ ? ExportPresenceModes.fromUserOption(options.importExportsPresence)
72
+ : options.exportsPresence !== undefined
73
+ ? ExportPresenceModes.fromUserOption(options.exportsPresence)
74
74
  : options.strictExportPresence
75
75
  ? ExportPresenceModes.ERROR
76
76
  : ExportPresenceModes.AUTO;
@@ -173,8 +173,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
173
173
  * @returns {WebpackError[]} warnings
174
174
  */
175
175
  getWarnings(moduleGraph) {
176
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
177
- if (exportPresence === ExportPresenceModes.WARN) {
176
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
177
+ if (exportsPresence === ExportPresenceModes.WARN) {
178
178
  return this._getErrors(moduleGraph);
179
179
  }
180
180
  return null;
@@ -186,8 +186,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
186
186
  * @returns {WebpackError[]} errors
187
187
  */
188
188
  getErrors(moduleGraph) {
189
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
190
- if (exportPresence === ExportPresenceModes.ERROR) {
189
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
190
+ if (exportsPresence === ExportPresenceModes.ERROR) {
191
191
  return this._getErrors(moduleGraph);
192
192
  }
193
193
  return null;
@@ -1160,7 +1160,7 @@ const AVAILABLE_FORMATS = {
1160
1160
  },
1161
1161
  { regExp: /(\(module has no exports\))/g, format: red },
1162
1162
  { regExp: /\(possible exports: (.+)\)/g, format: green },
1163
- { regExp: /\s*(.+ doesn't exist)/g, format: red },
1163
+ { regExp: /\s*([^\s].* doesn't exist)/g, format: red },
1164
1164
  { regExp: /('\w+' option has not been set)/g, format: red },
1165
1165
  {
1166
1166
  regExp: /(Emitted value instead of an instance of Error)/g,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.62.1",
3
+ "version": "5.62.2",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",