webpack 5.92.1 → 5.94.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.
Files changed (350) hide show
  1. package/README.md +8 -5
  2. package/bin/webpack.js +6 -7
  3. package/hot/log.js +1 -2
  4. package/hot/only-dev-server.js +1 -1
  5. package/hot/poll.js +1 -1
  6. package/hot/signal.js +1 -1
  7. package/lib/APIPlugin.js +4 -3
  8. package/lib/AbstractMethodError.js +10 -5
  9. package/lib/AutomaticPrefetchPlugin.js +1 -1
  10. package/lib/BannerPlugin.js +12 -6
  11. package/lib/Cache.js +8 -10
  12. package/lib/CacheFacade.js +3 -3
  13. package/lib/CaseSensitiveModulesWarning.js +5 -7
  14. package/lib/Chunk.js +14 -11
  15. package/lib/ChunkGraph.js +58 -36
  16. package/lib/ChunkGroup.js +2 -3
  17. package/lib/ChunkTemplate.js +43 -0
  18. package/lib/CleanPlugin.js +10 -11
  19. package/lib/CodeGenerationResults.js +6 -5
  20. package/lib/CommentCompilationWarning.js +0 -1
  21. package/lib/Compilation.js +223 -191
  22. package/lib/Compiler.js +81 -82
  23. package/lib/ConcatenationScope.js +3 -6
  24. package/lib/ConditionalInitFragment.js +6 -7
  25. package/lib/ConstPlugin.js +7 -15
  26. package/lib/ContextExclusionPlugin.js +3 -3
  27. package/lib/ContextModule.js +36 -21
  28. package/lib/ContextModuleFactory.js +89 -44
  29. package/lib/ContextReplacementPlugin.js +10 -9
  30. package/lib/DefinePlugin.js +76 -69
  31. package/lib/DelegatedModule.js +7 -3
  32. package/lib/DelegatedModuleFactoryPlugin.js +36 -22
  33. package/lib/DelegatedPlugin.js +4 -0
  34. package/lib/DependenciesBlock.js +0 -1
  35. package/lib/Dependency.js +10 -14
  36. package/lib/DllEntryPlugin.js +4 -2
  37. package/lib/DllModuleFactory.js +1 -0
  38. package/lib/DllPlugin.js +9 -7
  39. package/lib/DllReferencePlugin.js +30 -15
  40. package/lib/EntryPlugin.js +1 -3
  41. package/lib/EnvironmentPlugin.js +5 -2
  42. package/lib/ErrorHelpers.js +11 -12
  43. package/lib/EvalDevToolModulePlugin.js +10 -12
  44. package/lib/EvalSourceMapDevToolPlugin.js +15 -13
  45. package/lib/ExportsInfo.js +185 -120
  46. package/lib/ExternalModule.js +104 -64
  47. package/lib/ExternalModuleFactoryPlugin.js +23 -10
  48. package/lib/FileSystemInfo.js +791 -422
  49. package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
  50. package/lib/FlagDependencyExportsPlugin.js +12 -11
  51. package/lib/FlagDependencyUsagePlugin.js +1 -1
  52. package/lib/Generator.js +2 -5
  53. package/lib/GraphHelpers.js +3 -2
  54. package/lib/HookWebpackError.js +8 -10
  55. package/lib/HotModuleReplacementPlugin.js +78 -64
  56. package/lib/IgnoreErrorModuleFactory.js +3 -3
  57. package/lib/IgnorePlugin.js +1 -3
  58. package/lib/IgnoreWarningsPlugin.js +6 -9
  59. package/lib/InitFragment.js +2 -3
  60. package/lib/LibManifestPlugin.js +4 -3
  61. package/lib/MainTemplate.js +72 -19
  62. package/lib/Module.js +25 -9
  63. package/lib/ModuleBuildError.js +4 -11
  64. package/lib/ModuleDependencyError.js +5 -5
  65. package/lib/ModuleDependencyWarning.js +5 -5
  66. package/lib/ModuleError.js +1 -5
  67. package/lib/ModuleFilenameHelpers.js +29 -46
  68. package/lib/ModuleGraph.js +7 -6
  69. package/lib/ModuleGraphConnection.js +6 -6
  70. package/lib/ModuleInfoHeaderPlugin.js +82 -30
  71. package/lib/ModuleParseError.js +8 -9
  72. package/lib/ModuleRestoreError.js +1 -1
  73. package/lib/ModuleStoreError.js +1 -1
  74. package/lib/ModuleTemplate.js +33 -1
  75. package/lib/ModuleTypeConstants.js +21 -22
  76. package/lib/ModuleWarning.js +1 -5
  77. package/lib/MultiCompiler.js +24 -26
  78. package/lib/MultiStats.js +73 -31
  79. package/lib/MultiWatching.js +1 -1
  80. package/lib/NormalModule.js +132 -70
  81. package/lib/NormalModuleFactory.js +53 -49
  82. package/lib/OptimizationStages.js +3 -3
  83. package/lib/ProgressPlugin.js +9 -9
  84. package/lib/ProvidePlugin.js +4 -4
  85. package/lib/RuntimeGlobals.js +71 -70
  86. package/lib/RuntimeModule.js +1 -1
  87. package/lib/RuntimePlugin.js +24 -12
  88. package/lib/RuntimeTemplate.js +40 -44
  89. package/lib/SizeFormatHelpers.js +2 -4
  90. package/lib/SourceMapDevToolPlugin.js +42 -34
  91. package/lib/Stats.js +5 -11
  92. package/lib/Template.js +18 -24
  93. package/lib/TemplatedPathPlugin.js +12 -10
  94. package/lib/UseStrictPlugin.js +8 -1
  95. package/lib/WarnDeprecatedOptionPlugin.js +0 -1
  96. package/lib/WatchIgnorePlugin.js +26 -9
  97. package/lib/Watching.js +10 -5
  98. package/lib/WebpackOptionsApply.js +89 -62
  99. package/lib/asset/AssetGenerator.js +107 -42
  100. package/lib/asset/AssetModulesPlugin.js +29 -23
  101. package/lib/asset/AssetSourceGenerator.js +2 -7
  102. package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
  103. package/lib/buildChunkGraph.js +14 -19
  104. package/lib/cache/IdleFileCachePlugin.js +4 -4
  105. package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
  106. package/lib/cache/PackFileCacheStrategy.js +51 -50
  107. package/lib/cache/ResolverCachePlugin.js +6 -6
  108. package/lib/cache/mergeEtags.js +16 -21
  109. package/lib/cli.js +148 -104
  110. package/lib/config/browserslistTargetHandler.js +16 -13
  111. package/lib/config/defaults.js +31 -28
  112. package/lib/config/normalization.js +335 -344
  113. package/lib/config/target.js +42 -52
  114. package/lib/container/ContainerEntryModule.js +2 -2
  115. package/lib/container/ContainerPlugin.js +1 -1
  116. package/lib/container/RemoteRuntimeModule.js +11 -8
  117. package/lib/container/options.js +18 -4
  118. package/lib/css/CssExportsGenerator.js +39 -40
  119. package/lib/css/CssGenerator.js +11 -14
  120. package/lib/css/CssLoadingRuntimeModule.js +10 -10
  121. package/lib/css/CssModulesPlugin.js +127 -47
  122. package/lib/css/CssParser.js +20 -18
  123. package/lib/css/walkCssTokens.js +80 -95
  124. package/lib/debug/ProfilingPlugin.js +19 -20
  125. package/lib/dependencies/AMDDefineDependency.js +1 -1
  126. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
  127. package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
  128. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
  129. package/lib/dependencies/AMDRuntimeModules.js +2 -2
  130. package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
  131. package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
  132. package/lib/dependencies/CommonJsExportsDependency.js +0 -1
  133. package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
  134. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
  135. package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
  136. package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
  137. package/lib/dependencies/ConstDependency.js +1 -1
  138. package/lib/dependencies/ContextDependency.js +1 -1
  139. package/lib/dependencies/ContextDependencyHelpers.js +31 -34
  140. package/lib/dependencies/ContextElementDependency.js +2 -2
  141. package/lib/dependencies/CriticalDependencyWarning.js +1 -1
  142. package/lib/dependencies/CssExportDependency.js +72 -9
  143. package/lib/dependencies/CssImportDependency.js +0 -2
  144. package/lib/dependencies/CssLocalIdentifierDependency.js +68 -21
  145. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  146. package/lib/dependencies/CssUrlDependency.js +4 -5
  147. package/lib/dependencies/DynamicExports.js +5 -5
  148. package/lib/dependencies/ExportsInfoDependency.js +1 -2
  149. package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
  150. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
  151. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
  152. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  153. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
  154. package/lib/dependencies/HarmonyExports.js +2 -2
  155. package/lib/dependencies/HarmonyImportDependency.js +2 -4
  156. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
  157. package/lib/dependencies/HarmonyImportSpecifierDependency.js +41 -16
  158. package/lib/dependencies/ImportDependency.js +1 -1
  159. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
  160. package/lib/dependencies/ImportMetaPlugin.js +11 -13
  161. package/lib/dependencies/ImportParserPlugin.js +39 -44
  162. package/lib/dependencies/JsonExportsDependency.js +22 -18
  163. package/lib/dependencies/LoaderPlugin.js +47 -36
  164. package/lib/dependencies/LocalModule.js +1 -1
  165. package/lib/dependencies/LocalModulesHelpers.js +4 -4
  166. package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
  167. package/lib/dependencies/ProvidedDependency.js +1 -1
  168. package/lib/dependencies/PureExpressionDependency.js +6 -6
  169. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  170. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  171. package/lib/dependencies/SystemPlugin.js +1 -1
  172. package/lib/dependencies/URLDependency.js +3 -3
  173. package/lib/dependencies/URLPlugin.js +66 -12
  174. package/lib/dependencies/WorkerPlugin.js +25 -24
  175. package/lib/dependencies/processExportInfo.js +3 -1
  176. package/lib/electron/ElectronTargetPlugin.js +1 -0
  177. package/lib/esm/ModuleChunkFormatPlugin.js +11 -12
  178. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
  179. package/lib/formatLocation.js +1 -2
  180. package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
  181. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
  182. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
  183. package/lib/hmr/LazyCompilationPlugin.js +27 -12
  184. package/lib/hmr/lazyCompilationBackend.js +64 -40
  185. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
  186. package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
  187. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  188. package/lib/ids/HashedModuleIdsPlugin.js +5 -1
  189. package/lib/ids/IdHelpers.js +29 -39
  190. package/lib/ids/SyncModuleIdsPlugin.js +7 -2
  191. package/lib/index.js +1 -5
  192. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +6 -4
  193. package/lib/javascript/BasicEvaluatedExpression.js +4 -19
  194. package/lib/javascript/ChunkHelpers.js +1 -1
  195. package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -11
  196. package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
  197. package/lib/javascript/JavascriptGenerator.js +23 -7
  198. package/lib/javascript/JavascriptModulesPlugin.js +97 -70
  199. package/lib/javascript/JavascriptParser.js +179 -200
  200. package/lib/javascript/JavascriptParserHelpers.js +20 -21
  201. package/lib/javascript/StartupHelpers.js +41 -13
  202. package/lib/json/JsonGenerator.js +7 -13
  203. package/lib/json/JsonModulesPlugin.js +1 -4
  204. package/lib/json/JsonParser.js +5 -3
  205. package/lib/library/AmdLibraryPlugin.js +12 -16
  206. package/lib/library/AssignLibraryPlugin.js +9 -11
  207. package/lib/library/EnableLibraryPlugin.js +25 -15
  208. package/lib/library/ExportPropertyLibraryPlugin.js +8 -2
  209. package/lib/library/JsonpLibraryPlugin.js +2 -1
  210. package/lib/library/ModernModuleLibraryPlugin.js +144 -0
  211. package/lib/library/ModuleLibraryPlugin.js +2 -1
  212. package/lib/library/SystemLibraryPlugin.js +2 -1
  213. package/lib/library/UmdLibraryPlugin.js +66 -92
  214. package/lib/logging/Logger.js +32 -4
  215. package/lib/logging/createConsoleLogger.js +12 -13
  216. package/lib/logging/runtime.js +7 -8
  217. package/lib/logging/truncateArgs.js +5 -8
  218. package/lib/node/NodeWatchFileSystem.js +3 -18
  219. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  220. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  221. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
  222. package/lib/node/nodeConsole.js +22 -22
  223. package/lib/optimize/AggressiveMergingPlugin.js +2 -4
  224. package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
  225. package/lib/optimize/ConcatenatedModule.js +144 -61
  226. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  227. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
  228. package/lib/optimize/InnerGraph.js +17 -17
  229. package/lib/optimize/InnerGraphPlugin.js +8 -7
  230. package/lib/optimize/LimitChunkCountPlugin.js +2 -3
  231. package/lib/optimize/MangleExportsPlugin.js +1 -0
  232. package/lib/optimize/MinMaxSizeWarning.js +1 -1
  233. package/lib/optimize/ModuleConcatenationPlugin.js +56 -78
  234. package/lib/optimize/RealContentHashPlugin.js +7 -10
  235. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  236. package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
  237. package/lib/optimize/SplitChunksPlugin.js +34 -30
  238. package/lib/performance/SizeLimitsPlugin.js +2 -2
  239. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -0
  240. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
  241. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
  242. package/lib/rules/BasicEffectRulePlugin.js +3 -1
  243. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  244. package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
  245. package/lib/rules/RuleSetCompiler.js +41 -22
  246. package/lib/rules/UseEffectRulePlugin.js +36 -32
  247. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
  248. package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
  249. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
  250. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
  251. package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
  252. package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
  253. package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
  254. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
  255. package/lib/schemes/DataUriPlugin.js +1 -1
  256. package/lib/schemes/HttpUriPlugin.js +241 -126
  257. package/lib/serialization/BinaryMiddleware.js +44 -28
  258. package/lib/serialization/DateObjectSerializer.js +1 -0
  259. package/lib/serialization/ErrorObjectSerializer.js +2 -0
  260. package/lib/serialization/FileMiddleware.js +154 -106
  261. package/lib/serialization/MapObjectSerializer.js +2 -1
  262. package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
  263. package/lib/serialization/ObjectMiddleware.js +52 -56
  264. package/lib/serialization/PlainObjectSerializer.js +32 -6
  265. package/lib/serialization/RegExpObjectSerializer.js +1 -0
  266. package/lib/serialization/Serializer.js +4 -5
  267. package/lib/serialization/SerializerMiddleware.js +6 -6
  268. package/lib/serialization/SetObjectSerializer.js +2 -1
  269. package/lib/sharing/ConsumeSharedModule.js +19 -14
  270. package/lib/sharing/ConsumeSharedPlugin.js +116 -97
  271. package/lib/sharing/ConsumeSharedRuntimeModule.js +108 -141
  272. package/lib/sharing/ProvideForSharedDependency.js +0 -1
  273. package/lib/sharing/ProvideSharedPlugin.js +2 -2
  274. package/lib/sharing/resolveMatchedConfigs.js +2 -1
  275. package/lib/sharing/utils.js +15 -27
  276. package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
  277. package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
  278. package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
  279. package/lib/stats/StatsFactory.js +127 -56
  280. package/lib/stats/StatsPrinter.js +75 -44
  281. package/lib/util/ArrayHelpers.js +8 -4
  282. package/lib/util/ArrayQueue.js +1 -1
  283. package/lib/util/AsyncQueue.js +31 -12
  284. package/lib/util/IterableHelpers.js +3 -4
  285. package/lib/util/LazyBucketSortedSet.js +60 -44
  286. package/lib/util/LazySet.js +1 -0
  287. package/lib/util/MapHelpers.js +1 -3
  288. package/lib/util/ParallelismFactorCalculator.js +1 -1
  289. package/lib/util/Queue.js +1 -1
  290. package/lib/util/Semaphore.js +4 -7
  291. package/lib/util/SetHelpers.js +5 -5
  292. package/lib/util/SortableSet.js +4 -3
  293. package/lib/util/StackedCacheMap.js +4 -6
  294. package/lib/util/StackedMap.js +1 -3
  295. package/lib/util/StringXor.js +0 -5
  296. package/lib/util/TupleQueue.js +1 -1
  297. package/lib/util/TupleSet.js +15 -5
  298. package/lib/util/URLAbsoluteSpecifier.js +7 -7
  299. package/lib/util/WeakTupleMap.js +19 -21
  300. package/lib/util/binarySearchBounds.js +5 -12
  301. package/lib/util/chainedImports.js +1 -1
  302. package/lib/util/cleverMerge.js +21 -19
  303. package/lib/util/comparators.js +57 -52
  304. package/lib/util/compileBooleanMatcher.js +3 -6
  305. package/lib/util/conventions.js +10 -13
  306. package/lib/util/createHash.js +9 -6
  307. package/lib/util/deprecation.js +22 -12
  308. package/lib/util/deterministicGrouping.js +19 -26
  309. package/lib/util/findGraphRoots.js +2 -2
  310. package/lib/util/fs.js +31 -31
  311. package/lib/util/hash/md4.js +2 -2
  312. package/lib/util/hash/wasm-hash.js +7 -7
  313. package/lib/util/hash/xxhash64.js +2 -2
  314. package/lib/util/identifier.js +81 -59
  315. package/lib/util/memoize.js +8 -10
  316. package/lib/util/mergeScope.js +6 -9
  317. package/lib/util/nonNumericOnlyHash.js +2 -2
  318. package/lib/util/numberHash.js +1 -6
  319. package/lib/util/objectToMap.js +0 -1
  320. package/lib/util/propertyAccess.js +2 -5
  321. package/lib/util/propertyName.js +1 -3
  322. package/lib/util/registerExternalSerializer.js +1 -1
  323. package/lib/util/runtime.js +103 -113
  324. package/lib/util/semver.js +29 -27
  325. package/lib/util/serialization.js +16 -1
  326. package/lib/util/smartGrouping.js +5 -5
  327. package/lib/util/source.js +1 -1
  328. package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
  329. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  330. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
  331. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  332. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
  333. package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
  334. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
  335. package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
  336. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
  337. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
  338. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  339. package/package.json +17 -16
  340. package/schemas/WebpackOptions.check.js +1 -1
  341. package/schemas/WebpackOptions.json +17 -0
  342. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  343. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
  344. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  345. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  346. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  347. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  348. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  349. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  350. package/types.d.ts +682 -347
@@ -7,6 +7,7 @@
7
7
 
8
8
  const eslintScope = require("eslint-scope");
9
9
  const Referencer = require("eslint-scope/lib/referencer");
10
+ const { SyncBailHook } = require("tapable");
10
11
  const {
11
12
  CachedSource,
12
13
  ConcatSource,
@@ -61,6 +62,7 @@ const {
61
62
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
62
63
  /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
63
64
  /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
65
+ /** @typedef {import("../ModuleParseError")} ModuleParseError */
64
66
  /** @typedef {import("../RequestShortener")} RequestShortener */
65
67
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
66
68
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
@@ -127,12 +129,12 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
127
129
  * @property {Module} module
128
130
  * @property {number} index
129
131
  * @property {Program | undefined} ast
130
- * @property {Source} internalSource
132
+ * @property {Source | undefined} internalSource
131
133
  * @property {ReplaceSource} source
132
134
  * @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
133
- * @property {ReadOnlyRuntimeRequirements} runtimeRequirements
134
- * @property {Scope} globalScope
135
- * @property {Scope} moduleScope
135
+ * @property {ReadOnlyRuntimeRequirements | undefined} runtimeRequirements
136
+ * @property {Scope | undefined} globalScope
137
+ * @property {Scope | undefined} moduleScope
136
138
  * @property {Map<string, string>} internalNames
137
139
  * @property {Map<string, string> | undefined} exportMap
138
140
  * @property {Map<string, string> | undefined} rawExportMap
@@ -152,13 +154,13 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
152
154
  * @property {Module} module
153
155
  * @property {RuntimeSpec | boolean} runtimeCondition
154
156
  * @property {number} index
155
- * @property {string} name
157
+ * @property {string | undefined} name
156
158
  * @property {boolean} interopNamespaceObjectUsed
157
- * @property {string} interopNamespaceObjectName
159
+ * @property {string | undefined} interopNamespaceObjectName
158
160
  * @property {boolean} interopNamespaceObject2Used
159
- * @property {string} interopNamespaceObject2Name
161
+ * @property {string | undefined} interopNamespaceObject2Name
160
162
  * @property {boolean} interopDefaultAccessUsed
161
- * @property {string} interopDefaultAccessName
163
+ * @property {string | undefined} interopDefaultAccessName
162
164
  */
163
165
 
164
166
  /**
@@ -208,8 +210,17 @@ const RESERVED_NAMES = new Set(
208
210
  .split(",")
209
211
  );
210
212
 
213
+ /**
214
+ * @template T
215
+ * @param {string} property property
216
+ * @param {function(T[keyof T], T[keyof T]): 0 | 1 | -1} comparator comparator
217
+ * @returns {Comparator<T>} comparator
218
+ */
211
219
  const createComparator = (property, comparator) => (a, b) =>
212
- comparator(a[property], b[property]);
220
+ comparator(
221
+ a[/** @type {keyof T} */ (property)],
222
+ b[/** @type {keyof T} */ (property)]
223
+ );
213
224
 
214
225
  /**
215
226
  * @param {number} a a
@@ -217,12 +228,12 @@ const createComparator = (property, comparator) => (a, b) =>
217
228
  * @returns {0 | 1 | -1} result
218
229
  */
219
230
  const compareNumbers = (a, b) => {
220
- if (isNaN(a)) {
221
- if (!isNaN(b)) {
231
+ if (Number.isNaN(a)) {
232
+ if (!Number.isNaN(b)) {
222
233
  return 1;
223
234
  }
224
235
  } else {
225
- if (isNaN(b)) {
236
+ if (Number.isNaN(b)) {
226
237
  return -1;
227
238
  }
228
239
  if (a !== b) {
@@ -396,12 +407,21 @@ const getFinalBinding = (
396
407
  neededNamespaceObjects.add(info);
397
408
  return {
398
409
  info,
399
- rawName: /** @type {string} */ (info.namespaceObjectName),
410
+ rawName:
411
+ /** @type {NonNullable<ConcatenatedModuleInfo["namespaceObjectName"]>} */
412
+ (info.namespaceObjectName),
400
413
  ids: exportName,
401
414
  exportName
402
415
  };
403
416
  case "external":
404
- return { info, rawName: info.name, ids: exportName, exportName };
417
+ return {
418
+ info,
419
+ rawName:
420
+ /** @type {NonNullable<ExternalModuleInfo["name"]>} */
421
+ (info.name),
422
+ ids: exportName,
423
+ exportName
424
+ };
405
425
  }
406
426
  }
407
427
  const exportsInfo = moduleGraph.getExportsInfo(info.module);
@@ -628,11 +648,20 @@ const addScopeSymbols = (s, nameSet, scopeSet1, scopeSet2) => {
628
648
 
629
649
  const TYPES = new Set(["javascript"]);
630
650
 
651
+ /**
652
+ * @typedef {object} ConcatenateModuleHooks
653
+ * @property {SyncBailHook<[Record<string, string>], boolean>} exportsDefinitions
654
+ */
655
+
656
+ /** @type {WeakMap<Compilation, ConcatenateModuleHooks>} */
657
+ const compilationHooksMap = new WeakMap();
658
+
631
659
  class ConcatenatedModule extends Module {
632
660
  /**
633
661
  * @param {Module} rootModule the root module of the concatenation
634
662
  * @param {Set<Module>} modules all modules in the concatenation (including the root module)
635
663
  * @param {RuntimeSpec} runtime the runtime
664
+ * @param {Compilation} compilation the compilation
636
665
  * @param {object=} associatedObjectForCache object for caching
637
666
  * @param {string | HashConstructor=} hashFunction hash function to use
638
667
  * @returns {ConcatenatedModule} the module
@@ -641,6 +670,7 @@ class ConcatenatedModule extends Module {
641
670
  rootModule,
642
671
  modules,
643
672
  runtime,
673
+ compilation,
644
674
  associatedObjectForCache,
645
675
  hashFunction = "md4"
646
676
  ) {
@@ -654,18 +684,35 @@ class ConcatenatedModule extends Module {
654
684
  identifier,
655
685
  rootModule,
656
686
  modules,
657
- runtime
687
+ runtime,
688
+ compilation
658
689
  });
659
690
  }
660
691
 
692
+ /**
693
+ * @param {Compilation} compilation the compilation
694
+ * @returns {ConcatenateModuleHooks} the attached hooks
695
+ */
696
+ static getCompilationHooks(compilation) {
697
+ let hooks = compilationHooksMap.get(compilation);
698
+ if (hooks === undefined) {
699
+ hooks = {
700
+ exportsDefinitions: new SyncBailHook(["definitions"])
701
+ };
702
+ compilationHooksMap.set(compilation, hooks);
703
+ }
704
+ return hooks;
705
+ }
706
+
661
707
  /**
662
708
  * @param {object} options options
663
709
  * @param {string} options.identifier the identifier of the module
664
710
  * @param {Module=} options.rootModule the root module of the concatenation
665
711
  * @param {RuntimeSpec} options.runtime the selected runtime
666
712
  * @param {Set<Module>=} options.modules all concatenated modules
713
+ * @param {Compilation} options.compilation the compilation
667
714
  */
668
- constructor({ identifier, rootModule, modules, runtime }) {
715
+ constructor({ identifier, rootModule, modules, runtime, compilation }) {
669
716
  super(JAVASCRIPT_MODULE_TYPE_ESM, null, rootModule && rootModule.layer);
670
717
 
671
718
  // Info from Factory
@@ -677,6 +724,8 @@ class ConcatenatedModule extends Module {
677
724
  this._modules = modules;
678
725
  this._runtime = runtime;
679
726
  this.factoryMeta = rootModule && rootModule.factoryMeta;
727
+ /** @type {Compilation | undefined} */
728
+ this.compilation = compilation;
680
729
  }
681
730
 
682
731
  /**
@@ -713,10 +762,9 @@ class ConcatenatedModule extends Module {
713
762
  * @returns {string} a user readable identifier of the module
714
763
  */
715
764
  readableIdentifier(requestShortener) {
716
- return (
717
- this.rootModule.readableIdentifier(requestShortener) +
718
- ` + ${this._modules.size - 1} modules`
719
- );
765
+ return `${this.rootModule.readableIdentifier(
766
+ requestShortener
767
+ )} + ${this._modules.size - 1} modules`;
720
768
  }
721
769
 
722
770
  /**
@@ -827,7 +875,14 @@ class ConcatenatedModule extends Module {
827
875
  if (this.buildInfo.assets === undefined) {
828
876
  this.buildInfo.assets = Object.create(null);
829
877
  }
830
- Object.assign(/** @type {BuildInfo} */ (this.buildInfo).assets, assets);
878
+ Object.assign(
879
+ /** @type {NonNullable<BuildInfo["assets"]>} */
880
+ (
881
+ /** @type {BuildInfo} */
882
+ (this.buildInfo).assets
883
+ ),
884
+ assets
885
+ );
831
886
  }
832
887
  if (assetsInfo) {
833
888
  if (this.buildInfo.assetsInfo === undefined) {
@@ -873,7 +928,9 @@ class ConcatenatedModule extends Module {
873
928
  * @returns {Iterable<{ connection: ModuleGraphConnection, runtimeCondition: RuntimeSpec | true }>} imported modules in order
874
929
  */
875
930
  const getConcatenatedImports = module => {
876
- let connections = Array.from(moduleGraph.getOutgoingConnections(module));
931
+ const connections = Array.from(
932
+ moduleGraph.getOutgoingConnections(module)
933
+ );
877
934
  if (module === rootModule) {
878
935
  for (const c of moduleGraph.getOutgoingConnections(this))
879
936
  connections.push(c);
@@ -1047,14 +1104,14 @@ class ConcatenatedModule extends Module {
1047
1104
  /** @type {string} */ (rootModule.context),
1048
1105
  associatedObjectForCache
1049
1106
  );
1050
- let identifiers = [];
1107
+ const identifiers = [];
1051
1108
  for (const module of modules) {
1052
1109
  identifiers.push(cachedMakePathsRelative(module.identifier()));
1053
1110
  }
1054
1111
  identifiers.sort();
1055
1112
  const hash = createHash(hashFunction);
1056
1113
  hash.update(identifiers.join(" "));
1057
- return rootModule.identifier() + "|" + hash.digest("hex");
1114
+ return `${rootModule.identifier()}|${hash.digest("hex")}`;
1058
1115
  }
1059
1116
 
1060
1117
  /**
@@ -1283,7 +1340,11 @@ class ConcatenatedModule extends Module {
1283
1340
  );
1284
1341
  for (const identifier of allIdentifiers) {
1285
1342
  const r = /** @type {Range} */ (identifier.range);
1286
- const path = getPathInAst(info.ast, identifier);
1343
+ const path = getPathInAst(
1344
+ /** @type {NonNullable<ConcatenatedModuleInfo["ast"]>} */
1345
+ (info.ast),
1346
+ identifier
1347
+ );
1287
1348
  if (path && path.length > 1) {
1288
1349
  const maybeProperty =
1289
1350
  path[1].type === "AssignmentPattern" &&
@@ -1381,7 +1442,8 @@ class ConcatenatedModule extends Module {
1381
1442
  // Find and replace references to modules
1382
1443
  for (const info of moduleToInfoMap.values()) {
1383
1444
  if (info.type === "concatenated") {
1384
- for (const reference of info.globalScope.through) {
1445
+ const globalScope = /** @type {Scope} */ (info.globalScope);
1446
+ for (const reference of globalScope.through) {
1385
1447
  const name = reference.identifier.name;
1386
1448
  const match = ConcatenationScope.matchModuleReference(name);
1387
1449
  if (match) {
@@ -1427,6 +1489,8 @@ class ConcatenatedModule extends Module {
1427
1489
  /** @type {BuildMeta} */
1428
1490
  (rootInfo.module.buildMeta).strictHarmonyModule;
1429
1491
  const exportsInfo = moduleGraph.getExportsInfo(rootInfo.module);
1492
+ /** @type {Record<string, string>} */
1493
+ const exportsFinalName = {};
1430
1494
  for (const exportInfo of exportsInfo.orderedExports) {
1431
1495
  const name = exportInfo.name;
1432
1496
  if (exportInfo.provided === false) continue;
@@ -1451,14 +1515,15 @@ class ConcatenatedModule extends Module {
1451
1515
  strictHarmonyModule,
1452
1516
  true
1453
1517
  );
1518
+ exportsFinalName[used] = finalName;
1454
1519
  return `/* ${
1455
1520
  exportInfo.isReexport() ? "reexport" : "binding"
1456
1521
  } */ ${finalName}`;
1457
- } catch (e) {
1522
+ } catch (err) {
1458
1523
  /** @type {Error} */
1459
- (e).message +=
1524
+ (err).message +=
1460
1525
  `\nwhile generating the root export '${name}' (used name: '${used}')`;
1461
- throw e;
1526
+ throw err;
1462
1527
  }
1463
1528
  });
1464
1529
  }
@@ -1466,23 +1531,20 @@ class ConcatenatedModule extends Module {
1466
1531
  const result = new ConcatSource();
1467
1532
 
1468
1533
  // add harmony compatibility flag (must be first because of possible circular dependencies)
1534
+ let shouldAddHarmonyFlag = false;
1469
1535
  if (
1470
1536
  moduleGraph.getExportsInfo(this).otherExportsInfo.getUsed(runtime) !==
1471
1537
  UsageState.Unused
1472
1538
  ) {
1473
- result.add(`// ESM COMPAT FLAG\n`);
1474
- result.add(
1475
- runtimeTemplate.defineEsModuleFlagStatement({
1476
- exportsArgument: this.exportsArgument,
1477
- runtimeRequirements
1478
- })
1479
- );
1539
+ shouldAddHarmonyFlag = true;
1480
1540
  }
1481
1541
 
1482
1542
  // define exports
1483
1543
  if (exportsMap.size > 0) {
1484
- runtimeRequirements.add(RuntimeGlobals.exports);
1485
- runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
1544
+ const { exportsDefinitions } = ConcatenatedModule.getCompilationHooks(
1545
+ /** @type {Compilation} */ (this.compilation)
1546
+ );
1547
+
1486
1548
  const definitions = [];
1487
1549
  for (const [key, value] of exportsMap) {
1488
1550
  definitions.push(
@@ -1491,12 +1553,33 @@ class ConcatenatedModule extends Module {
1491
1553
  )}`
1492
1554
  );
1493
1555
  }
1494
- result.add(`\n// EXPORTS\n`);
1495
- result.add(
1496
- `${RuntimeGlobals.definePropertyGetters}(${
1497
- this.exportsArgument
1498
- }, {${definitions.join(",")}\n});\n`
1499
- );
1556
+ const shouldSkipRenderDefinitions =
1557
+ exportsDefinitions.call(exportsFinalName);
1558
+
1559
+ if (!shouldSkipRenderDefinitions) {
1560
+ runtimeRequirements.add(RuntimeGlobals.exports);
1561
+ runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
1562
+
1563
+ if (shouldAddHarmonyFlag) {
1564
+ result.add("// ESM COMPAT FLAG\n");
1565
+ result.add(
1566
+ runtimeTemplate.defineEsModuleFlagStatement({
1567
+ exportsArgument: this.exportsArgument,
1568
+ runtimeRequirements
1569
+ })
1570
+ );
1571
+ }
1572
+
1573
+ result.add("\n// EXPORTS\n");
1574
+ result.add(
1575
+ `${RuntimeGlobals.definePropertyGetters}(${
1576
+ this.exportsArgument
1577
+ }, {${definitions.join(",")}\n});\n`
1578
+ );
1579
+ } else {
1580
+ /** @type {BuildMeta} */
1581
+ (this.buildMeta).exportsFinalName = exportsFinalName;
1582
+ }
1500
1583
  }
1501
1584
 
1502
1585
  // list unused exports
@@ -1710,7 +1793,8 @@ ${defineGetters}`
1710
1793
  ast = JavascriptParser._parse(code, {
1711
1794
  sourceType: "module"
1712
1795
  });
1713
- } catch (err) {
1796
+ } catch (_err) {
1797
+ const err = /** @type {TODO} */ (_err);
1714
1798
  if (
1715
1799
  err.loc &&
1716
1800
  typeof err.loc === "object" &&
@@ -1718,11 +1802,9 @@ ${defineGetters}`
1718
1802
  ) {
1719
1803
  const lineNumber = err.loc.line;
1720
1804
  const lines = code.split("\n");
1721
- err.message +=
1722
- "\n| " +
1723
- lines
1724
- .slice(Math.max(0, lineNumber - 3), lineNumber + 2)
1725
- .join("\n| ");
1805
+ err.message += `\n| ${lines
1806
+ .slice(Math.max(0, lineNumber - 3), lineNumber + 2)
1807
+ .join("\n| ")}`;
1726
1808
  }
1727
1809
  throw err;
1728
1810
  }
@@ -1818,16 +1900,15 @@ ${defineGetters}`
1818
1900
  /** @type {ModuleInfo} */ (item).module,
1819
1901
  /** @type {ModuleInfo} */ (item)
1820
1902
  );
1821
- return item;
1822
- } else {
1823
- /** @type {ReferenceToModuleInfo} */
1824
- const ref = {
1825
- type: "reference",
1826
- runtimeCondition: info.runtimeCondition,
1827
- target: item
1828
- };
1829
- return ref;
1903
+ return /** @type {ModuleInfo} */ (item);
1830
1904
  }
1905
+ /** @type {ReferenceToModuleInfo} */
1906
+ const ref = {
1907
+ type: "reference",
1908
+ runtimeCondition: info.runtimeCondition,
1909
+ target: item
1910
+ };
1911
+ return ref;
1831
1912
  });
1832
1913
  return [list, map];
1833
1914
  }
@@ -1857,7 +1938,7 @@ ${defineGetters}`
1857
1938
 
1858
1939
  const splittedInfo = extraInfo.split("/");
1859
1940
  while (splittedInfo.length) {
1860
- name = splittedInfo.pop() + (name ? "_" + name : "");
1941
+ name = splittedInfo.pop() + (name ? `_${name}` : "");
1861
1942
  const nameIdent = Template.toIdentifier(name);
1862
1943
  if (
1863
1944
  !usedNamed1.has(nameIdent) &&
@@ -1870,6 +1951,7 @@ ${defineGetters}`
1870
1951
  let nameWithNumber = Template.toIdentifier(`${name}_${i}`);
1871
1952
  while (
1872
1953
  usedNamed1.has(nameWithNumber) ||
1954
+ // eslint-disable-next-line no-unmodified-loop-condition
1873
1955
  (usedNamed2 && usedNamed2.has(nameWithNumber))
1874
1956
  ) {
1875
1957
  i++;
@@ -1913,7 +1995,8 @@ ${defineGetters}`
1913
1995
  identifier: undefined,
1914
1996
  rootModule: undefined,
1915
1997
  modules: undefined,
1916
- runtime: undefined
1998
+ runtime: undefined,
1999
+ compilation: undefined
1917
2000
  });
1918
2001
  obj.deserialize(context);
1919
2002
  return obj;
@@ -56,7 +56,7 @@ class EnsureChunkConditionsPlugin {
56
56
  // We reached the entrypoint: fail
57
57
  if (chunkGroup.isInitial()) {
58
58
  throw new Error(
59
- "Cannot fulfil chunk condition of " + module.identifier()
59
+ `Cannot fulfil chunk condition of ${module.identifier()}`
60
60
  );
61
61
  }
62
62
  // Try placing in all parents
@@ -39,10 +39,10 @@ class FlagIncludedChunksPlugin {
39
39
  const modulesCount = compilation.modules.size;
40
40
 
41
41
  // precalculate the modulo values for each bit
42
- const modulo = 1 / Math.pow(1 / modulesCount, 1 / 31);
42
+ const modulo = 1 / (1 / modulesCount) ** (1 / 31);
43
43
  const modulos = Array.from(
44
44
  { length: 31 },
45
- (x, i) => Math.pow(modulo, i) | 0
45
+ (x, i) => (modulo ** i) | 0
46
46
  );
47
47
 
48
48
  // iterate all modules to generate bit values
@@ -74,7 +74,7 @@ class FlagIncludedChunksPlugin {
74
74
  const chunkAModulesCount =
75
75
  chunkGraph.getNumberOfChunkModules(chunkA);
76
76
  if (chunkAModulesCount === 0) continue;
77
- let bestModule = undefined;
77
+ let bestModule;
78
78
  for (const module of chunkGraph.getChunkModulesIterable(chunkA)) {
79
79
  if (
80
80
  bestModule === undefined ||
@@ -45,7 +45,7 @@ function getState(parserState) {
45
45
  * @param {ParserState} parserState parser state
46
46
  * @returns {void}
47
47
  */
48
- exports.bailout = parserState => {
48
+ module.exports.bailout = parserState => {
49
49
  parserStateMap.set(parserState, false);
50
50
  };
51
51
 
@@ -53,7 +53,7 @@ exports.bailout = parserState => {
53
53
  * @param {ParserState} parserState parser state
54
54
  * @returns {void}
55
55
  */
56
- exports.enable = parserState => {
56
+ module.exports.enable = parserState => {
57
57
  const state = parserStateMap.get(parserState);
58
58
  if (state === false) {
59
59
  return;
@@ -69,9 +69,9 @@ exports.enable = parserState => {
69
69
  * @param {ParserState} parserState parser state
70
70
  * @returns {boolean} true, when enabled
71
71
  */
72
- exports.isEnabled = parserState => {
72
+ module.exports.isEnabled = parserState => {
73
73
  const state = parserStateMap.get(parserState);
74
- return !!state;
74
+ return Boolean(state);
75
75
  };
76
76
 
77
77
  /**
@@ -80,7 +80,7 @@ exports.isEnabled = parserState => {
80
80
  * @param {string | TopLevelSymbol | true} usage usage data
81
81
  * @returns {void}
82
82
  */
83
- exports.addUsage = (state, symbol, usage) => {
83
+ module.exports.addUsage = (state, symbol, usage) => {
84
84
  const innerGraphState = getState(state);
85
85
 
86
86
  if (innerGraphState) {
@@ -102,13 +102,13 @@ exports.addUsage = (state, symbol, usage) => {
102
102
  * @param {string | TopLevelSymbol | true} usage usage data
103
103
  * @returns {void}
104
104
  */
105
- exports.addVariableUsage = (parser, name, usage) => {
105
+ module.exports.addVariableUsage = (parser, name, usage) => {
106
106
  const symbol =
107
107
  /** @type {TopLevelSymbol} */ (
108
108
  parser.getTagData(name, topLevelSymbolTag)
109
- ) || exports.tagTopLevelSymbol(parser, name);
109
+ ) || module.exports.tagTopLevelSymbol(parser, name);
110
110
  if (symbol) {
111
- exports.addUsage(parser.state, symbol, usage);
111
+ module.exports.addUsage(parser.state, symbol, usage);
112
112
  }
113
113
  };
114
114
 
@@ -116,7 +116,7 @@ exports.addVariableUsage = (parser, name, usage) => {
116
116
  * @param {ParserState} state parser state
117
117
  * @returns {void}
118
118
  */
119
- exports.inferDependencyUsage = state => {
119
+ module.exports.inferDependencyUsage = state => {
120
120
  const innerGraphState = getState(state);
121
121
 
122
122
  if (!innerGraphState) {
@@ -212,7 +212,7 @@ exports.inferDependencyUsage = state => {
212
212
  * @param {ParserState} state parser state
213
213
  * @param {UsageCallback} onUsageCallback on usage callback
214
214
  */
215
- exports.onUsage = (state, onUsageCallback) => {
215
+ module.exports.onUsage = (state, onUsageCallback) => {
216
216
  const innerGraphState = getState(state);
217
217
 
218
218
  if (innerGraphState) {
@@ -238,7 +238,7 @@ exports.onUsage = (state, onUsageCallback) => {
238
238
  * @param {ParserState} state parser state
239
239
  * @param {TopLevelSymbol | undefined} symbol the symbol
240
240
  */
241
- exports.setTopLevelSymbol = (state, symbol) => {
241
+ module.exports.setTopLevelSymbol = (state, symbol) => {
242
242
  const innerGraphState = getState(state);
243
243
 
244
244
  if (innerGraphState) {
@@ -250,7 +250,7 @@ exports.setTopLevelSymbol = (state, symbol) => {
250
250
  * @param {ParserState} state parser state
251
251
  * @returns {TopLevelSymbol|void} usage data
252
252
  */
253
- exports.getTopLevelSymbol = state => {
253
+ module.exports.getTopLevelSymbol = state => {
254
254
  const innerGraphState = getState(state);
255
255
 
256
256
  if (innerGraphState) {
@@ -263,7 +263,7 @@ exports.getTopLevelSymbol = state => {
263
263
  * @param {string} name name of variable
264
264
  * @returns {TopLevelSymbol | undefined} symbol
265
265
  */
266
- exports.tagTopLevelSymbol = (parser, name) => {
266
+ module.exports.tagTopLevelSymbol = (parser, name) => {
267
267
  const innerGraphState = getState(parser.state);
268
268
  if (!innerGraphState) return;
269
269
 
@@ -288,7 +288,7 @@ exports.tagTopLevelSymbol = (parser, name) => {
288
288
  * @param {RuntimeSpec} runtime runtime
289
289
  * @returns {boolean} false, when unused. Otherwise true
290
290
  */
291
- exports.isDependencyUsedByExports = (
291
+ module.exports.isDependencyUsedByExports = (
292
292
  dependency,
293
293
  usedByExports,
294
294
  moduleGraph,
@@ -316,7 +316,7 @@ exports.isDependencyUsedByExports = (
316
316
  * @param {ModuleGraph} moduleGraph moduleGraph
317
317
  * @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
318
318
  */
319
- exports.getDependencyUsedByExportsCondition = (
319
+ module.exports.getDependencyUsedByExportsCondition = (
320
320
  dependency,
321
321
  usedByExports,
322
322
  moduleGraph
@@ -347,5 +347,5 @@ class TopLevelSymbol {
347
347
  }
348
348
  }
349
349
 
350
- exports.TopLevelSymbol = TopLevelSymbol;
351
- exports.topLevelSymbolTag = topLevelSymbolTag;
350
+ module.exports.TopLevelSymbol = TopLevelSymbol;
351
+ module.exports.topLevelSymbolTag = topLevelSymbolTag;
@@ -109,13 +109,14 @@ class InnerGraphPlugin {
109
109
  parser.hooks.preStatement.tap(PLUGIN_NAME, statement => {
110
110
  if (!InnerGraph.isEnabled(parser.state)) return;
111
111
 
112
- if (parser.scope.topLevelScope === true) {
113
- if (statement.type === "FunctionDeclaration") {
114
- const name = statement.id ? statement.id.name : "*default*";
115
- const fn = InnerGraph.tagTopLevelSymbol(parser, name);
116
- statementWithTopLevelSymbol.set(statement, fn);
117
- return true;
118
- }
112
+ if (
113
+ parser.scope.topLevelScope === true &&
114
+ statement.type === "FunctionDeclaration"
115
+ ) {
116
+ const name = statement.id ? statement.id.name : "*default*";
117
+ const fn = InnerGraph.tagTopLevelSymbol(parser, name);
118
+ statementWithTopLevelSymbol.set(statement, fn);
119
+ return true;
119
120
  }
120
121
  });
121
122
 
@@ -119,7 +119,7 @@ class LimitChunkCountPlugin {
119
119
  /** @type {Map<Chunk, Set<ChunkCombination>>} */
120
120
  const combinationsByChunk = new Map();
121
121
 
122
- orderedChunks.forEach((b, bIdx) => {
122
+ for (const [bIdx, b] of orderedChunks.entries()) {
123
123
  // create combination pairs with size and integrated size
124
124
  for (let aIdx = 0; aIdx < bIdx; aIdx++) {
125
125
  const a = orderedChunks[aIdx];
@@ -149,8 +149,7 @@ class LimitChunkCountPlugin {
149
149
  addToSetMap(combinationsByChunk, a, c);
150
150
  addToSetMap(combinationsByChunk, b, c);
151
151
  }
152
- return combinations;
153
- });
152
+ }
154
153
 
155
154
  // list of modified chunks during this run
156
155
  // combinations affected by this change are skipped to allow
@@ -149,6 +149,7 @@ class MangleExportsPlugin {
149
149
  constructor(deterministic) {
150
150
  this._deterministic = deterministic;
151
151
  }
152
+
152
153
  /**
153
154
  * Apply the plugin
154
155
  * @param {Compiler} compiler the compiler instance
@@ -23,7 +23,7 @@ class MinMaxSizeWarning extends WebpackError {
23
23
  : `Cache group ${keys[0]}`;
24
24
  }
25
25
  super(
26
- `SplitChunksPlugin\n` +
26
+ "SplitChunksPlugin\n" +
27
27
  `${keysMessage}\n` +
28
28
  `Configured minSize (${SizeFormatHelpers.formatSize(minSize)}) is ` +
29
29
  `bigger than maxSize (${SizeFormatHelpers.formatSize(maxSize)}).\n` +