webpack 5.108.2 → 5.108.3

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.
@@ -19,8 +19,6 @@ const NullDependency = require("./NullDependency");
19
19
  /** @typedef {import("./HarmonyAcceptImportDependency")} HarmonyAcceptImportDependency */
20
20
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[Range, HarmonyAcceptImportDependency[], boolean]>} ObjectDeserializerContext */
21
21
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[Range, HarmonyAcceptImportDependency[], boolean]>} ObjectSerializerContext */
22
- /** @typedef {import("../Module")} Module */
23
- /** @typedef {import("../Module").ModuleId} ModuleId */
24
22
 
25
23
  class HarmonyAcceptDependency extends NullDependency {
26
24
  /**
@@ -91,26 +89,20 @@ HarmonyAcceptDependency.Template = class HarmonyAcceptDependencyTemplate extends
91
89
  chunkGraph
92
90
  } = templateContext;
93
91
 
94
- /**
95
- * Gets dependency module id.
96
- * @param {Dependency} dependency the dependency to get module id for
97
- * @returns {ModuleId | null} the module id or null if not found
98
- */
99
- const getDependencyModuleId = (dependency) =>
100
- chunkGraph.getModuleId(
101
- /** @type {Module} */ (moduleGraph.getModule(dependency))
102
- );
103
-
104
92
  /**
105
93
  * Checks whether this harmony accept dependency is related harmony import dependency.
106
94
  * @param {Dependency} a the first dependency
107
95
  * @param {Dependency} b the second dependency
108
96
  * @returns {boolean} true if the dependencies are related
109
97
  */
110
- const isRelatedHarmonyImportDependency = (a, b) =>
111
- a !== b &&
112
- b instanceof HarmonyImportDependency &&
113
- getDependencyModuleId(a) === getDependencyModuleId(b);
98
+ const isRelatedHarmonyImportDependency = (a, b) => {
99
+ if (a === b || !(b instanceof HarmonyImportDependency)) return false;
100
+ // Compare modules by reference: an unresolved import (ignored/failed, or a
101
+ // deferred lazy-barrel re-export) has no module, and a module not in any
102
+ // chunk has a null id — so comparing ids would crash or miss real matches.
103
+ const moduleA = moduleGraph.getModule(a);
104
+ return moduleA !== null && moduleA === moduleGraph.getModule(b);
105
+ };
114
106
 
115
107
  /**
116
108
  * HarmonyAcceptImportDependency lacks a lot of information, such as the defer property.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.108.2",
3
+ "version": "5.108.3",
4
4
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
5
5
  "homepage": "https://github.com/webpack/webpack",
6
6
  "bugs": "https://github.com/webpack/webpack/issues",