webpack 5.104.1 → 5.105.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 (323) hide show
  1. package/README.md +2 -2
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +85 -15
  4. package/lib/AbstractMethodError.js +1 -0
  5. package/lib/AsyncDependenciesBlock.js +17 -2
  6. package/lib/AsyncDependencyToInitialChunkError.js +3 -0
  7. package/lib/AutomaticPrefetchPlugin.js +1 -1
  8. package/lib/BannerPlugin.js +5 -1
  9. package/lib/CacheFacade.js +2 -2
  10. package/lib/CaseSensitiveModulesWarning.js +1 -0
  11. package/lib/Chunk.js +9 -5
  12. package/lib/ChunkGraph.js +30 -9
  13. package/lib/ChunkGroup.js +6 -3
  14. package/lib/ChunkRenderError.js +9 -2
  15. package/lib/CleanPlugin.js +4 -1
  16. package/lib/CodeGenerationError.js +7 -1
  17. package/lib/CodeGenerationResults.js +10 -3
  18. package/lib/CommentCompilationWarning.js +2 -1
  19. package/lib/Compilation.js +284 -236
  20. package/lib/Compiler.js +4 -3
  21. package/lib/ConcatenationScope.js +2 -1
  22. package/lib/ConcurrentCompilationError.js +3 -3
  23. package/lib/ContextModule.js +248 -111
  24. package/lib/ContextModuleFactory.js +14 -2
  25. package/lib/DefinePlugin.js +15 -8
  26. package/lib/DelegatedModule.js +6 -0
  27. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  28. package/lib/Dependency.js +6 -1
  29. package/lib/DependencyTemplates.js +3 -2
  30. package/lib/DllModule.js +2 -0
  31. package/lib/DllReferencePlugin.js +1 -0
  32. package/lib/DotenvPlugin.js +11 -5
  33. package/lib/DynamicEntryPlugin.js +8 -1
  34. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  35. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  36. package/lib/ExportsInfo.js +8 -4
  37. package/lib/ExternalModule.js +16 -0
  38. package/lib/ExternalModuleFactoryPlugin.js +9 -2
  39. package/lib/ExternalsPlugin.js +2 -1
  40. package/lib/FalseIIFEUmdWarning.js +1 -0
  41. package/lib/FileSystemInfo.js +49 -25
  42. package/lib/FlagDependencyExportsPlugin.js +8 -1
  43. package/lib/FlagDependencyUsagePlugin.js +9 -7
  44. package/lib/HarmonyLinkingError.js +1 -0
  45. package/lib/HookWebpackError.js +2 -0
  46. package/lib/HotModuleReplacementPlugin.js +16 -2
  47. package/lib/IgnoreWarningsPlugin.js +5 -2
  48. package/lib/InitFragment.js +1 -0
  49. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  50. package/lib/LibManifestPlugin.js +1 -0
  51. package/lib/ManifestPlugin.js +8 -1
  52. package/lib/Module.js +7 -4
  53. package/lib/ModuleBuildError.js +3 -1
  54. package/lib/ModuleDependencyError.js +1 -0
  55. package/lib/ModuleDependencyWarning.js +1 -0
  56. package/lib/ModuleError.js +4 -1
  57. package/lib/ModuleFilenameHelpers.js +4 -2
  58. package/lib/ModuleGraph.js +3 -0
  59. package/lib/ModuleGraphConnection.js +10 -1
  60. package/lib/ModuleHashingError.js +2 -0
  61. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  62. package/lib/ModuleNotFoundError.js +1 -0
  63. package/lib/ModuleParseError.js +5 -1
  64. package/lib/ModuleProfile.js +1 -1
  65. package/lib/ModuleRestoreError.js +2 -0
  66. package/lib/ModuleSourceTypeConstants.js +1 -11
  67. package/lib/ModuleStoreError.js +2 -0
  68. package/lib/ModuleWarning.js +3 -1
  69. package/lib/MultiCompiler.js +11 -7
  70. package/lib/MultiWatching.js +2 -2
  71. package/lib/NoModeWarning.js +1 -0
  72. package/lib/NodeStuffInWebError.js +1 -0
  73. package/lib/NormalModule.js +28 -5
  74. package/lib/NormalModuleFactory.js +20 -4
  75. package/lib/OptionsApply.js +3 -1
  76. package/lib/ProgressPlugin.js +4 -0
  77. package/lib/RawModule.js +2 -0
  78. package/lib/RuntimeModule.js +10 -0
  79. package/lib/RuntimePlugin.js +7 -9
  80. package/lib/RuntimeTemplate.js +14 -7
  81. package/lib/SourceMapDevToolPlugin.js +30 -23
  82. package/lib/Template.js +10 -5
  83. package/lib/TemplatedPathPlugin.js +4 -2
  84. package/lib/UnhandledSchemeError.js +1 -0
  85. package/lib/UnsupportedFeatureWarning.js +3 -0
  86. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  87. package/lib/WatchIgnorePlugin.js +1 -1
  88. package/lib/Watching.js +5 -0
  89. package/lib/WebpackError.js +4 -0
  90. package/lib/WebpackOptionsApply.js +61 -41
  91. package/lib/asset/AssetBytesGenerator.js +1 -0
  92. package/lib/asset/AssetGenerator.js +18 -3
  93. package/lib/asset/AssetModulesPlugin.js +33 -2
  94. package/lib/asset/AssetParser.js +4 -0
  95. package/lib/asset/AssetSourceGenerator.js +1 -0
  96. package/lib/asset/RawDataUrlModule.js +4 -0
  97. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  98. package/lib/buildChunkGraph.js +31 -2
  99. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  100. package/lib/cache/PackFileCacheStrategy.js +41 -8
  101. package/lib/cache/getLazyHashedEtag.js +13 -4
  102. package/lib/cache/mergeEtags.js +3 -1
  103. package/lib/cli.js +3 -1
  104. package/lib/config/defaults.js +65 -44
  105. package/lib/config/normalization.js +96 -0
  106. package/lib/container/ContainerEntryDependency.js +3 -0
  107. package/lib/container/ContainerEntryModule.js +7 -0
  108. package/lib/container/ContainerExposedDependency.js +1 -0
  109. package/lib/container/FallbackDependency.js +1 -0
  110. package/lib/container/FallbackItemDependency.js +1 -0
  111. package/lib/container/FallbackModule.js +4 -0
  112. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  113. package/lib/container/ModuleFederationPlugin.js +1 -1
  114. package/lib/container/RemoteModule.js +24 -0
  115. package/lib/css/CssGenerator.js +31 -4
  116. package/lib/css/CssModulesPlugin.js +26 -30
  117. package/lib/css/CssParser.js +12 -9
  118. package/lib/debug/ProfilingPlugin.js +1 -0
  119. package/lib/dependencies/AMDDefineDependency.js +3 -1
  120. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  121. package/lib/dependencies/AMDPlugin.js +1 -1
  122. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  123. package/lib/dependencies/CachedConstDependency.js +1 -0
  124. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  125. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  126. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  127. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  128. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  129. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  130. package/lib/dependencies/ConstDependency.js +1 -0
  131. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  132. package/lib/dependencies/ContextElementDependency.js +1 -0
  133. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  134. package/lib/dependencies/CssIcssExportDependency.js +7 -4
  135. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  136. package/lib/dependencies/CssUrlDependency.js +2 -3
  137. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  138. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  139. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  140. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -1
  141. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  142. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  143. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  144. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  145. package/lib/dependencies/HarmonyImportDependency.js +1 -1
  146. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +269 -5
  147. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  148. package/lib/dependencies/ImportDependency.js +1 -0
  149. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  150. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  151. package/lib/dependencies/ImportParserPlugin.js +7 -12
  152. package/lib/dependencies/LoaderPlugin.js +3 -0
  153. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  154. package/lib/dependencies/ModuleDependency.js +1 -0
  155. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  156. package/lib/dependencies/ProvidedDependency.js +1 -0
  157. package/lib/dependencies/RequireContextPlugin.js +1 -0
  158. package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
  159. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  160. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  161. package/lib/dependencies/WorkerDependency.js +9 -3
  162. package/lib/dependencies/WorkerPlugin.js +1 -0
  163. package/lib/dependencies/getFunctionExpression.js +3 -1
  164. package/lib/electron/ElectronTargetPlugin.js +3 -1
  165. package/lib/errors/BuildCycleError.js +4 -1
  166. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  167. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  168. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  169. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  170. package/lib/hmr/lazyCompilationBackend.js +3 -2
  171. package/lib/ids/ChunkModuleIdRangePlugin.js +9 -7
  172. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
  173. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
  174. package/lib/ids/HashedModuleIdsPlugin.js +3 -8
  175. package/lib/ids/IdHelpers.js +10 -8
  176. package/lib/ids/NamedChunkIdsPlugin.js +7 -5
  177. package/lib/ids/NamedModuleIdsPlugin.js +1 -0
  178. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  179. package/lib/ids/OccurrenceModuleIdsPlugin.js +18 -10
  180. package/lib/ids/SyncModuleIdsPlugin.js +30 -20
  181. package/lib/index.js +2 -2
  182. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  183. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  184. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  185. package/lib/javascript/JavascriptParser.js +47 -14
  186. package/lib/json/JsonGenerator.js +1 -0
  187. package/lib/json/JsonParser.js +9 -2
  188. package/lib/library/AbstractLibraryPlugin.js +4 -1
  189. package/lib/library/AmdLibraryPlugin.js +2 -1
  190. package/lib/library/AssignLibraryPlugin.js +6 -2
  191. package/lib/library/EnableLibraryPlugin.js +1 -0
  192. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  193. package/lib/library/JsonpLibraryPlugin.js +1 -1
  194. package/lib/library/ModuleLibraryPlugin.js +130 -13
  195. package/lib/library/SystemLibraryPlugin.js +4 -1
  196. package/lib/library/UmdLibraryPlugin.js +4 -3
  197. package/lib/logging/Logger.js +9 -5
  198. package/lib/logging/createConsoleLogger.js +4 -0
  199. package/lib/logging/truncateArgs.js +1 -1
  200. package/lib/node/CommonJsChunkLoadingPlugin.js +6 -4
  201. package/lib/node/NodeEnvironmentPlugin.js +1 -0
  202. package/lib/node/NodeTargetPlugin.js +10 -1
  203. package/lib/node/NodeTemplatePlugin.js +1 -0
  204. package/lib/node/NodeWatchFileSystem.js +6 -0
  205. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
  206. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  207. package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
  208. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
  209. package/lib/node/nodeConsole.js +18 -1
  210. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  211. package/lib/optimize/AggressiveSplittingPlugin.js +15 -6
  212. package/lib/optimize/ConcatenatedModule.js +33 -19
  213. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  214. package/lib/optimize/InnerGraph.js +5 -3
  215. package/lib/optimize/InnerGraphPlugin.js +25 -25
  216. package/lib/optimize/LimitChunkCountPlugin.js +3 -2
  217. package/lib/optimize/MangleExportsPlugin.js +14 -2
  218. package/lib/optimize/MergeDuplicateChunksPlugin.js +5 -1
  219. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  220. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  221. package/lib/optimize/RealContentHashPlugin.js +37 -27
  222. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  223. package/lib/optimize/RuntimeChunkPlugin.js +3 -5
  224. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  225. package/lib/optimize/SplitChunksPlugin.js +23 -5
  226. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  227. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  228. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  229. package/lib/performance/SizeLimitsPlugin.js +6 -6
  230. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
  231. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
  232. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
  233. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
  234. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  235. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  236. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  237. package/lib/rules/RuleSetCompiler.js +6 -0
  238. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  239. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  240. package/lib/runtime/CompatRuntimeModule.js +1 -0
  241. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  242. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -0
  243. package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
  244. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  245. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  246. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  247. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +16 -32
  248. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  249. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  250. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  251. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  252. package/lib/schemes/HttpUriPlugin.js +39 -20
  253. package/lib/schemes/VirtualUrlPlugin.js +28 -2
  254. package/lib/serialization/BinaryMiddleware.js +4 -0
  255. package/lib/serialization/FileMiddleware.js +9 -4
  256. package/lib/serialization/ObjectMiddleware.js +34 -11
  257. package/lib/serialization/PlainObjectSerializer.js +2 -0
  258. package/lib/sharing/ConsumeSharedModule.js +60 -0
  259. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  260. package/lib/sharing/ProvideSharedModule.js +4 -0
  261. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  262. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  263. package/lib/sharing/utils.js +8 -6
  264. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -12
  265. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  266. package/lib/stats/StatsFactory.js +2 -2
  267. package/lib/url/URLParserPlugin.js +5 -3
  268. package/lib/util/AppendOnlyStackedSet.js +57 -0
  269. package/lib/util/Hash.js +1 -0
  270. package/lib/util/IterableHelpers.js +1 -0
  271. package/lib/util/LazyBucketSortedSet.js +1 -0
  272. package/lib/util/LazySet.js +1 -0
  273. package/lib/util/ParallelismFactorCalculator.js +1 -0
  274. package/lib/util/SortableSet.js +1 -0
  275. package/lib/util/StringXor.js +1 -0
  276. package/lib/util/binarySearchBounds.js +15 -8
  277. package/lib/util/chainedImports.js +1 -1
  278. package/lib/util/cleverMerge.js +6 -1
  279. package/lib/util/comparators.js +21 -1
  280. package/lib/util/compileBooleanMatcher.js +3 -3
  281. package/lib/util/concatenate.js +3 -2
  282. package/lib/util/conventions.js +3 -2
  283. package/lib/util/deterministicGrouping.js +13 -1
  284. package/lib/util/extractSourceMap.js +12 -13
  285. package/lib/util/fs.js +15 -19
  286. package/lib/util/hash/BatchedHash.js +4 -0
  287. package/lib/util/hash/BulkUpdateHash.js +8 -1
  288. package/lib/util/hash/hash-digest.js +1 -0
  289. package/lib/util/hash/wasm-hash.js +18 -2
  290. package/lib/util/identifier.js +7 -2
  291. package/lib/util/magicComment.js +1 -1
  292. package/lib/util/propertyName.js +1 -1
  293. package/lib/util/registerExternalSerializer.js +1 -0
  294. package/lib/util/runtime.js +15 -1
  295. package/lib/util/semver.js +1 -0
  296. package/lib/util/serialization.js +2 -2
  297. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -0
  298. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  299. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  300. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  301. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  302. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  303. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  304. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  305. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  306. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  307. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  308. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  309. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  310. package/lib/webpack.js +16 -4
  311. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  312. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
  313. package/package.json +33 -36
  314. package/schemas/WebpackOptions.check.js +1 -1
  315. package/schemas/WebpackOptions.json +121 -55
  316. package/schemas/plugins/BannerPlugin.json +2 -2
  317. package/schemas/plugins/IgnorePlugin.json +1 -1
  318. package/schemas/plugins/ManifestPlugin.json +3 -3
  319. package/schemas/plugins/ProgressPlugin.json +1 -1
  320. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  321. package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
  322. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  323. package/types.d.ts +440 -137
@@ -53,7 +53,6 @@ class HashedModuleIdsPlugin {
53
53
  * @returns {void}
54
54
  */
55
55
  apply(compiler) {
56
- const options = this.options;
57
56
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
58
57
  compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
59
58
  const chunkGraph = compilation.chunkGraph;
@@ -67,14 +66,10 @@ class HashedModuleIdsPlugin {
67
66
  );
68
67
  for (const module of modulesInNaturalOrder) {
69
68
  const ident = getFullModuleName(module, context, compiler.root);
70
- const hash = createHash(
71
- /** @type {NonNullable<HashedModuleIdsPluginOptions["hashFunction"]>} */ (
72
- options.hashFunction
73
- )
74
- );
69
+ const hash = createHash(this.options.hashFunction);
75
70
  hash.update(ident || "");
76
- const hashId = hash.digest(options.hashDigest);
77
- let len = options.hashDigestLength;
71
+ const hashId = hash.digest(this.options.hashDigest);
72
+ let len = this.options.hashDigestLength;
78
73
  while (usedIds.has(hashId.slice(0, len))) {
79
74
  /** @type {number} */ (len)++;
80
75
  }
@@ -13,14 +13,14 @@ const numberHash = require("../util/numberHash");
13
13
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
14
14
  /** @typedef {import("../Compilation")} Compilation */
15
15
  /** @typedef {import("../Module")} Module */
16
- /** @typedef {typeof import("../util/Hash")} Hash */
16
+ /** @typedef {import("../util/Hash").HashFunction} HashFunction */
17
17
  /** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
18
18
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
19
19
 
20
20
  /**
21
21
  * @param {string} str string to hash
22
22
  * @param {number} len max length of the hash
23
- * @param {string | Hash} hashFunction hash function to use
23
+ * @param {HashFunction} hashFunction hash function to use
24
24
  * @returns {string} hash
25
25
  */
26
26
  const getHash = (str, len, hashFunction) => {
@@ -56,12 +56,12 @@ const avoidNumber = (str) => {
56
56
  * @returns {string} id representation
57
57
  */
58
58
  const requestToId = (request) =>
59
- request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_");
59
+ request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-z0-9_-])+/gi, "_");
60
60
 
61
61
  /**
62
62
  * @param {string} string the string
63
63
  * @param {string} delimiter separator for string and hash
64
- * @param {string | Hash} hashFunction hash function to use
64
+ * @param {HashFunction} hashFunction hash function to use
65
65
  * @returns {string} string with limited max length to 100 chars
66
66
  */
67
67
  const shortenLongString = (string, delimiter, hashFunction) => {
@@ -95,7 +95,7 @@ const getShortModuleName = (module, context, associatedObjectForCache) => {
95
95
  * @param {string} shortName the short name
96
96
  * @param {Module} module the module
97
97
  * @param {string} context context directory
98
- * @param {string | Hash} hashFunction hash function to use
98
+ * @param {HashFunction} hashFunction hash function to use
99
99
  * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
100
100
  * @returns {string} long module name
101
101
  */
@@ -124,7 +124,7 @@ const getFullModuleName = (module, context, associatedObjectForCache) =>
124
124
  * @param {ChunkGraph} chunkGraph the chunk graph
125
125
  * @param {string} context context directory
126
126
  * @param {string} delimiter delimiter for names
127
- * @param {string | Hash} hashFunction hash function to use
127
+ * @param {HashFunction} hashFunction hash function to use
128
128
  * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
129
129
  * @returns {string} short chunk name
130
130
  */
@@ -152,7 +152,7 @@ const getShortChunkName = (
152
152
  * @param {ChunkGraph} chunkGraph the chunk graph
153
153
  * @param {string} context context directory
154
154
  * @param {string} delimiter delimiter for names
155
- * @param {string | Hash} hashFunction hash function to use
155
+ * @param {HashFunction} hashFunction hash function to use
156
156
  * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
157
157
  * @returns {string} short chunk name
158
158
  */
@@ -231,7 +231,7 @@ const addToMapOfItems = (map, key, value) => {
231
231
  */
232
232
  const getUsedModuleIdsAndModules = (compilation, filter) => {
233
233
  const chunkGraph = compilation.chunkGraph;
234
-
234
+ /** @type {Module[]} */
235
235
  const modules = [];
236
236
 
237
237
  /** @type {UsedModuleIds} */
@@ -402,6 +402,7 @@ const assignDeterministicIds = (
402
402
 
403
403
  for (const item of items) {
404
404
  const ident = getName(item);
405
+ /** @type {number} */
405
406
  let id;
406
407
  let i = salt;
407
408
  do {
@@ -420,6 +421,7 @@ const assignAscendingModuleIds = (usedIds, modules, compilation) => {
420
421
  const chunkGraph = compilation.chunkGraph;
421
422
 
422
423
  let nextId = 0;
424
+ /** @type {(mod: Module) => void} */
423
425
  let assignId;
424
426
  if (usedIds.size > 0) {
425
427
  /**
@@ -28,9 +28,9 @@ class NamedChunkIdsPlugin {
28
28
  /**
29
29
  * @param {NamedChunkIdsPluginOptions=} options options
30
30
  */
31
- constructor(options) {
32
- this.delimiter = (options && options.delimiter) || "-";
33
- this.context = options && options.context;
31
+ constructor(options = {}) {
32
+ /** @type {NamedChunkIdsPluginOptions} */
33
+ this.options = options;
34
34
  }
35
35
 
36
36
  /**
@@ -43,8 +43,10 @@ class NamedChunkIdsPlugin {
43
43
  const hashFunction = compilation.outputOptions.hashFunction;
44
44
  compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
45
45
  const chunkGraph = compilation.chunkGraph;
46
- const context = this.context ? this.context : compiler.context;
47
- const delimiter = this.delimiter;
46
+ const context = this.options.context
47
+ ? this.options.context
48
+ : compiler.context;
49
+ const delimiter = this.options.delimiter || "-";
48
50
 
49
51
  const unnamedChunks = assignNames(
50
52
  [...chunks].filter((chunk) => {
@@ -28,6 +28,7 @@ class NamedModuleIdsPlugin {
28
28
  * @param {NamedModuleIdsPluginOptions=} options options
29
29
  */
30
30
  constructor(options = {}) {
31
+ /** @type {NamedModuleIdsPluginOptions} */
31
32
  this.options = options;
32
33
  }
33
34
 
@@ -30,6 +30,7 @@ class OccurrenceChunkIdsPlugin {
30
30
  */
31
31
  constructor(options = {}) {
32
32
  validate(options);
33
+ /** @type {OccurrenceChunkIdsPluginOptions} */
33
34
  this.options = options;
34
35
  }
35
36
 
@@ -39,7 +40,6 @@ class OccurrenceChunkIdsPlugin {
39
40
  * @returns {void}
40
41
  */
41
42
  apply(compiler) {
42
- const prioritiseInitial = this.options.prioritiseInitial;
43
43
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
44
44
  compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
45
45
  const chunkGraph = compilation.chunkGraph;
@@ -61,7 +61,7 @@ class OccurrenceChunkIdsPlugin {
61
61
 
62
62
  /** @type {Chunk[]} */
63
63
  const chunksInOccurrenceOrder = [...chunks].sort((a, b) => {
64
- if (prioritiseInitial) {
64
+ if (this.options.prioritiseInitial) {
65
65
  const aEntryOccurs =
66
66
  /** @type {number} */
67
67
  (occursInInitialChunksMap.get(a));
@@ -35,6 +35,7 @@ class OccurrenceModuleIdsPlugin {
35
35
  */
36
36
  constructor(options = {}) {
37
37
  validate(options);
38
+ /** @type {OccurrenceModuleIdsPluginOptions} */
38
39
  this.options = options;
39
40
  }
40
41
 
@@ -44,7 +45,6 @@ class OccurrenceModuleIdsPlugin {
44
45
  * @returns {void}
45
46
  */
46
47
  apply(compiler) {
47
- const prioritiseInitial = this.options.prioritiseInitial;
48
48
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
49
49
  const moduleGraph = compilation.moduleGraph;
50
50
 
@@ -54,10 +54,14 @@ class OccurrenceModuleIdsPlugin {
54
54
  const [usedIds, modulesInOccurrenceOrder] =
55
55
  getUsedModuleIdsAndModules(compilation);
56
56
 
57
+ /** @type {Map<Module, number>} */
57
58
  const occursInInitialChunksMap = new Map();
59
+ /** @type {Map<Module, number>} */
58
60
  const occursInAllChunksMap = new Map();
59
61
 
62
+ /** @type {Map<Module, number>} */
60
63
  const initialChunkChunkMap = new Map();
64
+ /** @type {Map<Module, number>} */
61
65
  const entryCountMap = new Map();
62
66
  for (const m of modulesInOccurrenceOrder) {
63
67
  let initial = 0;
@@ -111,12 +115,12 @@ class OccurrenceModuleIdsPlugin {
111
115
  return sum;
112
116
  };
113
117
 
114
- if (prioritiseInitial) {
118
+ if (this.options.prioritiseInitial) {
115
119
  for (const m of modulesInOccurrenceOrder) {
116
120
  const result =
117
121
  countOccursInEntry(m) +
118
- initialChunkChunkMap.get(m) +
119
- entryCountMap.get(m);
122
+ /** @type {number} */ (initialChunkChunkMap.get(m)) +
123
+ /** @type {number} */ (entryCountMap.get(m));
120
124
  occursInInitialChunksMap.set(m, result);
121
125
  }
122
126
  }
@@ -125,7 +129,7 @@ class OccurrenceModuleIdsPlugin {
125
129
  const result =
126
130
  countOccurs(m) +
127
131
  chunkGraph.getNumberOfModuleChunks(m) +
128
- entryCountMap.get(m);
132
+ /** @type {number} */ (entryCountMap.get(m));
129
133
  occursInAllChunksMap.set(m, result);
130
134
  }
131
135
 
@@ -134,14 +138,18 @@ class OccurrenceModuleIdsPlugin {
134
138
  );
135
139
 
136
140
  modulesInOccurrenceOrder.sort((a, b) => {
137
- if (prioritiseInitial) {
138
- const aEntryOccurs = occursInInitialChunksMap.get(a);
139
- const bEntryOccurs = occursInInitialChunksMap.get(b);
141
+ if (this.options.prioritiseInitial) {
142
+ const aEntryOccurs =
143
+ /** @type {number} */
144
+ (occursInInitialChunksMap.get(a));
145
+ const bEntryOccurs =
146
+ /** @type {number} */
147
+ (occursInInitialChunksMap.get(b));
140
148
  if (aEntryOccurs > bEntryOccurs) return -1;
141
149
  if (aEntryOccurs < bEntryOccurs) return 1;
142
150
  }
143
- const aOccurs = occursInAllChunksMap.get(a);
144
- const bOccurs = occursInAllChunksMap.get(b);
151
+ const aOccurs = /** @type {number} */ (occursInAllChunksMap.get(a));
152
+ const bOccurs = /** @type {number} */ (occursInAllChunksMap.get(b));
145
153
  if (aOccurs > bOccurs) return -1;
146
154
  if (aOccurs < bOccurs) return 1;
147
155
  return naturalCompare(a, b);
@@ -13,6 +13,8 @@ const { getUsedModuleIdsAndModules } = require("./IdHelpers");
13
13
  /** @typedef {import("../Module").ModuleId} ModuleId */
14
14
  /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
15
15
 
16
+ /** @typedef {{ [key: string]: ModuleId }} JSONContent */
17
+
16
18
  const plugin = "SyncModuleIdsPlugin";
17
19
 
18
20
  /**
@@ -27,14 +29,9 @@ class SyncModuleIdsPlugin {
27
29
  /**
28
30
  * @param {SyncModuleIdsPluginOptions} options options
29
31
  */
30
- constructor({ path, context, test, mode }) {
31
- this._path = path;
32
- this._context = context;
33
- this._test = test || (() => true);
34
- const readAndWrite = !mode || mode === "merge" || mode === "update";
35
- this._read = readAndWrite || mode === "read";
36
- this._write = readAndWrite || mode === "create";
37
- this._prune = mode === "update";
32
+ constructor(options) {
33
+ /** @type {SyncModuleIdsPluginOptions} */
34
+ this.options = options;
38
35
  }
39
36
 
40
37
  /**
@@ -46,19 +43,31 @@ class SyncModuleIdsPlugin {
46
43
  /** @type {Map<string, ModuleId>} */
47
44
  let data;
48
45
  let dataChanged = false;
49
- if (this._read) {
46
+
47
+ const readAndWrite =
48
+ !this.options.mode ||
49
+ this.options.mode === "merge" ||
50
+ this.options.mode === "update";
51
+
52
+ const needRead = readAndWrite || this.options.mode === "read";
53
+ const needWrite = readAndWrite || this.options.mode === "create";
54
+ const needPrune = this.options.mode === "update";
55
+
56
+ if (needRead) {
50
57
  compiler.hooks.readRecords.tapAsync(plugin, (callback) => {
51
58
  const fs =
52
59
  /** @type {IntermediateFileSystem} */
53
60
  (compiler.intermediateFileSystem);
54
- fs.readFile(this._path, (err, buffer) => {
61
+ fs.readFile(this.options.path, (err, buffer) => {
55
62
  if (err) {
56
63
  if (err.code !== "ENOENT") {
57
64
  return callback(err);
58
65
  }
59
66
  return callback();
60
67
  }
68
+ /** @type {JSONContent} */
61
69
  const json = JSON.parse(/** @type {Buffer} */ (buffer).toString());
70
+ /** @type {Map<string, string | number | null>} */
62
71
  data = new Map();
63
72
  for (const key of Object.keys(json)) {
64
73
  data.set(key, json[key]);
@@ -68,10 +77,10 @@ class SyncModuleIdsPlugin {
68
77
  });
69
78
  });
70
79
  }
71
- if (this._write) {
80
+ if (needWrite) {
72
81
  compiler.hooks.emitRecords.tapAsync(plugin, (callback) => {
73
82
  if (!data || !dataChanged) return callback();
74
- /** @type {{[key: string]: ModuleId}} */
83
+ /** @type {JSONContent} */
75
84
  const json = {};
76
85
  const sorted = [...data].sort(([a], [b]) => (a < b ? -1 : 1));
77
86
  for (const [key, value] of sorted) {
@@ -80,19 +89,20 @@ class SyncModuleIdsPlugin {
80
89
  const fs =
81
90
  /** @type {IntermediateFileSystem} */
82
91
  (compiler.intermediateFileSystem);
83
- fs.writeFile(this._path, JSON.stringify(json), callback);
92
+ fs.writeFile(this.options.path, JSON.stringify(json), callback);
84
93
  });
85
94
  }
86
95
  compiler.hooks.thisCompilation.tap(plugin, (compilation) => {
87
96
  const associatedObjectForCache = compiler.root;
88
- const context = this._context || compiler.context;
89
- if (this._read) {
97
+ const context = this.options.context || compiler.context;
98
+ const test = this.options.test || (() => true);
99
+ if (needRead) {
90
100
  compilation.hooks.reviveModules.tap(plugin, (_1, _2) => {
91
101
  if (!data) return;
92
102
  const { chunkGraph } = compilation;
93
103
  const [usedIds, modules] = getUsedModuleIdsAndModules(
94
104
  compilation,
95
- this._test
105
+ test
96
106
  );
97
107
  for (const module of modules) {
98
108
  const name = module.libIdent({
@@ -104,7 +114,7 @@ class SyncModuleIdsPlugin {
104
114
  const idAsString = `${id}`;
105
115
  if (usedIds.has(idAsString)) {
106
116
  const err = new WebpackError(
107
- `SyncModuleIdsPlugin: Unable to restore id '${id}' from '${this._path}' as it's already used.`
117
+ `SyncModuleIdsPlugin: Unable to restore id '${id}' from '${this.options.path}' as it's already used.`
108
118
  );
109
119
  err.module = module;
110
120
  compilation.errors.push(err);
@@ -114,17 +124,17 @@ class SyncModuleIdsPlugin {
114
124
  }
115
125
  });
116
126
  }
117
- if (this._write) {
127
+ if (needWrite) {
118
128
  compilation.hooks.recordModules.tap(plugin, (modules) => {
119
129
  const { chunkGraph } = compilation;
120
130
  let oldData = data;
121
131
  if (!oldData) {
122
132
  oldData = data = new Map();
123
- } else if (this._prune) {
133
+ } else if (needPrune) {
124
134
  data = new Map();
125
135
  }
126
136
  for (const module of modules) {
127
- if (this._test(module)) {
137
+ if (test(module)) {
128
138
  const name = module.libIdent({
129
139
  context,
130
140
  associatedObjectForCache
package/lib/index.js CHANGED
@@ -33,8 +33,8 @@ const memoize = require("./util/memoize");
33
33
  /** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
34
34
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptions} Configuration */
35
35
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
36
- /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
37
- /** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
36
+ /** @typedef {import("./webpack").WebpackPluginFunction} WebpackPluginFunction */
37
+ /** @typedef {import("./webpack").WebpackPluginInstance} WebpackPluginInstance */
38
38
  /** @typedef {import("./ChunkGroup")} ChunkGroup */
39
39
  /** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
40
40
  /** @typedef {import("./Compilation").Asset} Asset */
@@ -296,6 +296,7 @@ class BasicEvaluatedExpression {
296
296
  if (this.isBigInt()) return `${this.bigint}`;
297
297
  if (this.isRegExp()) return `${this.regExp}`;
298
298
  if (this.isArray()) {
299
+ /** @type {string[]} */
299
300
  const array = [];
300
301
  for (const item of /** @type {BasicEvaluatedExpression[]} */ (
301
302
  this.items
@@ -8,16 +8,19 @@
8
8
  /** @typedef {import("../../declarations/WebpackOptions").ChunkLoadingType} ChunkLoadingType */
9
9
  /** @typedef {import("../Compiler")} Compiler */
10
10
 
11
- /** @type {WeakMap<Compiler, Set<ChunkLoadingType>>} */
11
+ /** @typedef {Set<ChunkLoadingType>} ChunkLoadingTypes */
12
+
13
+ /** @type {WeakMap<Compiler, ChunkLoadingTypes>} */
12
14
  const enabledTypes = new WeakMap();
13
15
 
14
16
  /**
15
17
  * @param {Compiler} compiler compiler
16
- * @returns {Set<ChunkLoadingType>} enabled types
18
+ * @returns {ChunkLoadingTypes} enabled types
17
19
  */
18
20
  const getEnabledTypes = (compiler) => {
19
21
  let set = enabledTypes.get(compiler);
20
22
  if (set === undefined) {
23
+ /** @type {ChunkLoadingTypes} */
21
24
  set = new Set();
22
25
  enabledTypes.set(compiler, set);
23
26
  }
@@ -32,7 +32,7 @@ const RuntimeGlobals = require("../RuntimeGlobals");
32
32
  const Template = require("../Template");
33
33
  const { last, someInIterable } = require("../util/IterableHelpers");
34
34
  const StringXor = require("../util/StringXor");
35
- const { compareModulesByIdOrIdentifier } = require("../util/comparators");
35
+ const { compareModulesByFullName } = require("../util/comparators");
36
36
  const {
37
37
  RESERVED_NAMES,
38
38
  addScopeSymbols,
@@ -59,17 +59,21 @@ const JavascriptParser = require("./JavascriptParser");
59
59
  /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
60
60
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
61
61
  /** @typedef {import("../Compilation").ExecuteModuleObject} ExecuteModuleObject */
62
+ /** @typedef {import("../Compilation").WebpackRequire} WebpackRequire */
62
63
  /** @typedef {import("../Compiler")} Compiler */
63
64
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
64
65
  /** @typedef {import("../Entrypoint")} Entrypoint */
65
66
  /** @typedef {import("../Module")} Module */
66
67
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
68
+ /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
67
69
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
68
70
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
69
71
  /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
70
72
  /** @typedef {import("../WebpackError")} WebpackError */
71
73
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
72
74
  /** @typedef {import("../util/Hash")} Hash */
75
+ /** @typedef {import("../util/concatenate").ScopeSet} ScopeSet */
76
+ /** @typedef {import("../util/concatenate").UsedNamesInScopeInfo} UsedNamesInScopeInfo */
73
77
 
74
78
  /**
75
79
  * @param {Chunk} chunk a chunk
@@ -278,7 +282,7 @@ class JavascriptModulesPlugin {
278
282
 
279
283
  constructor(options = {}) {
280
284
  this.options = options;
281
- /** @type {WeakMap<Source, { source: Source, needModule:boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
285
+ /** @type {WeakMap<Source, { source: Source, needModule: boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
282
286
  this._moduleFactoryCache = new WeakMap();
283
287
  }
284
288
 
@@ -354,6 +358,7 @@ class JavascriptModulesPlugin {
354
358
  outputOptions
355
359
  );
356
360
 
361
+ /** @type {() => Source} */
357
362
  let render;
358
363
 
359
364
  if (hotUpdateChunk) {
@@ -535,6 +540,7 @@ class JavascriptModulesPlugin {
535
540
  const { module } = options;
536
541
  const code = source.source();
537
542
 
543
+ /** @type {(this: ExecuteModuleObject["exports"], exports: ExecuteModuleObject["exports"], moduleObject: ExecuteModuleObject, webpackRequire: WebpackRequire) => void} */
538
544
  const fn = vm.runInThisContext(
539
545
  `(function(${module.moduleArgument}, ${module.exportsArgument}, ${RuntimeGlobals.require}) {\n${code}\n/**/})`,
540
546
  {
@@ -552,7 +558,8 @@ class JavascriptModulesPlugin {
552
558
  moduleObject.exports,
553
559
  moduleObject,
554
560
  moduleObject.exports,
555
- context.__webpack_require__
561
+ /** @type {WebpackRequire} */
562
+ (context.__webpack_require__)
556
563
  );
557
564
  } catch (err) {
558
565
  /** @type {Error} */
@@ -569,6 +576,7 @@ class JavascriptModulesPlugin {
569
576
  let code = source.source();
570
577
  if (typeof code !== "string") code = code.toString();
571
578
 
579
+ /** @type {(this: null, webpackRequire: WebpackRequire) => void} */
572
580
  const fn = vm.runInThisContext(
573
581
  `(function(${RuntimeGlobals.require}) {\n${code}\n/**/})`,
574
582
  {
@@ -578,7 +586,11 @@ class JavascriptModulesPlugin {
578
586
  );
579
587
  try {
580
588
  // eslint-disable-next-line no-useless-call
581
- fn.call(null, context.__webpack_require__);
589
+ fn.call(
590
+ null,
591
+ /** @type {WebpackRequire} */
592
+ (context.__webpack_require__)
593
+ );
582
594
  } catch (err) {
583
595
  /** @type {Error} */
584
596
  (err).stack += printGeneratedCodeForStack(options.module, code);
@@ -638,6 +650,7 @@ class JavascriptModulesPlugin {
638
650
  hooks.renderModuleContent.call(moduleSource, module, renderContext),
639
651
  "JavascriptModulesPlugin.getCompilationHooks().renderModuleContent"
640
652
  );
653
+ /** @type {Source} */
641
654
  let moduleSourcePostContainer;
642
655
  if (factory) {
643
656
  const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements(
@@ -660,6 +673,7 @@ class JavascriptModulesPlugin {
660
673
  );
661
674
  const renderShorthand =
662
675
  renderInObject === true && runtimeTemplate.supportsMethodShorthand();
676
+ /** @type {Source} */
663
677
  let source;
664
678
  if (
665
679
  cacheEntry &&
@@ -673,6 +687,7 @@ class JavascriptModulesPlugin {
673
687
  source = cacheEntry.source;
674
688
  } else {
675
689
  const factorySource = new ConcatSource();
690
+ /** @type {string[]} */
676
691
  const args = [];
677
692
  if (needExports || needRequire || needModule) {
678
693
  args.push(
@@ -747,13 +762,14 @@ class JavascriptModulesPlugin {
747
762
  * @returns {Source} the rendered source
748
763
  */
749
764
  renderChunk(renderContext, hooks) {
750
- const { chunk, chunkGraph } = renderContext;
765
+ const { chunk, chunkGraph, runtimeTemplate } = renderContext;
751
766
  const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
752
767
  chunk,
753
768
  JAVASCRIPT_TYPE,
754
- compareModulesByIdOrIdentifier(chunkGraph)
769
+ compareModulesByFullName(runtimeTemplate.compilation.compiler)
755
770
  );
756
771
  const allModules = modules ? [...modules] : [];
772
+ /** @type {undefined | string} */
757
773
  let strictHeader;
758
774
  let allStrict = renderContext.strictMode;
759
775
  if (
@@ -838,7 +854,7 @@ class JavascriptModulesPlugin {
838
854
  ...(chunkGraph.getOrderedChunkModulesIterableBySourceType(
839
855
  chunk,
840
856
  JAVASCRIPT_TYPE,
841
- compareModulesByIdOrIdentifier(chunkGraph)
857
+ compareModulesByFullName(runtimeTemplate.compilation.compiler)
842
858
  ) || [])
843
859
  ];
844
860
 
@@ -850,6 +866,7 @@ class JavascriptModulesPlugin {
850
866
  }
851
867
 
852
868
  const source = new ConcatSource();
869
+ /** @type {string} */
853
870
  let prefix;
854
871
  if (iife) {
855
872
  if (runtimeTemplate.supportsArrowFunction()) {
@@ -1026,6 +1043,7 @@ class JavascriptModulesPlugin {
1026
1043
  );
1027
1044
 
1028
1045
  if (renderedModule) {
1046
+ /** @type {string} */
1029
1047
  let footer;
1030
1048
  if (iife !== undefined) {
1031
1049
  startupSource.add(
@@ -1209,7 +1227,7 @@ class JavascriptModulesPlugin {
1209
1227
  requireFunction || interceptModuleExecution || moduleUsed;
1210
1228
 
1211
1229
  /**
1212
- * @type {{startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean}}
1230
+ * @type {{ startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean }}
1213
1231
  */
1214
1232
  const result = {
1215
1233
  header: [],
@@ -1334,6 +1352,7 @@ class JavascriptModulesPlugin {
1334
1352
  result.allowInlineStartup = false;
1335
1353
  }
1336
1354
 
1355
+ /** @type {undefined | CodeGenerationResultData} */
1337
1356
  let data;
1338
1357
  if (codeGenerationResults.has(entryModule, chunk.runtime)) {
1339
1358
  const result = codeGenerationResults.get(
@@ -1766,7 +1785,9 @@ class JavascriptModulesPlugin {
1766
1785
  }
1767
1786
 
1768
1787
  for (const variable of info.variables) {
1788
+ /** @type {UsedNamesInScopeInfo} */
1769
1789
  const usedNamesInScopeInfo = new Map();
1790
+ /** @type {ScopeSet} */
1770
1791
  const ignoredScopes = new Set();
1771
1792
 
1772
1793
  const name = variable.name;