webpack 5.100.2 → 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 +126 -113
  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 +9 -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 +23 -23
  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 +35 -26
  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 +3 -3
  88. package/lib/asset/AssetGenerator.js +1 -1
  89. package/lib/asset/AssetModulesPlugin.js +6 -6
  90. package/lib/async-modules/AsyncModuleHelpers.js +1 -1
  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 -13
  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 +56 -48
  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 +80 -78
  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 +5 -5
  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 +85 -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 +10 -10
  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 +151 -44
@@ -73,7 +73,9 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
73
73
  render(source, { chunkGraph, moduleGraph, chunk }, { options, compilation }) {
74
74
  const modules = chunkGraph
75
75
  .getChunkModules(chunk)
76
- .filter(m => m instanceof ExternalModule && m.externalType === "system");
76
+ .filter(
77
+ (m) => m instanceof ExternalModule && m.externalType === "system"
78
+ );
77
79
  const externals = /** @type {ExternalModule[]} */ (modules);
78
80
 
79
81
  // The name this bundle should be registered as with System
@@ -83,7 +85,7 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
83
85
 
84
86
  // The array of dependencies that are external to webpack and will be provided by System
85
87
  const systemDependencies = JSON.stringify(
86
- externals.map(m =>
88
+ externals.map((m) =>
87
89
  typeof m.request === "object" && !Array.isArray(m.request)
88
90
  ? m.request.amd
89
91
  : m.request
@@ -95,7 +97,7 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
95
97
 
96
98
  // An array of the internal variable names for the webpack externals
97
99
  const externalWebpackNames = externals.map(
98
- m =>
100
+ (m) =>
99
101
  `__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(
100
102
  `${chunkGraph.getModuleId(m)}`
101
103
  )}__`
@@ -103,7 +105,7 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
103
105
 
104
106
  // Declaring variables for the internal variable names for the webpack externals
105
107
  const externalVarDeclarations = externalWebpackNames
106
- .map(name => `var ${name} = {};`)
108
+ .map((name) => `var ${name} = {};`)
107
109
  .join("\n");
108
110
 
109
111
  // Define __esModule flag on all internal variables and helpers
@@ -30,8 +30,8 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
30
30
  * @param {string[]} accessor the accessor to convert to path
31
31
  * @returns {string} the path
32
32
  */
33
- const accessorToObjectAccess = accessor =>
34
- accessor.map(a => `[${JSON.stringify(a)}]`).join("");
33
+ const accessorToObjectAccess = (accessor) =>
34
+ accessor.map((a) => `[${JSON.stringify(a)}]`).join("");
35
35
 
36
36
  /**
37
37
  * @param {string|undefined} base the path prefix
@@ -131,7 +131,7 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
131
131
  const modules = chunkGraph
132
132
  .getChunkModules(chunk)
133
133
  .filter(
134
- m =>
134
+ (m) =>
135
135
  m instanceof ExternalModule &&
136
136
  (m.externalType === "umd" || m.externalType === "umd2")
137
137
  );
@@ -157,7 +157,7 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
157
157
  * @param {string} str the string to replace
158
158
  * @returns {string} the replaced keys
159
159
  */
160
- const replaceKeys = str =>
160
+ const replaceKeys = (str) =>
161
161
  compilation.getPath(str, {
162
162
  chunk
163
163
  });
@@ -166,10 +166,10 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
166
166
  * @param {ExternalModule[]} modules external modules
167
167
  * @returns {string} result
168
168
  */
169
- const externalsDepsArray = modules =>
169
+ const externalsDepsArray = (modules) =>
170
170
  `[${replaceKeys(
171
171
  modules
172
- .map(m =>
172
+ .map((m) =>
173
173
  JSON.stringify(
174
174
  typeof m.request === "object"
175
175
  ? /** @type {RequestRecord} */
@@ -184,10 +184,10 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
184
184
  * @param {ExternalModule[]} modules external modules
185
185
  * @returns {string} result
186
186
  */
187
- const externalsRootArray = modules =>
187
+ const externalsRootArray = (modules) =>
188
188
  replaceKeys(
189
189
  modules
190
- .map(m => {
190
+ .map((m) => {
191
191
  let request = m.request;
192
192
  if (typeof request === "object") {
193
193
  request =
@@ -206,10 +206,10 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
206
206
  * @param {string} type the type
207
207
  * @returns {string} external require array
208
208
  */
209
- const externalsRequireArray = type =>
209
+ const externalsRequireArray = (type) =>
210
210
  replaceKeys(
211
211
  externals
212
- .map(m => {
212
+ .map((m) => {
213
213
  let expr;
214
214
  let request = m.request;
215
215
  if (typeof request === "object") {
@@ -239,10 +239,10 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
239
239
  * @param {ExternalModule[]} modules external modules
240
240
  * @returns {string} arguments
241
241
  */
242
- const externalsArguments = modules =>
242
+ const externalsArguments = (modules) =>
243
243
  modules
244
244
  .map(
245
- m =>
245
+ (m) =>
246
246
  `__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(
247
247
  `${chunkGraph.getModuleId(m)}`
248
248
  )}__`
@@ -253,7 +253,7 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
253
253
  * @param {string| string[]} library library name
254
254
  * @returns {string} stringified library name
255
255
  */
256
- const libraryName = library =>
256
+ const libraryName = (library) =>
257
257
  JSON.stringify(
258
258
  replaceKeys(
259
259
  /** @type {string} */
@@ -287,7 +287,7 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
287
287
  * @param {keyof LibraryCustomUmdCommentObject} type type
288
288
  * @returns {string} comment
289
289
  */
290
- const getAuxiliaryComment = type => {
290
+ const getAuxiliaryComment = (type) => {
291
291
  if (auxiliaryComment) {
292
292
  if (typeof auxiliaryComment === "string") {
293
293
  return `\t//${auxiliaryComment}\n`;
@@ -43,15 +43,15 @@ const { LogType } = require("./Logger");
43
43
  * @param {FilterItemTypes} item an input item
44
44
  * @returns {FilterFunction | undefined} filter function
45
45
  */
46
- const filterToFunction = item => {
46
+ const filterToFunction = (item) => {
47
47
  if (typeof item === "string") {
48
48
  const regExp = new RegExp(
49
49
  `[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, "\\$&")}([\\\\/]|$|!|\\?)`
50
50
  );
51
- return ident => regExp.test(ident);
51
+ return (ident) => regExp.test(ident);
52
52
  }
53
53
  if (item && typeof item === "object" && typeof item.test === "function") {
54
- return ident => item.test(ident);
54
+ return (ident) => item.test(ident);
55
55
  }
56
56
  if (typeof item === "function") {
57
57
  return item;
@@ -107,7 +107,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
107
107
  }
108
108
  return [];
109
109
  };
110
- const debug = debugFilters.some(f => f(name));
110
+ const debug = debugFilters.some((f) => f(name));
111
111
  switch (type) {
112
112
  case LogType.debug:
113
113
  if (!debug) return;
@@ -21,7 +21,7 @@ let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
21
21
  * @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
22
22
  * @returns {void}
23
23
  */
24
- module.exports.configureDefaultLogger = options => {
24
+ module.exports.configureDefaultLogger = (options) => {
25
25
  Object.assign(currentDefaultLoggerOptions, options);
26
26
  currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
27
27
  };
@@ -30,14 +30,14 @@ module.exports.configureDefaultLogger = options => {
30
30
  * @param {string} name name of the logger
31
31
  * @returns {Logger} a logger
32
32
  */
33
- module.exports.getLogger = name =>
33
+ module.exports.getLogger = (name) =>
34
34
  new Logger(
35
35
  (type, args) => {
36
36
  if (module.exports.hooks.log.call(name, type, args) === undefined) {
37
37
  currentDefaultLogger(name, type, args);
38
38
  }
39
39
  },
40
- childName => module.exports.getLogger(`${name}/${childName}`)
40
+ (childName) => module.exports.getLogger(`${name}/${childName}`)
41
41
  );
42
42
 
43
43
  module.exports.hooks = {
@@ -9,7 +9,7 @@
9
9
  * @param {Array<number>} array array of numbers
10
10
  * @returns {number} sum of all numbers in array
11
11
  */
12
- const arraySum = array => {
12
+ const arraySum = (array) => {
13
13
  let sum = 0;
14
14
  for (const item of array) sum += item;
15
15
  return sum;
@@ -21,7 +21,7 @@ const arraySum = array => {
21
21
  * @returns {string[]} truncated args
22
22
  */
23
23
  const truncateArgs = (args, maxLength) => {
24
- const lengths = args.map(a => `${a}`.length);
24
+ const lengths = args.map((a) => `${a}`.length);
25
25
  const availableLength = maxLength - lengths.length + 1;
26
26
 
27
27
  if (availableLength > 0 && args.length === 1) {
@@ -34,7 +34,7 @@ const truncateArgs = (args, maxLength) => {
34
34
  }
35
35
 
36
36
  // Check if there is space for at least 4 chars per arg
37
- if (availableLength < arraySum(lengths.map(i => Math.min(i, 6)))) {
37
+ if (availableLength < arraySum(lengths.map((i) => Math.min(i, 6)))) {
38
38
  // remove args
39
39
  if (args.length > 1) return truncateArgs(args.slice(0, -1), maxLength);
40
40
  return [];
@@ -48,7 +48,7 @@ const truncateArgs = (args, maxLength) => {
48
48
  // Try to remove chars from the longest items until it fits
49
49
  while (currentLength > availableLength) {
50
50
  const maxLength = Math.max(...lengths);
51
- const shorterItems = lengths.filter(l => l !== maxLength);
51
+ const shorterItems = lengths.filter((l) => l !== maxLength);
52
52
  const nextToMaxLength =
53
53
  shorterItems.length > 0 ? Math.max(...shorterItems) : 0;
54
54
  const maxReduce = maxLength - nextToMaxLength;
@@ -42,13 +42,13 @@ class CommonJsChunkLoadingPlugin {
42
42
  chunkLoading: chunkLoadingValue,
43
43
  asyncChunkLoading: this._asyncChunkLoading
44
44
  }).apply(compiler);
45
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
45
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
46
46
  const globalChunkLoading = compilation.outputOptions.chunkLoading;
47
47
  /**
48
48
  * @param {Chunk} chunk chunk
49
49
  * @returns {boolean} true, if wasm loading is enabled for the chunk
50
50
  */
51
- const isEnabledForChunk = chunk => {
51
+ const isEnabledForChunk = (chunk) => {
52
52
  const options = chunk.getEntryOptions();
53
53
  const chunkLoading =
54
54
  options && options.chunkLoading !== undefined
@@ -57,7 +57,7 @@ class NodeEnvironmentPlugin {
57
57
  compiler.outputFileSystem = fs;
58
58
  compiler.intermediateFileSystem = fs;
59
59
  compiler.watchFileSystem = new NodeWatchFileSystem(inputFileSystem);
60
- compiler.hooks.beforeRun.tap(PLUGIN_NAME, compiler => {
60
+ compiler.hooks.beforeRun.tap(PLUGIN_NAME, (compiler) => {
61
61
  if (
62
62
  compiler.inputFileSystem === inputFileSystem &&
63
63
  inputFileSystem.purge
@@ -21,6 +21,7 @@ const { getUndoPath } = require("../util/identifier");
21
21
  /** @typedef {import("../Chunk")} Chunk */
22
22
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
23
23
  /** @typedef {import("../Compilation")} Compilation */
24
+ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
24
25
  /** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
25
26
 
26
27
  class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
@@ -36,15 +37,16 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
36
37
  * @private
37
38
  * @param {Chunk} chunk chunk
38
39
  * @param {string} rootOutputDir root output directory
40
+ * @param {RuntimeTemplate} runtimeTemplate the runtime template
39
41
  * @returns {string} generated code
40
42
  */
41
- _generateBaseUri(chunk, rootOutputDir) {
43
+ _generateBaseUri(chunk, rootOutputDir, runtimeTemplate) {
42
44
  const options = chunk.getEntryOptions();
43
45
  if (options && options.baseUri) {
44
46
  return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
45
47
  }
46
48
 
47
- return `${RuntimeGlobals.baseURI} = require("url").pathToFileURL(${
49
+ return `${RuntimeGlobals.baseURI} = require(${runtimeTemplate.renderNodePrefixForCoreModule("url")}).pathToFileURL(${
48
50
  rootOutputDir
49
51
  ? `__dirname + ${JSON.stringify(`/${rootOutputDir}`)}`
50
52
  : "__filename"
@@ -99,7 +101,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
99
101
 
100
102
  return Template.asString([
101
103
  withBaseURI
102
- ? this._generateBaseUri(chunk, rootOutputDir)
104
+ ? this._generateBaseUri(chunk, rootOutputDir, runtimeTemplate)
103
105
  : "// no baseURI",
104
106
  "",
105
107
  "// object to store loaded chunks",
@@ -108,7 +110,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
108
110
  stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
109
111
  }{`,
110
112
  Template.indent(
111
- Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 0`).join(
113
+ Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(
112
114
  ",\n"
113
115
  )
114
116
  ),
@@ -171,17 +173,17 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
171
173
  "var promise = new Promise(function(resolve, reject) {",
172
174
  Template.indent([
173
175
  "installedChunkData = installedChunks[chunkId] = [resolve, reject];",
174
- `var filename = require('path').join(__dirname, ${JSON.stringify(
176
+ `var filename = require(${runtimeTemplate.renderNodePrefixForCoreModule("path")}).join(__dirname, ${JSON.stringify(
175
177
  rootOutputDir
176
178
  )} + ${
177
179
  RuntimeGlobals.getChunkScriptFilename
178
180
  }(chunkId));`,
179
- "require('fs').readFile(filename, 'utf-8', function(err, content) {",
181
+ `require(${runtimeTemplate.renderNodePrefixForCoreModule("fs")}).readFile(filename, 'utf-8', function(err, content) {`,
180
182
  Template.indent([
181
183
  "if(err) return reject(err);",
182
184
  "var chunk = {};",
183
- "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
184
- "(chunk, require, require('path').dirname(filename), filename);",
185
+ `require(${runtimeTemplate.renderNodePrefixForCoreModule("vm")}).runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)` +
186
+ `(chunk, require, require(${runtimeTemplate.renderNodePrefixForCoreModule("path")}).dirname(filename), filename);`,
185
187
  "installChunk(chunk);"
186
188
  ]),
187
189
  "});"
@@ -215,15 +217,15 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
215
217
  Template.indent([
216
218
  "return new Promise(function(resolve, reject) {",
217
219
  Template.indent([
218
- `var filename = require('path').join(__dirname, ${JSON.stringify(
220
+ `var filename = require(${runtimeTemplate.renderNodePrefixForCoreModule("path")}).join(__dirname, ${JSON.stringify(
219
221
  rootOutputDir
220
222
  )} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
221
- "require('fs').readFile(filename, 'utf-8', function(err, content) {",
223
+ `require(${runtimeTemplate.renderNodePrefixForCoreModule("fs")}).readFile(filename, 'utf-8', function(err, content) {`,
222
224
  Template.indent([
223
225
  "if(err) return reject(err);",
224
226
  "var update = {};",
225
- "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
226
- "(update, require, require('path').dirname(filename), filename);",
227
+ `require(${runtimeTemplate.renderNodePrefixForCoreModule("vm")}).runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)` +
228
+ `(update, require, require(${runtimeTemplate.renderNodePrefixForCoreModule("path")}).dirname(filename), filename);`,
227
229
  "var updatedModules = update.modules;",
228
230
  "var runtime = update.runtime;",
229
231
  "for(var moduleId in updatedModules) {",
@@ -255,10 +257,10 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
255
257
  Template.indent([
256
258
  "return new Promise(function(resolve, reject) {",
257
259
  Template.indent([
258
- `var filename = require('path').join(__dirname, ${JSON.stringify(
260
+ `var filename = require(${runtimeTemplate.renderNodePrefixForCoreModule("path")}).join(__dirname, ${JSON.stringify(
259
261
  rootOutputDir
260
262
  )} + ${RuntimeGlobals.getUpdateManifestFilename}());`,
261
- "require('fs').readFile(filename, 'utf-8', function(err, content) {",
263
+ `require(${runtimeTemplate.renderNodePrefixForCoreModule("fs")}).readFile(filename, 'utf-8', function(err, content) {`,
262
264
  Template.indent([
263
265
  "if(err) {",
264
266
  Template.indent([
@@ -34,13 +34,13 @@ class ReadFileCompileAsyncWasmPlugin {
34
34
  * @returns {void}
35
35
  */
36
36
  apply(compiler) {
37
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
37
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
38
38
  const globalWasmLoading = compilation.outputOptions.wasmLoading;
39
39
  /**
40
40
  * @param {Chunk} chunk chunk
41
41
  * @returns {boolean} true, if wasm loading is enabled for the chunk
42
42
  */
43
- const isEnabledForChunk = chunk => {
43
+ const isEnabledForChunk = (chunk) => {
44
44
  const options = chunk.getEntryOptions();
45
45
  const wasmLoading =
46
46
  options && options.wasmLoading !== undefined
@@ -53,7 +53,7 @@ class ReadFileCompileAsyncWasmPlugin {
53
53
  * @type {(path: string) => string} callback to generate code to load the wasm file
54
54
  */
55
55
  const generateLoadBinaryCode = this._import
56
- ? path =>
56
+ ? (path) =>
57
57
  Template.asString([
58
58
  "Promise.all([import('fs'), import('url')]).then(([{ readFile }, { URL }]) => new Promise((resolve, reject) => {",
59
59
  Template.indent([
@@ -70,14 +70,14 @@ class ReadFileCompileAsyncWasmPlugin {
70
70
  ]),
71
71
  "}))"
72
72
  ])
73
- : path =>
73
+ : (path) =>
74
74
  Template.asString([
75
75
  "new Promise(function (resolve, reject) {",
76
76
  Template.indent([
77
77
  "try {",
78
78
  Template.indent([
79
- "var { readFile } = require('fs');",
80
- "var { join } = require('path');",
79
+ `var { readFile } = require(${compilation.runtimeTemplate.renderNodePrefixForCoreModule("fs")});`,
80
+ `var { join } = require(${compilation.runtimeTemplate.renderNodePrefixForCoreModule("path")});`,
81
81
  "",
82
82
  `readFile(join(__dirname, ${path}), function(err, buffer){`,
83
83
  Template.indent([
@@ -102,7 +102,7 @@ class ReadFileCompileAsyncWasmPlugin {
102
102
  if (
103
103
  !chunkGraph.hasModuleInGraph(
104
104
  chunk,
105
- m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
105
+ (m) => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
106
106
  )
107
107
  ) {
108
108
  return;
@@ -37,13 +37,13 @@ class ReadFileCompileWasmPlugin {
37
37
  * @returns {void}
38
38
  */
39
39
  apply(compiler) {
40
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
40
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
41
41
  const globalWasmLoading = compilation.outputOptions.wasmLoading;
42
42
  /**
43
43
  * @param {Chunk} chunk chunk
44
44
  * @returns {boolean} true, when wasm loading is enabled for the chunk
45
45
  */
46
- const isEnabledForChunk = chunk => {
46
+ const isEnabledForChunk = (chunk) => {
47
47
  const options = chunk.getEntryOptions();
48
48
  const wasmLoading =
49
49
  options && options.wasmLoading !== undefined
@@ -56,7 +56,7 @@ class ReadFileCompileWasmPlugin {
56
56
  * @type {(path: string) => string} callback to generate code to load the wasm file
57
57
  */
58
58
  const generateLoadBinaryCode = this.options.import
59
- ? path =>
59
+ ? (path) =>
60
60
  Template.asString([
61
61
  "Promise.all([import('fs'), import('url')]).then(([{ readFile }, { URL }]) => new Promise((resolve, reject) => {",
62
62
  Template.indent([
@@ -73,12 +73,12 @@ class ReadFileCompileWasmPlugin {
73
73
  ]),
74
74
  "}))"
75
75
  ])
76
- : path =>
76
+ : (path) =>
77
77
  Template.asString([
78
78
  "new Promise(function (resolve, reject) {",
79
79
  Template.indent([
80
- "var { readFile } = require('fs');",
81
- "var { join } = require('path');",
80
+ `var { readFile } = require(${compilation.runtimeTemplate.renderNodePrefixForCoreModule("fs")});`,
81
+ `var { join } = require(${compilation.runtimeTemplate.renderNodePrefixForCoreModule("path")});`,
82
82
  "",
83
83
  "try {",
84
84
  Template.indent([
@@ -105,7 +105,7 @@ class ReadFileCompileWasmPlugin {
105
105
  if (
106
106
  !chunkGraph.hasModuleInGraph(
107
107
  chunk,
108
- m => m.type === WEBASSEMBLY_MODULE_TYPE_SYNC
108
+ (m) => m.type === WEBASSEMBLY_MODULE_TYPE_SYNC
109
109
  )
110
110
  ) {
111
111
  return;
@@ -21,6 +21,7 @@ const { getUndoPath } = require("../util/identifier");
21
21
  /** @typedef {import("../Chunk")} Chunk */
22
22
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
23
23
  /** @typedef {import("../Compilation")} Compilation */
24
+ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
24
25
  /** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
25
26
 
26
27
  class RequireChunkLoadingRuntimeModule extends RuntimeModule {
@@ -36,15 +37,16 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
36
37
  * @private
37
38
  * @param {Chunk} chunk chunk
38
39
  * @param {string} rootOutputDir root output directory
40
+ * @param {RuntimeTemplate} runtimeTemplate the runtime template
39
41
  * @returns {string} generated code
40
42
  */
41
- _generateBaseUri(chunk, rootOutputDir) {
43
+ _generateBaseUri(chunk, rootOutputDir, runtimeTemplate) {
42
44
  const options = chunk.getEntryOptions();
43
45
  if (options && options.baseUri) {
44
46
  return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
45
47
  }
46
48
 
47
- return `${RuntimeGlobals.baseURI} = require("url").pathToFileURL(${
49
+ return `${RuntimeGlobals.baseURI} = require(${runtimeTemplate.renderNodePrefixForCoreModule("url")}).pathToFileURL(${
48
50
  rootOutputDir !== "./"
49
51
  ? `__dirname + ${JSON.stringify(`/${rootOutputDir}`)}`
50
52
  : "__filename"
@@ -99,7 +101,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
99
101
 
100
102
  return Template.asString([
101
103
  withBaseURI
102
- ? this._generateBaseUri(chunk, rootOutputDir)
104
+ ? this._generateBaseUri(chunk, rootOutputDir, runtimeTemplate)
103
105
  : "// no baseURI",
104
106
  "",
105
107
  "// object to store loaded chunks",
@@ -108,7 +110,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
108
110
  stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
109
111
  }{`,
110
112
  Template.indent(
111
- Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 1`).join(
113
+ Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 1`).join(
112
114
  ",\n"
113
115
  )
114
116
  ),
@@ -130,8 +130,8 @@ module.exports = ({ colors, appendOnly, stream }) => {
130
130
  currentIndent = currentIndent.slice(0, -2);
131
131
  }
132
132
  },
133
- profile: console.profile && (name => console.profile(name)),
134
- profileEnd: console.profileEnd && (name => console.profileEnd(name)),
133
+ profile: console.profile && ((name) => console.profile(name)),
134
+ profileEnd: console.profileEnd && ((name) => console.profileEnd(name)),
135
135
  clear:
136
136
  /** @type {() => void} */
137
137
  (
@@ -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 {