webpack 5.100.1 → 5.101.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 (304) hide show
  1. package/README.md +12 -10
  2. package/bin/webpack.js +7 -7
  3. package/lib/APIPlugin.js +12 -14
  4. package/lib/AutomaticPrefetchPlugin.js +2 -2
  5. package/lib/BannerPlugin.js +4 -4
  6. package/lib/Cache.js +1 -1
  7. package/lib/CacheFacade.js +7 -7
  8. package/lib/CaseSensitiveModulesWarning.js +2 -2
  9. package/lib/Chunk.js +3 -3
  10. package/lib/ChunkGraph.js +21 -18
  11. package/lib/ChunkGroup.js +4 -4
  12. package/lib/CleanPlugin.js +19 -53
  13. package/lib/CodeGenerationResults.js +3 -3
  14. package/lib/CompatibilityPlugin.js +6 -6
  15. package/lib/Compilation.js +127 -114
  16. package/lib/Compiler.js +37 -37
  17. package/lib/ConcatenationScope.js +39 -1
  18. package/lib/ConstPlugin.js +11 -11
  19. package/lib/ContextExclusionPlugin.js +3 -3
  20. package/lib/ContextModule.js +12 -11
  21. package/lib/ContextModuleFactory.js +11 -11
  22. package/lib/ContextReplacementPlugin.js +5 -5
  23. package/lib/DefinePlugin.js +24 -22
  24. package/lib/DelegatedModuleFactoryPlugin.js +1 -1
  25. package/lib/DllEntryPlugin.js +1 -1
  26. package/lib/DllReferencePlugin.js +1 -1
  27. package/lib/DynamicEntryPlugin.js +3 -3
  28. package/lib/EntryPlugin.js +1 -1
  29. package/lib/EnvironmentPlugin.js +1 -1
  30. package/lib/ErrorHelpers.js +2 -2
  31. package/lib/EvalDevToolModulePlugin.js +2 -2
  32. package/lib/EvalSourceMapDevToolPlugin.js +5 -5
  33. package/lib/ExportsInfo.js +9 -9
  34. package/lib/ExportsInfoApiPlugin.js +2 -2
  35. package/lib/ExternalModule.js +163 -48
  36. package/lib/ExternalModuleFactoryPlugin.js +2 -2
  37. package/lib/ExternalsPlugin.js +45 -0
  38. package/lib/FileSystemInfo.js +64 -61
  39. package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
  40. package/lib/FlagDependencyExportsPlugin.js +7 -7
  41. package/lib/FlagDependencyUsagePlugin.js +4 -4
  42. package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
  43. package/lib/HotModuleReplacementPlugin.js +27 -27
  44. package/lib/IgnorePlugin.js +3 -3
  45. package/lib/IgnoreWarningsPlugin.js +4 -4
  46. package/lib/InitFragment.js +6 -0
  47. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  48. package/lib/JavascriptMetaInfoPlugin.js +1 -1
  49. package/lib/LibManifestPlugin.js +2 -2
  50. package/lib/LoaderOptionsPlugin.js +1 -1
  51. package/lib/LoaderTargetPlugin.js +2 -2
  52. package/lib/MainTemplate.js +1 -1
  53. package/lib/Module.js +1 -1
  54. package/lib/ModuleFilenameHelpers.js +3 -3
  55. package/lib/ModuleGraph.js +86 -5
  56. package/lib/ModuleInfoHeaderPlugin.js +3 -3
  57. package/lib/ModuleParseError.js +5 -3
  58. package/lib/MultiCompiler.js +29 -24
  59. package/lib/MultiStats.js +18 -13
  60. package/lib/MultiWatching.js +1 -1
  61. package/lib/NoEmitOnErrorsPlugin.js +2 -2
  62. package/lib/NodeStuffPlugin.js +27 -15
  63. package/lib/NormalModule.js +28 -24
  64. package/lib/NormalModuleFactory.js +23 -21
  65. package/lib/NormalModuleReplacementPlugin.js +3 -3
  66. package/lib/PrefetchPlugin.js +1 -1
  67. package/lib/ProgressPlugin.js +11 -11
  68. package/lib/ProvidePlugin.js +2 -2
  69. package/lib/RecordIdsPlugin.js +3 -3
  70. package/lib/ResolverFactory.js +3 -3
  71. package/lib/RuntimeGlobals.js +20 -0
  72. package/lib/RuntimePlugin.js +16 -16
  73. package/lib/RuntimeTemplate.js +42 -44
  74. package/lib/SizeFormatHelpers.js +1 -1
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -4
  76. package/lib/SourceMapDevToolPlugin.js +9 -9
  77. package/lib/Stats.js +2 -2
  78. package/lib/Template.js +1 -1
  79. package/lib/TemplatedPathPlugin.js +2 -2
  80. package/lib/UseStrictPlugin.js +1 -1
  81. package/lib/WarnCaseSensitiveModulesPlugin.js +1 -1
  82. package/lib/WarnDeprecatedOptionPlugin.js +1 -1
  83. package/lib/WarnNoModeSetPlugin.js +1 -1
  84. package/lib/WatchIgnorePlugin.js +2 -2
  85. package/lib/Watching.js +12 -12
  86. package/lib/WebpackIsIncludedPlugin.js +2 -2
  87. package/lib/WebpackOptionsApply.js +10 -3
  88. package/lib/asset/AssetGenerator.js +3 -3
  89. package/lib/asset/AssetModulesPlugin.js +6 -6
  90. package/lib/async-modules/AsyncModuleHelpers.js +50 -0
  91. package/lib/async-modules/AwaitDependenciesInitFragment.js +36 -24
  92. package/lib/async-modules/InferAsyncModulesPlugin.js +3 -3
  93. package/lib/buildChunkGraph.js +5 -5
  94. package/lib/cache/AddBuildDependenciesPlugin.js +1 -1
  95. package/lib/cache/IdleFileCachePlugin.js +5 -5
  96. package/lib/cache/PackFileCacheStrategy.js +20 -20
  97. package/lib/cache/ResolverCachePlugin.js +4 -4
  98. package/lib/cli.js +196 -14
  99. package/lib/config/browserslistTargetHandler.js +6 -6
  100. package/lib/config/defaults.js +23 -14
  101. package/lib/config/normalization.js +41 -38
  102. package/lib/config/target.js +4 -4
  103. package/lib/container/ContainerEntryModule.js +3 -3
  104. package/lib/container/ContainerPlugin.js +3 -3
  105. package/lib/container/ContainerReferencePlugin.js +3 -3
  106. package/lib/container/FallbackModule.js +1 -1
  107. package/lib/container/HoistContainerReferencesPlugin.js +7 -7
  108. package/lib/container/options.js +4 -4
  109. package/lib/css/CssGenerator.js +5 -3
  110. package/lib/css/CssLoadingRuntimeModule.js +1 -1
  111. package/lib/css/CssModulesPlugin.js +25 -22
  112. package/lib/css/CssParser.js +5 -5
  113. package/lib/css/walkCssTokens.js +9 -9
  114. package/lib/debug/ProfilingPlugin.js +5 -5
  115. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -4
  116. package/lib/dependencies/AMDPlugin.js +3 -3
  117. package/lib/dependencies/AMDRequireArrayDependency.js +1 -1
  118. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +3 -3
  119. package/lib/dependencies/CommonJsExportRequireDependency.js +2 -2
  120. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -10
  121. package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -19
  122. package/lib/dependencies/CommonJsPlugin.js +2 -2
  123. package/lib/dependencies/ContextDependency.js +1 -1
  124. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  125. package/lib/dependencies/CssIcssExportDependency.js +2 -2
  126. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  127. package/lib/dependencies/CssUrlDependency.js +4 -4
  128. package/lib/dependencies/DynamicExports.js +5 -5
  129. package/lib/dependencies/HarmonyAcceptDependency.js +39 -5
  130. package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
  131. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -23
  132. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -8
  133. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  134. package/lib/dependencies/HarmonyExports.js +1 -1
  135. package/lib/dependencies/HarmonyImportDependency.js +28 -9
  136. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +59 -75
  137. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -5
  138. package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -4
  139. package/lib/dependencies/HarmonyModulesPlugin.js +2 -8
  140. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
  141. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -4
  142. package/lib/dependencies/ImportMetaPlugin.js +7 -7
  143. package/lib/dependencies/ImportParserPlugin.js +4 -4
  144. package/lib/dependencies/JsonExportsDependency.js +1 -1
  145. package/lib/dependencies/LoaderPlugin.js +4 -4
  146. package/lib/dependencies/ProvidedDependency.js +2 -2
  147. package/lib/dependencies/PureExpressionDependency.js +1 -1
  148. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  149. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
  150. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -3
  151. package/lib/dependencies/SystemPlugin.js +3 -3
  152. package/lib/dependencies/WorkerPlugin.js +5 -5
  153. package/lib/dependencies/getFunctionExpression.js +1 -1
  154. package/lib/esm/ModuleChunkFormatPlugin.js +5 -5
  155. package/lib/esm/ModuleChunkLoadingPlugin.js +2 -2
  156. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -11
  157. package/lib/formatLocation.js +2 -2
  158. package/lib/hmr/HotModuleReplacement.runtime.js +39 -27
  159. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -32
  160. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -1
  161. package/lib/hmr/LazyCompilationPlugin.js +6 -6
  162. package/lib/hmr/lazyCompilationBackend.js +6 -6
  163. package/lib/ids/ChunkModuleIdRangePlugin.js +4 -4
  164. package/lib/ids/DeterministicChunkIdsPlugin.js +5 -4
  165. package/lib/ids/DeterministicModuleIdsPlugin.js +2 -2
  166. package/lib/ids/HashedModuleIdsPlugin.js +1 -1
  167. package/lib/ids/IdHelpers.js +9 -9
  168. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  169. package/lib/ids/NamedModuleIdsPlugin.js +2 -2
  170. package/lib/ids/NaturalChunkIdsPlugin.js +2 -2
  171. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  172. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  173. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -4
  174. package/lib/ids/SyncModuleIdsPlugin.js +4 -4
  175. package/lib/index.js +10 -6
  176. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
  177. package/lib/javascript/BasicEvaluatedExpression.js +3 -3
  178. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
  179. package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
  180. package/lib/javascript/JavascriptGenerator.js +1 -1
  181. package/lib/javascript/JavascriptModulesPlugin.js +16 -16
  182. package/lib/javascript/JavascriptParser.js +90 -83
  183. package/lib/javascript/JavascriptParserHelpers.js +3 -3
  184. package/lib/javascript/StartupHelpers.js +2 -2
  185. package/lib/json/JsonGenerator.js +2 -2
  186. package/lib/json/JsonModulesPlugin.js +2 -2
  187. package/lib/library/AbstractLibraryPlugin.js +3 -3
  188. package/lib/library/AmdLibraryPlugin.js +3 -3
  189. package/lib/library/AssignLibraryPlugin.js +2 -2
  190. package/lib/library/EnableLibraryPlugin.js +2 -2
  191. package/lib/library/ModuleLibraryPlugin.js +7 -2
  192. package/lib/library/SystemLibraryPlugin.js +6 -4
  193. package/lib/library/UmdLibraryPlugin.js +14 -14
  194. package/lib/logging/createConsoleLogger.js +4 -4
  195. package/lib/logging/runtime.js +3 -3
  196. package/lib/logging/truncateArgs.js +4 -4
  197. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
  198. package/lib/node/NodeEnvironmentPlugin.js +1 -1
  199. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +16 -14
  200. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +7 -7
  201. package/lib/node/ReadFileCompileWasmPlugin.js +7 -7
  202. package/lib/node/RequireChunkLoadingRuntimeModule.js +6 -4
  203. package/lib/node/nodeConsole.js +2 -2
  204. package/lib/optimize/AggressiveMergingPlugin.js +2 -2
  205. package/lib/optimize/AggressiveSplittingPlugin.js +10 -10
  206. package/lib/optimize/ConcatenatedModule.js +161 -52
  207. package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -2
  208. package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
  209. package/lib/optimize/InnerGraph.js +5 -5
  210. package/lib/optimize/InnerGraphPlugin.js +14 -12
  211. package/lib/optimize/LimitChunkCountPlugin.js +5 -5
  212. package/lib/optimize/MangleExportsPlugin.js +5 -5
  213. package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
  214. package/lib/optimize/MinChunkSizePlugin.js +3 -3
  215. package/lib/optimize/ModuleConcatenationPlugin.js +45 -38
  216. package/lib/optimize/RealContentHashPlugin.js +23 -23
  217. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
  218. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  219. package/lib/optimize/RuntimeChunkPlugin.js +2 -2
  220. package/lib/optimize/SideEffectsFlagPlugin.js +22 -6
  221. package/lib/optimize/SplitChunksPlugin.js +20 -20
  222. package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
  223. package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
  224. package/lib/performance/SizeLimitsPlugin.js +4 -4
  225. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
  226. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -3
  227. package/lib/rules/BasicMatcherRulePlugin.js +1 -1
  228. package/lib/rules/RuleSetCompiler.js +10 -10
  229. package/lib/rules/UseEffectRulePlugin.js +2 -2
  230. package/lib/runtime/GetChunkFilenameRuntimeModule.js +15 -15
  231. package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
  232. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
  233. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  234. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
  235. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -3
  236. package/lib/schemes/DataUriPlugin.js +3 -3
  237. package/lib/schemes/FileUriPlugin.js +1 -1
  238. package/lib/schemes/HttpUriPlugin.js +40 -36
  239. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  240. package/lib/serialization/BinaryMiddleware.js +11 -11
  241. package/lib/serialization/FileMiddleware.js +17 -17
  242. package/lib/serialization/ObjectMiddleware.js +8 -8
  243. package/lib/serialization/Serializer.js +2 -2
  244. package/lib/serialization/SerializerMiddleware.js +2 -2
  245. package/lib/sharing/ConsumeSharedPlugin.js +4 -4
  246. package/lib/sharing/ProvideSharedPlugin.js +4 -4
  247. package/lib/sharing/SharePlugin.js +1 -1
  248. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  249. package/lib/stats/DefaultStatsFactoryPlugin.js +86 -80
  250. package/lib/stats/DefaultStatsPresetPlugin.js +15 -15
  251. package/lib/stats/DefaultStatsPrinterPlugin.js +87 -87
  252. package/lib/stats/StatsFactory.js +7 -7
  253. package/lib/stats/StatsPrinter.js +9 -9
  254. package/lib/url/URLParserPlugin.js +5 -5
  255. package/lib/util/AsyncQueue.js +4 -4
  256. package/lib/util/IterableHelpers.js +2 -2
  257. package/lib/util/LazyBucketSortedSet.js +3 -3
  258. package/lib/util/SetHelpers.js +2 -2
  259. package/lib/util/StackedCacheMap.js +1 -1
  260. package/lib/util/StackedMap.js +1 -1
  261. package/lib/util/TupleSet.js +1 -1
  262. package/lib/util/WeakTupleMap.js +1 -1
  263. package/lib/util/cleverMerge.js +8 -8
  264. package/lib/util/comparators.js +107 -8
  265. package/lib/util/compileBooleanMatcher.js +20 -20
  266. package/lib/util/concatenate.js +3 -3
  267. package/lib/util/conventions.js +4 -4
  268. package/lib/util/create-schema-validation.js +1 -1
  269. package/lib/util/createHash.js +1 -1
  270. package/lib/util/deprecation.js +4 -4
  271. package/lib/util/deterministicGrouping.js +7 -7
  272. package/lib/util/findGraphRoots.js +1 -1
  273. package/lib/util/fs.js +3 -3
  274. package/lib/util/identifier.js +14 -14
  275. package/lib/util/magicComment.js +5 -1
  276. package/lib/util/memoize.js +1 -1
  277. package/lib/util/processAsyncTree.js +2 -2
  278. package/lib/util/propertyName.js +1 -1
  279. package/lib/util/removeBOM.js +1 -1
  280. package/lib/util/runtime.js +6 -6
  281. package/lib/util/semver.js +16 -16
  282. package/lib/util/serialization.js +5 -5
  283. package/lib/util/smartGrouping.js +1 -1
  284. package/lib/validateSchema.js +2 -2
  285. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
  286. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
  287. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
  288. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -4
  289. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -9
  290. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
  291. package/lib/wasm-sync/WebAssemblyGenerator.js +14 -14
  292. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +4 -2
  293. package/lib/wasm-sync/WebAssemblyParser.js +2 -2
  294. package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
  295. package/lib/web/FetchCompileWasmPlugin.js +4 -4
  296. package/lib/web/JsonpChunkLoadingPlugin.js +2 -2
  297. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  298. package/lib/webpack.js +17 -12
  299. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -2
  300. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  301. package/package.json +13 -13
  302. package/schemas/WebpackOptions.check.js +1 -1
  303. package/schemas/WebpackOptions.json +4 -0
  304. package/types.d.ts +186 -54
@@ -42,13 +42,13 @@ class AggressiveMergingPlugin {
42
42
  const options = this.options;
43
43
  const minSizeReduce = options.minSizeReduce || 1.5;
44
44
 
45
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
45
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
46
46
  compilation.hooks.optimizeChunks.tap(
47
47
  {
48
48
  name: PLUGIN_NAME,
49
49
  stage: STAGE_ADVANCED
50
50
  },
51
- chunks => {
51
+ (chunks) => {
52
52
  const chunkGraph = compilation.chunkGraph;
53
53
  /** @type {{a: Chunk, b: Chunk, improvement: number}[]} */
54
54
  const combinations = [];
@@ -36,7 +36,7 @@ const validate = createSchemaValidation(
36
36
  * @param {Chunk} newChunk the new chunk
37
37
  * @returns {(module: Module) => void} function to move module between chunks
38
38
  */
39
- const moveModuleBetween = (chunkGraph, oldChunk, newChunk) => module => {
39
+ const moveModuleBetween = (chunkGraph, oldChunk, newChunk) => (module) => {
40
40
  chunkGraph.disconnectChunkAndModule(oldChunk, module);
41
41
  chunkGraph.connectChunkAndModule(newChunk, module);
42
42
  };
@@ -46,7 +46,7 @@ const moveModuleBetween = (chunkGraph, oldChunk, newChunk) => module => {
46
46
  * @param {Chunk} chunk the chunk
47
47
  * @returns {(module: Module) => boolean} filter for entry module
48
48
  */
49
- const isNotAEntryModule = (chunkGraph, chunk) => module =>
49
+ const isNotAEntryModule = (chunkGraph, chunk) => (module) =>
50
50
  !chunkGraph.isEntryModuleInChunk(module, chunk);
51
51
 
52
52
  /** @typedef {{ id?: NonNullable<Chunk["id"]>, hash?: NonNullable<Chunk["hash"]>, modules: Module[], size: number }} SplitData */
@@ -92,7 +92,7 @@ class AggressiveSplittingPlugin {
92
92
  * @returns {void}
93
93
  */
94
94
  apply(compiler) {
95
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
95
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
96
96
  let needAdditionalSeal = false;
97
97
  /** @type {SplitData[]} */
98
98
  let newSplits;
@@ -110,7 +110,7 @@ class AggressiveSplittingPlugin {
110
110
  name: PLUGIN_NAME,
111
111
  stage: STAGE_ADVANCED
112
112
  },
113
- chunks => {
113
+ (chunks) => {
114
114
  const chunkGraph = compilation.chunkGraph;
115
115
  // Precompute stuff
116
116
  const nameToModuleMap = new Map();
@@ -145,14 +145,14 @@ class AggressiveSplittingPlugin {
145
145
  * @param {SplitData} splitData split data
146
146
  * @returns {boolean} true when applied, otherwise false
147
147
  */
148
- const applySplit = splitData => {
148
+ const applySplit = (splitData) => {
149
149
  // Cannot split if id is already taken
150
150
  if (splitData.id !== undefined && usedIds.has(splitData.id)) {
151
151
  return false;
152
152
  }
153
153
 
154
154
  // Get module objects from names
155
- const selectedModules = splitData.modules.map(name =>
155
+ const selectedModules = splitData.modules.map((name) =>
156
156
  nameToModuleMap.get(name)
157
157
  );
158
158
 
@@ -167,7 +167,7 @@ class AggressiveSplittingPlugin {
167
167
  // get chunks with all modules
168
168
  const selectedChunks = intersect(
169
169
  selectedModules.map(
170
- m => new Set(chunkGraph.getModuleChunksIterable(m))
170
+ (m) => new Set(chunkGraph.getModuleChunksIterable(m))
171
171
  )
172
172
  );
173
173
 
@@ -253,7 +253,7 @@ class AggressiveSplittingPlugin {
253
253
  /** @type {SplitData} */
254
254
  const splitData = {
255
255
  modules: selectedModules
256
- .map(m => moduleToNameMap.get(m))
256
+ .map((m) => moduleToNameMap.get(m))
257
257
  .sort(),
258
258
  size: selectedModulesSize
259
259
  };
@@ -267,7 +267,7 @@ class AggressiveSplittingPlugin {
267
267
  if (changed) return true;
268
268
  }
269
269
  );
270
- compilation.hooks.recordHash.tap(PLUGIN_NAME, records => {
270
+ compilation.hooks.recordHash.tap(PLUGIN_NAME, (records) => {
271
271
  // 4. save made splittings to records
272
272
  const allSplits = new Set();
273
273
  /** @type {Set<SplitData>} */
@@ -292,7 +292,7 @@ class AggressiveSplittingPlugin {
292
292
  records.aggressiveSplits =
293
293
  /** @type {SplitData[]} */
294
294
  (records.aggressiveSplits).filter(
295
- splitData => !invalidSplits.has(splitData)
295
+ (splitData) => !invalidSplits.has(splitData)
296
296
  );
297
297
  needAdditionalSeal = true;
298
298
  } else {
@@ -66,6 +66,7 @@ const {
66
66
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
67
67
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
68
68
  /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
69
+ /** @typedef {import("../ExternalModule")} ExternalModule */
69
70
  /** @typedef {import("../Module").BuildCallback} BuildCallback */
70
71
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
71
72
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
@@ -94,7 +95,6 @@ const {
94
95
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
95
96
  /** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
96
97
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
97
-
98
98
  /**
99
99
  * @template T
100
100
  * @typedef {import("../InitFragment")<T>} InitFragment
@@ -159,6 +159,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
159
159
  * @property {Map<string, string> | undefined} rawExportMap
160
160
  * @property {string=} namespaceExportSymbol
161
161
  * @property {string | undefined} namespaceObjectName
162
+ * @property {ConcatenationScope | undefined} concatenationScope
162
163
  * @property {boolean} interopNamespaceObjectUsed "default-with-named" namespace
163
164
  * @property {string | undefined} interopNamespaceObjectName "default-with-named" namespace
164
165
  * @property {boolean} interopNamespaceObject2Used "default-only" namespace
@@ -241,7 +242,7 @@ const moveDeferToLast = (
241
242
  * @param {Iterable<string>} iterable iterable object
242
243
  * @returns {string} joined iterable object
243
244
  */
244
- const joinIterableWithComma = iterable => {
245
+ const joinIterableWithComma = (iterable) => {
245
246
  // This is more performant than Array.from().join(", ")
246
247
  // as it doesn't create an array
247
248
  let str = "";
@@ -503,7 +504,7 @@ const getFinalBinding = (
503
504
  exportName
504
505
  };
505
506
  }
506
- const reexport = exportInfo.findTarget(moduleGraph, module =>
507
+ const reexport = exportInfo.findTarget(moduleGraph, (module) =>
507
508
  moduleToInfoMap.has(module)
508
509
  );
509
510
  if (reexport === false) {
@@ -668,6 +669,7 @@ const getFinalName = (
668
669
  /**
669
670
  * @typedef {object} ConcatenateModuleHooks
670
671
  * @property {SyncBailHook<[Record<string, string>, ConcatenatedModule], boolean | void>} exportsDefinitions
672
+ * @property {SyncBailHook<[Partial<ConcatenatedModuleInfo>, ConcatenatedModuleInfo], boolean | void>} concatenatedModuleInfo
671
673
  */
672
674
 
673
675
  /** @type {WeakMap<Compilation, ConcatenateModuleHooks>} */
@@ -714,7 +716,11 @@ class ConcatenatedModule extends Module {
714
716
  let hooks = compilationHooksMap.get(compilation);
715
717
  if (hooks === undefined) {
716
718
  hooks = {
717
- exportsDefinitions: new SyncBailHook(["definitions", "module"])
719
+ exportsDefinitions: new SyncBailHook(["definitions", "module"]),
720
+ concatenatedModuleInfo: new SyncBailHook([
721
+ "updatedInfo",
722
+ "concatenatedModuleInfo"
723
+ ])
718
724
  };
719
725
  compilationHooksMap.set(compilation, hooks);
720
726
  }
@@ -848,7 +854,7 @@ class ConcatenatedModule extends Module {
848
854
 
849
855
  // populate dependencies
850
856
  for (const d of m.dependencies.filter(
851
- dep =>
857
+ (dep) =>
852
858
  !(dep instanceof HarmonyImportDependency) ||
853
859
  !this._modules.has(
854
860
  /** @type {Module} */
@@ -945,13 +951,14 @@ class ConcatenatedModule extends Module {
945
951
  /** @type {Map<Module, RuntimeSpec | true>} */
946
952
  const existingEntries = new Map();
947
953
  const deferEnabled =
948
- this.compilation && this.compilation.options.experiments.deferImport;
954
+ /** @type {Compilation} */
955
+ (this.compilation).options.experiments.deferImport;
949
956
 
950
957
  /**
951
958
  * @param {Module} module a module
952
959
  * @returns {Iterable<{ connection: ModuleGraphConnection, runtimeCondition: RuntimeSpec | true }>} imported modules in order
953
960
  */
954
- const getConcatenatedImports = module => {
961
+ const getConcatenatedImports = (module) => {
955
962
  const connections = [...moduleGraph.getOutgoingConnections(module)];
956
963
  if (module === rootModule) {
957
964
  for (const c of moduleGraph.getOutgoingConnections(this)) {
@@ -962,7 +969,7 @@ class ConcatenatedModule extends Module {
962
969
  * @type {Array<{ connection: ModuleGraphConnection, sourceOrder: number, rangeStart: number, defer?: boolean }>}
963
970
  */
964
971
  const references = connections
965
- .filter(connection => {
972
+ .filter((connection) => {
966
973
  if (!(connection.dependency instanceof HarmonyImportDependency)) {
967
974
  return false;
968
975
  }
@@ -973,7 +980,7 @@ class ConcatenatedModule extends Module {
973
980
  connection.isTargetActive(runtime)
974
981
  );
975
982
  })
976
- .map(connection => {
983
+ .map((connection) => {
977
984
  const dep = /** @type {HarmonyImportDependency} */ (
978
985
  connection.dependency
979
986
  );
@@ -1009,7 +1016,7 @@ class ConcatenatedModule extends Module {
1009
1016
  /** @type {Map<Module, { connection: ModuleGraphConnection, runtimeCondition: RuntimeSpec | true }>} */
1010
1017
  const referencesMap = new Map();
1011
1018
  for (const { connection } of references) {
1012
- const runtimeCondition = filterRuntime(runtime, r =>
1019
+ const runtimeCondition = filterRuntime(runtime, (r) =>
1013
1020
  connection.isTargetActive(r)
1014
1021
  );
1015
1022
  if (runtimeCondition === false) continue;
@@ -1180,6 +1187,10 @@ class ConcatenatedModule extends Module {
1180
1187
  runtime: generationRuntime,
1181
1188
  codeGenerationResults
1182
1189
  }) {
1190
+ const { concatenatedModuleInfo } = ConcatenatedModule.getCompilationHooks(
1191
+ /** @type {Compilation} */ (this.compilation)
1192
+ );
1193
+
1183
1194
  /** @type {RuntimeRequirements} */
1184
1195
  const runtimeRequirements = new Set();
1185
1196
  const runtime = intersectRuntime(generationRuntime, this._runtime);
@@ -1195,6 +1206,9 @@ class ConcatenatedModule extends Module {
1195
1206
  /** @type {Set<ConcatenatedModuleInfo>} */
1196
1207
  const neededNamespaceObjects = new Set();
1197
1208
 
1209
+ // List of all used names to avoid conflicts
1210
+ const allUsedNames = new Set(RESERVED_NAMES);
1211
+
1198
1212
  // Generate source code and analyse scopes
1199
1213
  // Prepare a ReplaceSource for the final source
1200
1214
  for (const info of moduleToInfoMap.values()) {
@@ -1207,12 +1221,11 @@ class ConcatenatedModule extends Module {
1207
1221
  chunkGraph,
1208
1222
  runtime,
1209
1223
  /** @type {CodeGenerationResults} */
1210
- (codeGenerationResults)
1224
+ (codeGenerationResults),
1225
+ allUsedNames
1211
1226
  );
1212
1227
  }
1213
1228
 
1214
- // List of all used names to avoid conflicts
1215
- const allUsedNames = new Set(RESERVED_NAMES);
1216
1229
  // Updated Top level declarations are created by renaming
1217
1230
  /** @type {Set<string>} */
1218
1231
  const topLevelDeclarations = new Set();
@@ -1240,7 +1253,7 @@ class ConcatenatedModule extends Module {
1240
1253
  * @param {Scope} scope scope
1241
1254
  * @returns {{ range: Range, variables: Variable[] }[]} result
1242
1255
  */
1243
- const getSuperClassExpressions = scope => {
1256
+ const getSuperClassExpressions = (scope) => {
1244
1257
  const cacheEntry = superClassCache.get(scope);
1245
1258
  if (cacheEntry !== undefined) return cacheEntry;
1246
1259
  const superClassExpressions = [];
@@ -1321,6 +1334,75 @@ class ConcatenatedModule extends Module {
1321
1334
  }
1322
1335
  }
1323
1336
 
1337
+ /**
1338
+ * @param {string} name the name to find a new name for
1339
+ * @param {ConcatenatedModuleInfo} info the info of the module
1340
+ * @param {Reference[]} references the references to the name
1341
+ * @returns {string|undefined} the new name or undefined if the name is not found
1342
+ */
1343
+ const _findNewName = (name, info, references) => {
1344
+ const { usedNames, alreadyCheckedScopes } = getUsedNamesInScopeInfo(
1345
+ usedNamesInScopeInfo,
1346
+ info.module.identifier(),
1347
+ name
1348
+ );
1349
+ if (allUsedNames.has(name) || usedNames.has(name)) {
1350
+ for (const ref of references) {
1351
+ addScopeSymbols(
1352
+ ref.from,
1353
+ usedNames,
1354
+ alreadyCheckedScopes,
1355
+ ignoredScopes
1356
+ );
1357
+ }
1358
+ const newName = findNewName(
1359
+ name,
1360
+ allUsedNames,
1361
+ usedNames,
1362
+ info.module.readableIdentifier(requestShortener)
1363
+ );
1364
+ allUsedNames.add(newName);
1365
+ info.internalNames.set(name, newName);
1366
+ topLevelDeclarations.add(newName);
1367
+ return newName;
1368
+ }
1369
+ };
1370
+
1371
+ /**
1372
+ * @param {string} name the name to find a new name for
1373
+ * @param {ConcatenatedModuleInfo} info the info of the module
1374
+ * @param {Reference[]} references the references to the name
1375
+ * @returns {string|undefined} the new name or undefined if the name is not found
1376
+ */
1377
+ const _findNewNameForSpecifier = (name, info, references) => {
1378
+ const { usedNames: moduleUsedNames, alreadyCheckedScopes } =
1379
+ getUsedNamesInScopeInfo(
1380
+ usedNamesInScopeInfo,
1381
+ info.module.identifier(),
1382
+ name
1383
+ );
1384
+ const referencesUsedNames = new Set();
1385
+ for (const ref of references) {
1386
+ addScopeSymbols(
1387
+ ref.from,
1388
+ referencesUsedNames,
1389
+ alreadyCheckedScopes,
1390
+ ignoredScopes
1391
+ );
1392
+ }
1393
+ if (moduleUsedNames.has(name) || referencesUsedNames.has(name)) {
1394
+ const newName = findNewName(
1395
+ name,
1396
+ allUsedNames,
1397
+ new Set([...moduleUsedNames, ...referencesUsedNames]),
1398
+ info.module.readableIdentifier(requestShortener)
1399
+ );
1400
+ allUsedNames.add(newName);
1401
+ topLevelDeclarations.add(newName);
1402
+ return newName;
1403
+ }
1404
+ };
1405
+
1324
1406
  // generate names for symbols
1325
1407
  for (const info of moduleToInfoMap.values()) {
1326
1408
  const { usedNames: namespaceObjectUsedNames } = getUsedNamesInScopeInfo(
@@ -1333,33 +1415,12 @@ class ConcatenatedModule extends Module {
1333
1415
  const variables = /** @type {Scope} */ (info.moduleScope).variables;
1334
1416
  for (const variable of variables) {
1335
1417
  const name = variable.name;
1336
- const { usedNames, alreadyCheckedScopes } = getUsedNamesInScopeInfo(
1337
- usedNamesInScopeInfo,
1338
- info.module.identifier(),
1339
- name
1340
- );
1341
- if (allUsedNames.has(name) || usedNames.has(name)) {
1342
- const references = getAllReferences(variable);
1343
- for (const ref of references) {
1344
- addScopeSymbols(
1345
- ref.from,
1346
- usedNames,
1347
- alreadyCheckedScopes,
1348
- ignoredScopes
1349
- );
1350
- }
1351
- const newName = findNewName(
1352
- name,
1353
- allUsedNames,
1354
- usedNames,
1355
- info.module.readableIdentifier(requestShortener)
1356
- );
1357
- allUsedNames.add(newName);
1358
- info.internalNames.set(name, newName);
1359
- topLevelDeclarations.add(newName);
1418
+ const references = getAllReferences(variable);
1419
+ const newName = _findNewName(name, info, references);
1420
+ if (newName) {
1360
1421
  const source = /** @type {ReplaceSource} */ (info.source);
1361
1422
  const allIdentifiers = new Set([
1362
- ...references.map(r => r.identifier),
1423
+ ...references.map((r) => r.identifier),
1363
1424
  ...variable.identifiers
1364
1425
  ]);
1365
1426
  for (const identifier of allIdentifiers) {
@@ -1493,14 +1554,48 @@ class ConcatenatedModule extends Module {
1493
1554
  for (const info of moduleToInfoMap.values()) {
1494
1555
  if (info.type === "concatenated") {
1495
1556
  const globalScope = /** @type {Scope} */ (info.globalScope);
1557
+ // group references by name
1558
+ const referencesByName = new Map();
1496
1559
  for (const reference of globalScope.through) {
1497
1560
  const name = reference.identifier.name;
1561
+ if (!referencesByName.has(name)) {
1562
+ referencesByName.set(name, []);
1563
+ }
1564
+ referencesByName.get(name).push(reference);
1565
+ }
1566
+ for (const [name, references] of referencesByName) {
1498
1567
  const match = ConcatenationScope.matchModuleReference(name);
1499
1568
  if (match) {
1500
1569
  const referencedInfo = modulesWithInfo[match.index];
1501
1570
  if (referencedInfo.type === "reference") {
1502
1571
  throw new Error("Module reference can't point to a reference");
1503
1572
  }
1573
+ const concatenationScope = /** @type {ConcatenatedModuleInfo} */ (
1574
+ referencedInfo
1575
+ ).concatenationScope;
1576
+ const exportId = match.ids[0];
1577
+ const specifier =
1578
+ concatenationScope && concatenationScope.getRawExport(exportId);
1579
+ if (specifier) {
1580
+ const newName = _findNewNameForSpecifier(
1581
+ specifier,
1582
+ info,
1583
+ references
1584
+ );
1585
+ const initFragmentChanged =
1586
+ newName &&
1587
+ concatenatedModuleInfo.call(
1588
+ {
1589
+ rawExportMap: new Map([
1590
+ [exportId, /** @type {string} */ (newName)]
1591
+ ])
1592
+ },
1593
+ /** @type {ConcatenatedModuleInfo} */ (referencedInfo)
1594
+ );
1595
+ if (initFragmentChanged) {
1596
+ concatenationScope.setRawExportMap(exportId, newName);
1597
+ }
1598
+ }
1504
1599
  const finalName = getFinalName(
1505
1600
  moduleGraph,
1506
1601
  referencedInfo,
@@ -1517,10 +1612,13 @@ class ConcatenatedModule extends Module {
1517
1612
  (info.module.buildMeta).strictHarmonyModule,
1518
1613
  match.asiSafe
1519
1614
  );
1520
- const r = /** @type {Range} */ (reference.identifier.range);
1521
- const source = /** @type {ReplaceSource} */ (info.source);
1522
- // range is extended by 2 chars to cover the appended "._"
1523
- source.replace(r[0], r[1] + 1, finalName);
1615
+
1616
+ for (const reference of references) {
1617
+ const r = /** @type {Range} */ (reference.identifier.range);
1618
+ const source = /** @type {ReplaceSource} */ (info.source);
1619
+ // range is extended by 2 chars to cover the appended "._"
1620
+ source.replace(r[0], r[1] + 1, finalName);
1621
+ }
1524
1622
  }
1525
1623
  }
1526
1624
  }
@@ -1551,7 +1649,7 @@ class ConcatenatedModule extends Module {
1551
1649
  unusedExports.add(name);
1552
1650
  continue;
1553
1651
  }
1554
- exportsMap.set(used, requestShortener => {
1652
+ exportsMap.set(used, (requestShortener) => {
1555
1653
  try {
1556
1654
  const finalName = getFinalName(
1557
1655
  moduleGraph,
@@ -1712,7 +1810,8 @@ ${defineGetters}`
1712
1810
  /** @type {InitFragment<ChunkRenderContext>[]} */
1713
1811
  const chunkInitFragments = [];
1714
1812
  const deferEnabled =
1715
- this.compilation && this.compilation.options.experiments.deferImport;
1813
+ /** @type {Compilation} */
1814
+ (this.compilation).options.experiments.deferImport;
1716
1815
 
1717
1816
  // evaluate modules in order
1718
1817
  for (const rawInfo of modulesWithInfo) {
@@ -1738,7 +1837,8 @@ ${defineGetters}`
1738
1837
  if (moduleGraph.isDeferred(referredModule)) {
1739
1838
  const deferredModuleInfo = /** @type {ExternalModuleInfo} */ (
1740
1839
  modulesWithInfo.find(
1741
- i => i.type === "external" && i.module === referredModule
1840
+ (i) =>
1841
+ i.type === "external" && i.module === referredModule
1742
1842
  )
1743
1843
  );
1744
1844
  if (!deferredModuleInfo) continue;
@@ -1787,18 +1887,19 @@ ${defineGetters}`
1787
1887
  runtimeTemplate,
1788
1888
  info.module.getExportsType(
1789
1889
  moduleGraph,
1790
- this.rootModule.buildMeta &&
1791
- this.rootModule.buildMeta.strictHarmonyModule
1890
+ /** @type {BuildMeta} */
1891
+ (this.rootModule.buildMeta).strictHarmonyModule
1792
1892
  ),
1793
1893
  moduleId,
1794
1894
  // an async module will opt-out of the concat module optimization.
1795
1895
  []
1796
1896
  );
1797
1897
  result.add(`var ${info.deferredName} = ${loader};`);
1898
+ name = info.deferredName;
1798
1899
  } else {
1799
1900
  result.add(`var ${info.name} = __webpack_require__(${moduleId});`);
1901
+ name = info.name;
1800
1902
  }
1801
- name = info.name;
1802
1903
  break;
1803
1904
  }
1804
1905
  default:
@@ -1865,6 +1966,7 @@ ${defineGetters}`
1865
1966
  * @param {ChunkGraph} chunkGraph chunkGraph
1866
1967
  * @param {RuntimeSpec} runtime runtime
1867
1968
  * @param {CodeGenerationResults} codeGenerationResults codeGenerationResults
1969
+ * @param {Set<string>} usedNames used names
1868
1970
  */
1869
1971
  _analyseModule(
1870
1972
  modulesMap,
@@ -1874,13 +1976,18 @@ ${defineGetters}`
1874
1976
  moduleGraph,
1875
1977
  chunkGraph,
1876
1978
  runtime,
1877
- codeGenerationResults
1979
+ codeGenerationResults,
1980
+ usedNames
1878
1981
  ) {
1879
1982
  if (info.type === "concatenated") {
1880
1983
  const m = info.module;
1881
1984
  try {
1882
1985
  // Create a concatenation scope to track and capture information
1883
- const concatenationScope = new ConcatenationScope(modulesMap, info);
1986
+ const concatenationScope = new ConcatenationScope(
1987
+ modulesMap,
1988
+ info,
1989
+ usedNames
1990
+ );
1884
1991
 
1885
1992
  // TODO cache codeGeneration results
1886
1993
  const codeGenResult = m.codeGeneration({
@@ -1940,6 +2047,7 @@ ${defineGetters}`
1940
2047
  info.chunkInitFragments = chunkInitFragments;
1941
2048
  info.globalScope = globalScope;
1942
2049
  info.moduleScope = moduleScope;
2050
+ info.concatenationScope = concatenationScope;
1943
2051
  } catch (err) {
1944
2052
  /** @type {Error} */
1945
2053
  (err).message +=
@@ -1988,7 +2096,8 @@ ${defineGetters}`
1988
2096
  interopNamespaceObject2Used: false,
1989
2097
  interopNamespaceObject2Name: undefined,
1990
2098
  interopDefaultAccessUsed: false,
1991
- interopDefaultAccessName: undefined
2099
+ interopDefaultAccessName: undefined,
2100
+ concatenationScope: undefined
1992
2101
  };
1993
2102
  break;
1994
2103
  case "external":
@@ -20,11 +20,11 @@ class EnsureChunkConditionsPlugin {
20
20
  * @returns {void}
21
21
  */
22
22
  apply(compiler) {
23
- compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
23
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
24
24
  /**
25
25
  * @param {Iterable<Chunk>} chunks the chunks
26
26
  */
27
- const handler = chunks => {
27
+ const handler = (chunks) => {
28
28
  const chunkGraph = compilation.chunkGraph;
29
29
  // These sets are hoisted here to save memory
30
30
  // They are cleared at the end of every loop
@@ -21,8 +21,8 @@ class FlagIncludedChunksPlugin {
21
21
  * @returns {void}
22
22
  */
23
23
  apply(compiler) {
24
- compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
25
- compilation.hooks.optimizeChunkIds.tap(PLUGIN_NAME, chunks => {
24
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
25
+ compilation.hooks.optimizeChunkIds.tap(PLUGIN_NAME, (chunks) => {
26
26
  const chunkGraph = compilation.chunkGraph;
27
27
 
28
28
  // prepare two bit integers for each module
@@ -95,7 +95,7 @@ module.exports.addVariableUsage = (parser, name, usage) => {
95
95
  * @param {ParserState} parserState parser state
96
96
  * @returns {void}
97
97
  */
98
- module.exports.bailout = parserState => {
98
+ module.exports.bailout = (parserState) => {
99
99
  parserStateMap.set(parserState, false);
100
100
  };
101
101
 
@@ -103,7 +103,7 @@ module.exports.bailout = parserState => {
103
103
  * @param {ParserState} parserState parser state
104
104
  * @returns {void}
105
105
  */
106
- module.exports.enable = parserState => {
106
+ module.exports.enable = (parserState) => {
107
107
  const state = parserStateMap.get(parserState);
108
108
  if (state === false) {
109
109
  return;
@@ -148,7 +148,7 @@ module.exports.getDependencyUsedByExportsCondition = (
148
148
  * @param {ParserState} state parser state
149
149
  * @returns {TopLevelSymbol|void} usage data
150
150
  */
151
- module.exports.getTopLevelSymbol = state => {
151
+ module.exports.getTopLevelSymbol = (state) => {
152
152
  const innerGraphState = getState(state);
153
153
 
154
154
  if (innerGraphState) {
@@ -160,7 +160,7 @@ module.exports.getTopLevelSymbol = state => {
160
160
  * @param {ParserState} state parser state
161
161
  * @returns {void}
162
162
  */
163
- module.exports.inferDependencyUsage = state => {
163
+ module.exports.inferDependencyUsage = (state) => {
164
164
  const innerGraphState = getState(state);
165
165
 
166
166
  if (!innerGraphState) {
@@ -286,7 +286,7 @@ module.exports.isDependencyUsedByExports = (
286
286
  * @param {ParserState} parserState parser state
287
287
  * @returns {boolean} true, when enabled
288
288
  */
289
- module.exports.isEnabled = parserState => {
289
+ module.exports.isEnabled = (parserState) => {
290
290
  const state = parserStateMap.get(parserState);
291
291
  return Boolean(state);
292
292
  };
@@ -59,8 +59,8 @@ class InnerGraphPlugin {
59
59
  /**
60
60
  * @param {Expression} sup sup
61
61
  */
62
- const onUsageSuper = sup => {
63
- InnerGraph.onUsage(parser.state, usedByExports => {
62
+ const onUsageSuper = (sup) => {
63
+ InnerGraph.onUsage(parser.state, (usedByExports) => {
64
64
  switch (usedByExports) {
65
65
  case undefined:
66
66
  case true:
@@ -115,7 +115,7 @@ class InnerGraphPlugin {
115
115
 
116
116
  // The following hooks are used during prewalking:
117
117
 
118
- parser.hooks.preStatement.tap(PLUGIN_NAME, statement => {
118
+ parser.hooks.preStatement.tap(PLUGIN_NAME, (statement) => {
119
119
  if (!InnerGraph.isEnabled(parser.state)) return;
120
120
 
121
121
  if (
@@ -131,7 +131,7 @@ class InnerGraphPlugin {
131
131
  }
132
132
  });
133
133
 
134
- parser.hooks.blockPreStatement.tap(PLUGIN_NAME, statement => {
134
+ parser.hooks.blockPreStatement.tap(PLUGIN_NAME, (statement) => {
135
135
  if (!InnerGraph.isEnabled(parser.state)) return;
136
136
 
137
137
  if (parser.scope.topLevelScope === true) {
@@ -250,7 +250,7 @@ class InnerGraphPlugin {
250
250
 
251
251
  // The following hooks are called during walking:
252
252
 
253
- parser.hooks.statement.tap(PLUGIN_NAME, statement => {
253
+ parser.hooks.statement.tap(PLUGIN_NAME, (statement) => {
254
254
  if (!InnerGraph.isEnabled(parser.state)) return;
255
255
  if (parser.scope.topLevelScope === true) {
256
256
  InnerGraph.setTopLevelSymbol(parser.state, undefined);
@@ -260,7 +260,7 @@ class InnerGraphPlugin {
260
260
  InnerGraph.setTopLevelSymbol(parser.state, fn);
261
261
  const purePart = statementPurePart.get(statement);
262
262
  if (purePart) {
263
- InnerGraph.onUsage(parser.state, usedByExports => {
263
+ InnerGraph.onUsage(parser.state, (usedByExports) => {
264
264
  switch (usedByExports) {
265
265
  case undefined:
266
266
  case true:
@@ -336,7 +336,7 @@ class InnerGraphPlugin {
336
336
  ) {
337
337
  InnerGraph.setTopLevelSymbol(parser.state, fn);
338
338
  if (element.type !== "MethodDefinition" && element.static) {
339
- InnerGraph.onUsage(parser.state, usedByExports => {
339
+ InnerGraph.onUsage(parser.state, (usedByExports) => {
340
340
  switch (usedByExports) {
341
341
  case undefined:
342
342
  case true:
@@ -378,7 +378,7 @@ class InnerGraphPlugin {
378
378
  onUsageSuper(decl.init.superClass);
379
379
  }
380
380
  } else {
381
- InnerGraph.onUsage(parser.state, usedByExports => {
381
+ InnerGraph.onUsage(parser.state, (usedByExports) => {
382
382
  switch (usedByExports) {
383
383
  case undefined:
384
384
  case true:
@@ -433,10 +433,12 @@ class InnerGraphPlugin {
433
433
  currentTopLevelSymbol || true
434
434
  );
435
435
  });
436
- parser.hooks.assign.for(topLevelSymbolTag).tap(PLUGIN_NAME, expr => {
437
- if (!InnerGraph.isEnabled(parser.state)) return;
438
- if (expr.operator === "=") return true;
439
- });
436
+ parser.hooks.assign
437
+ .for(topLevelSymbolTag)
438
+ .tap(PLUGIN_NAME, (expr) => {
439
+ if (!InnerGraph.isEnabled(parser.state)) return;
440
+ if (expr.operator === "=") return true;
441
+ });
440
442
  };
441
443
  normalModuleFactory.hooks.parser
442
444
  .for(JAVASCRIPT_MODULE_TYPE_AUTO)