webpack 5.100.2 → 5.101.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) 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 +63 -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 +168 -116
  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/Dependency.js +2 -1
  26. package/lib/DllEntryPlugin.js +1 -1
  27. package/lib/DllReferencePlugin.js +1 -1
  28. package/lib/DynamicEntryPlugin.js +3 -3
  29. package/lib/EntryPlugin.js +1 -1
  30. package/lib/EnvironmentPlugin.js +1 -1
  31. package/lib/ErrorHelpers.js +2 -2
  32. package/lib/EvalDevToolModulePlugin.js +2 -2
  33. package/lib/EvalSourceMapDevToolPlugin.js +5 -5
  34. package/lib/ExportsInfo.js +9 -9
  35. package/lib/ExportsInfoApiPlugin.js +2 -2
  36. package/lib/ExternalModule.js +163 -48
  37. package/lib/ExternalModuleFactoryPlugin.js +2 -2
  38. package/lib/ExternalsPlugin.js +45 -0
  39. package/lib/FileSystemInfo.js +64 -61
  40. package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
  41. package/lib/FlagDependencyExportsPlugin.js +7 -7
  42. package/lib/FlagDependencyUsagePlugin.js +4 -4
  43. package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
  44. package/lib/HotModuleReplacementPlugin.js +27 -27
  45. package/lib/IgnorePlugin.js +3 -3
  46. package/lib/IgnoreWarningsPlugin.js +4 -4
  47. package/lib/InitFragment.js +6 -0
  48. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  49. package/lib/JavascriptMetaInfoPlugin.js +1 -1
  50. package/lib/LibManifestPlugin.js +2 -2
  51. package/lib/LoaderOptionsPlugin.js +1 -1
  52. package/lib/LoaderTargetPlugin.js +2 -2
  53. package/lib/MainTemplate.js +1 -1
  54. package/lib/Module.js +3 -2
  55. package/lib/ModuleFilenameHelpers.js +3 -3
  56. package/lib/ModuleGraph.js +23 -38
  57. package/lib/ModuleInfoHeaderPlugin.js +3 -3
  58. package/lib/ModuleParseError.js +5 -3
  59. package/lib/ModuleTemplate.js +3 -2
  60. package/lib/MultiCompiler.js +29 -24
  61. package/lib/MultiStats.js +18 -13
  62. package/lib/MultiWatching.js +1 -1
  63. package/lib/NoEmitOnErrorsPlugin.js +2 -2
  64. package/lib/NodeStuffPlugin.js +27 -15
  65. package/lib/NormalModule.js +23 -23
  66. package/lib/NormalModuleFactory.js +23 -21
  67. package/lib/NormalModuleReplacementPlugin.js +3 -3
  68. package/lib/PrefetchPlugin.js +1 -1
  69. package/lib/ProgressPlugin.js +11 -11
  70. package/lib/ProvidePlugin.js +2 -2
  71. package/lib/RecordIdsPlugin.js +3 -3
  72. package/lib/ResolverFactory.js +3 -3
  73. package/lib/RuntimeGlobals.js +20 -0
  74. package/lib/RuntimePlugin.js +16 -16
  75. package/lib/RuntimeTemplate.js +35 -26
  76. package/lib/SizeFormatHelpers.js +1 -1
  77. package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -4
  78. package/lib/SourceMapDevToolPlugin.js +9 -9
  79. package/lib/Stats.js +2 -2
  80. package/lib/Template.js +1 -1
  81. package/lib/TemplatedPathPlugin.js +2 -2
  82. package/lib/UseStrictPlugin.js +1 -1
  83. package/lib/WarnCaseSensitiveModulesPlugin.js +1 -1
  84. package/lib/WarnDeprecatedOptionPlugin.js +1 -1
  85. package/lib/WarnNoModeSetPlugin.js +1 -1
  86. package/lib/WatchIgnorePlugin.js +2 -2
  87. package/lib/Watching.js +12 -14
  88. package/lib/WebpackIsIncludedPlugin.js +2 -2
  89. package/lib/WebpackOptionsApply.js +3 -3
  90. package/lib/asset/AssetGenerator.js +1 -1
  91. package/lib/asset/AssetModulesPlugin.js +6 -6
  92. package/lib/async-modules/AsyncModuleHelpers.js +1 -1
  93. package/lib/async-modules/AwaitDependenciesInitFragment.js +36 -24
  94. package/lib/async-modules/InferAsyncModulesPlugin.js +3 -3
  95. package/lib/buildChunkGraph.js +5 -5
  96. package/lib/cache/AddBuildDependenciesPlugin.js +1 -1
  97. package/lib/cache/IdleFileCachePlugin.js +5 -5
  98. package/lib/cache/PackFileCacheStrategy.js +20 -20
  99. package/lib/cache/ResolverCachePlugin.js +4 -4
  100. package/lib/cli.js +196 -14
  101. package/lib/config/browserslistTargetHandler.js +6 -6
  102. package/lib/config/defaults.js +23 -14
  103. package/lib/config/normalization.js +41 -38
  104. package/lib/config/target.js +4 -4
  105. package/lib/container/ContainerEntryModule.js +3 -3
  106. package/lib/container/ContainerPlugin.js +3 -3
  107. package/lib/container/ContainerReferencePlugin.js +3 -3
  108. package/lib/container/FallbackModule.js +1 -1
  109. package/lib/container/HoistContainerReferencesPlugin.js +7 -7
  110. package/lib/container/options.js +4 -4
  111. package/lib/css/CssGenerator.js +5 -3
  112. package/lib/css/CssLoadingRuntimeModule.js +1 -1
  113. package/lib/css/CssModulesPlugin.js +25 -22
  114. package/lib/css/CssParser.js +5 -5
  115. package/lib/css/walkCssTokens.js +9 -9
  116. package/lib/debug/ProfilingPlugin.js +5 -5
  117. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -4
  118. package/lib/dependencies/AMDPlugin.js +3 -3
  119. package/lib/dependencies/AMDRequireArrayDependency.js +1 -1
  120. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +3 -3
  121. package/lib/dependencies/CommonJsExportRequireDependency.js +2 -2
  122. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -10
  123. package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -19
  124. package/lib/dependencies/CommonJsPlugin.js +2 -2
  125. package/lib/dependencies/ContextDependency.js +1 -1
  126. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  127. package/lib/dependencies/CssIcssExportDependency.js +2 -2
  128. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  129. package/lib/dependencies/CssUrlDependency.js +4 -4
  130. package/lib/dependencies/DynamicExports.js +5 -5
  131. package/lib/dependencies/HarmonyAcceptDependency.js +91 -5
  132. package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
  133. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -13
  134. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -8
  135. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  136. package/lib/dependencies/HarmonyExports.js +1 -1
  137. package/lib/dependencies/HarmonyImportDependency.js +28 -9
  138. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +56 -48
  139. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -5
  140. package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -4
  141. package/lib/dependencies/HarmonyModulesPlugin.js +2 -8
  142. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
  143. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -4
  144. package/lib/dependencies/ImportMetaPlugin.js +7 -7
  145. package/lib/dependencies/ImportParserPlugin.js +4 -4
  146. package/lib/dependencies/JsonExportsDependency.js +7 -2
  147. package/lib/dependencies/LoaderPlugin.js +4 -4
  148. package/lib/dependencies/ModuleDependency.js +2 -1
  149. package/lib/dependencies/ProvidedDependency.js +2 -2
  150. package/lib/dependencies/PureExpressionDependency.js +1 -1
  151. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  152. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
  153. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -3
  154. package/lib/dependencies/SystemPlugin.js +3 -3
  155. package/lib/dependencies/WorkerPlugin.js +5 -5
  156. package/lib/dependencies/getFunctionExpression.js +1 -1
  157. package/lib/esm/ExportWebpackRequireRuntimeModule.js +8 -1
  158. package/lib/esm/ModuleChunkFormatPlugin.js +35 -69
  159. package/lib/esm/ModuleChunkLoadingPlugin.js +3 -6
  160. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -11
  161. package/lib/formatLocation.js +2 -2
  162. package/lib/hmr/HotModuleReplacement.runtime.js +39 -27
  163. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -32
  164. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -1
  165. package/lib/hmr/LazyCompilationPlugin.js +6 -6
  166. package/lib/hmr/lazyCompilationBackend.js +6 -6
  167. package/lib/ids/ChunkModuleIdRangePlugin.js +4 -4
  168. package/lib/ids/DeterministicChunkIdsPlugin.js +5 -4
  169. package/lib/ids/DeterministicModuleIdsPlugin.js +2 -2
  170. package/lib/ids/HashedModuleIdsPlugin.js +1 -1
  171. package/lib/ids/IdHelpers.js +9 -9
  172. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  173. package/lib/ids/NamedModuleIdsPlugin.js +2 -2
  174. package/lib/ids/NaturalChunkIdsPlugin.js +2 -2
  175. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  176. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  177. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -4
  178. package/lib/ids/SyncModuleIdsPlugin.js +4 -4
  179. package/lib/index.js +18 -6
  180. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
  181. package/lib/javascript/BasicEvaluatedExpression.js +3 -3
  182. package/lib/javascript/ChunkFormatHelpers.js +70 -0
  183. package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -21
  184. package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
  185. package/lib/javascript/JavascriptGenerator.js +1 -1
  186. package/lib/javascript/JavascriptModulesPlugin.js +108 -54
  187. package/lib/javascript/JavascriptParser.js +80 -78
  188. package/lib/javascript/JavascriptParserHelpers.js +3 -3
  189. package/lib/javascript/StartupHelpers.js +2 -2
  190. package/lib/json/JsonGenerator.js +2 -2
  191. package/lib/json/JsonModulesPlugin.js +2 -2
  192. package/lib/library/AbstractLibraryPlugin.js +30 -3
  193. package/lib/library/AmdLibraryPlugin.js +3 -3
  194. package/lib/library/AssignLibraryPlugin.js +2 -2
  195. package/lib/library/EnableLibraryPlugin.js +2 -2
  196. package/lib/library/ModuleLibraryPlugin.js +49 -31
  197. package/lib/library/SystemLibraryPlugin.js +6 -4
  198. package/lib/library/UmdLibraryPlugin.js +14 -14
  199. package/lib/logging/createConsoleLogger.js +4 -4
  200. package/lib/logging/runtime.js +3 -3
  201. package/lib/logging/truncateArgs.js +4 -4
  202. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
  203. package/lib/node/NodeEnvironmentPlugin.js +1 -1
  204. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +16 -14
  205. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +7 -7
  206. package/lib/node/ReadFileCompileWasmPlugin.js +7 -7
  207. package/lib/node/RequireChunkLoadingRuntimeModule.js +13 -6
  208. package/lib/node/nodeConsole.js +2 -2
  209. package/lib/optimize/AggressiveMergingPlugin.js +2 -2
  210. package/lib/optimize/AggressiveSplittingPlugin.js +10 -10
  211. package/lib/optimize/ConcatenatedModule.js +186 -77
  212. package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -2
  213. package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
  214. package/lib/optimize/InnerGraph.js +5 -5
  215. package/lib/optimize/InnerGraphPlugin.js +14 -12
  216. package/lib/optimize/LimitChunkCountPlugin.js +5 -5
  217. package/lib/optimize/MangleExportsPlugin.js +5 -5
  218. package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
  219. package/lib/optimize/MinChunkSizePlugin.js +3 -3
  220. package/lib/optimize/ModuleConcatenationPlugin.js +45 -38
  221. package/lib/optimize/RealContentHashPlugin.js +23 -23
  222. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
  223. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  224. package/lib/optimize/RuntimeChunkPlugin.js +2 -2
  225. package/lib/optimize/SideEffectsFlagPlugin.js +5 -5
  226. package/lib/optimize/SplitChunksPlugin.js +20 -20
  227. package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
  228. package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
  229. package/lib/performance/SizeLimitsPlugin.js +4 -4
  230. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
  231. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -3
  232. package/lib/rules/BasicMatcherRulePlugin.js +1 -1
  233. package/lib/rules/RuleSetCompiler.js +10 -10
  234. package/lib/rules/UseEffectRulePlugin.js +2 -2
  235. package/lib/runtime/GetChunkFilenameRuntimeModule.js +19 -15
  236. package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
  237. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
  238. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  239. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
  240. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -3
  241. package/lib/schemes/DataUriPlugin.js +3 -3
  242. package/lib/schemes/FileUriPlugin.js +1 -1
  243. package/lib/schemes/HttpUriPlugin.js +40 -36
  244. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  245. package/lib/serialization/BinaryMiddleware.js +11 -11
  246. package/lib/serialization/FileMiddleware.js +18 -17
  247. package/lib/serialization/ObjectMiddleware.js +8 -8
  248. package/lib/serialization/Serializer.js +2 -2
  249. package/lib/serialization/SerializerMiddleware.js +2 -2
  250. package/lib/sharing/ConsumeSharedPlugin.js +4 -4
  251. package/lib/sharing/ProvideSharedPlugin.js +4 -4
  252. package/lib/sharing/SharePlugin.js +1 -1
  253. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  254. package/lib/stats/DefaultStatsFactoryPlugin.js +85 -80
  255. package/lib/stats/DefaultStatsPresetPlugin.js +15 -15
  256. package/lib/stats/DefaultStatsPrinterPlugin.js +87 -87
  257. package/lib/stats/StatsFactory.js +7 -7
  258. package/lib/stats/StatsPrinter.js +9 -9
  259. package/lib/url/URLParserPlugin.js +5 -5
  260. package/lib/util/AsyncQueue.js +4 -4
  261. package/lib/util/IterableHelpers.js +2 -2
  262. package/lib/util/LazyBucketSortedSet.js +3 -3
  263. package/lib/util/SetHelpers.js +2 -2
  264. package/lib/util/StackedCacheMap.js +1 -1
  265. package/lib/util/StackedMap.js +1 -1
  266. package/lib/util/TupleSet.js +1 -1
  267. package/lib/util/WeakTupleMap.js +1 -1
  268. package/lib/util/cleverMerge.js +8 -8
  269. package/lib/util/comparators.js +10 -10
  270. package/lib/util/compileBooleanMatcher.js +20 -20
  271. package/lib/util/concatenate.js +3 -3
  272. package/lib/util/conventions.js +4 -4
  273. package/lib/util/create-schema-validation.js +1 -1
  274. package/lib/util/createHash.js +1 -1
  275. package/lib/util/deprecation.js +4 -4
  276. package/lib/util/deterministicGrouping.js +7 -7
  277. package/lib/util/findGraphRoots.js +1 -1
  278. package/lib/util/fs.js +4 -4
  279. package/lib/util/identifier.js +14 -14
  280. package/lib/util/magicComment.js +5 -1
  281. package/lib/util/memoize.js +1 -1
  282. package/lib/util/processAsyncTree.js +2 -2
  283. package/lib/util/propertyName.js +1 -1
  284. package/lib/util/removeBOM.js +1 -1
  285. package/lib/util/runtime.js +6 -6
  286. package/lib/util/semver.js +16 -16
  287. package/lib/util/serialization.js +5 -5
  288. package/lib/util/smartGrouping.js +1 -1
  289. package/lib/validateSchema.js +2 -2
  290. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
  291. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
  292. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
  293. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -4
  294. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -9
  295. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
  296. package/lib/wasm-sync/WebAssemblyGenerator.js +16 -17
  297. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +4 -2
  298. package/lib/wasm-sync/WebAssemblyParser.js +2 -2
  299. package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
  300. package/lib/web/FetchCompileWasmPlugin.js +4 -4
  301. package/lib/web/JsonpChunkLoadingPlugin.js +2 -2
  302. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  303. package/lib/webpack.js +17 -12
  304. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -2
  305. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  306. package/package.json +16 -16
  307. package/schemas/WebpackOptions.check.js +1 -1
  308. package/schemas/WebpackOptions.json +4 -0
  309. package/types.d.ts +275 -64
@@ -15,6 +15,7 @@ const StackedCacheMap = require("./util/StackedCacheMap");
15
15
  const createHash = require("./util/createHash");
16
16
  const { dirname, join, lstatReadlinkAbsolute, relative } = require("./util/fs");
17
17
  const makeSerializable = require("./util/makeSerializable");
18
+ const memoize = require("./util/memoize");
18
19
  const processAsyncTree = require("./util/processAsyncTree");
19
20
 
20
21
  /** @typedef {import("enhanced-resolve").Resolver} Resolver */
@@ -550,7 +551,7 @@ class Snapshot {
550
551
  */
551
552
  getFileIterable() {
552
553
  if (this._cachedFileIterable === undefined) {
553
- this._cachedFileIterable = this._createIterable(s => [
554
+ this._cachedFileIterable = this._createIterable((s) => [
554
555
  s.fileTimestamps,
555
556
  s.fileHashes,
556
557
  s.fileTshs,
@@ -565,7 +566,7 @@ class Snapshot {
565
566
  */
566
567
  getContextIterable() {
567
568
  if (this._cachedContextIterable === undefined) {
568
- this._cachedContextIterable = this._createIterable(s => [
569
+ this._cachedContextIterable = this._createIterable((s) => [
569
570
  s.contextTimestamps,
570
571
  s.contextHashes,
571
572
  s.contextTshs,
@@ -580,7 +581,7 @@ class Snapshot {
580
581
  */
581
582
  getMissingIterable() {
582
583
  if (this._cachedMissingIterable === undefined) {
583
- this._cachedMissingIterable = this._createIterable(s => [
584
+ this._cachedMissingIterable = this._createIterable((s) => [
584
585
  s.missingExistence,
585
586
  s.managedMissing
586
587
  ]);
@@ -661,7 +662,7 @@ class SnapshotOptimization {
661
662
  * @param {SnapshotOptimizationEntry} entry optimization entry
662
663
  * @returns {void}
663
664
  */
664
- const increaseSharedAndStoreOptimizationEntry = entry => {
665
+ const increaseSharedAndStoreOptimizationEntry = (entry) => {
665
666
  if (entry.children !== undefined) {
666
667
  for (const child of entry.children) {
667
668
  increaseSharedAndStoreOptimizationEntry(child);
@@ -674,7 +675,7 @@ class SnapshotOptimization {
674
675
  * @param {SnapshotOptimizationEntry} entry optimization entry
675
676
  * @returns {void}
676
677
  */
677
- const storeOptimizationEntry = entry => {
678
+ const storeOptimizationEntry = (entry) => {
678
679
  for (const path of /** @type {SnapshotContent} */ (
679
680
  entry.snapshotContent
680
681
  )) {
@@ -872,7 +873,7 @@ class SnapshotOptimization {
872
873
  * @param {string} str input
873
874
  * @returns {string} result
874
875
  */
875
- const parseString = str => {
876
+ const parseString = (str) => {
876
877
  if (str[0] === "'" || str[0] === "`") {
877
878
  str = `"${str.slice(1, -1).replace(/"/g, '\\"')}"`;
878
879
  }
@@ -883,7 +884,7 @@ const parseString = str => {
883
884
  /**
884
885
  * @param {number} mtime mtime
885
886
  */
886
- const applyMtime = mtime => {
887
+ const applyMtime = (mtime) => {
887
888
  if (FS_ACCURACY > 1 && mtime % 2 !== 0) FS_ACCURACY = 1;
888
889
  else if (FS_ACCURACY > 10 && mtime % 20 !== 0) FS_ACCURACY = 10;
889
890
  else if (FS_ACCURACY > 100 && mtime % 200 !== 0) FS_ACCURACY = 100;
@@ -1014,7 +1015,7 @@ const getManagedItem = (managedPath, path) => {
1014
1015
  * @param {T | null} entry entry
1015
1016
  * @returns {T["resolved"] | null | undefined} the resolved entry
1016
1017
  */
1017
- const getResolvedTimestamp = entry => {
1018
+ const getResolvedTimestamp = (entry) => {
1018
1019
  if (entry === null) return null;
1019
1020
  if (entry.resolved !== undefined) return entry.resolved;
1020
1021
  return entry.symlinks === undefined ? entry : undefined;
@@ -1024,7 +1025,7 @@ const getResolvedTimestamp = entry => {
1024
1025
  * @param {ContextHash | null} entry entry
1025
1026
  * @returns {string | null | undefined} the resolved entry
1026
1027
  */
1027
- const getResolvedHash = entry => {
1028
+ const getResolvedHash = (entry) => {
1028
1029
  if (entry === null) return null;
1029
1030
  if (entry.resolved !== undefined) return entry.resolved;
1030
1031
  return entry.symlinks === undefined ? entry.hash : undefined;
@@ -1039,6 +1040,8 @@ const addAll = (source, target) => {
1039
1040
  for (const key of source) target.add(key);
1040
1041
  };
1041
1042
 
1043
+ const getEsModuleLexer = memoize(() => require("es-module-lexer"));
1044
+
1042
1045
  /** @typedef {Set<string>} LoggedPaths */
1043
1046
 
1044
1047
  /** @typedef {FileSystemInfoEntry | "ignore" | null} FileTimestamp */
@@ -1079,66 +1082,66 @@ class FileSystemInfo {
1079
1082
  /** @type {WeakMap<Snapshot, boolean | CheckSnapshotValidCallback[]>} */
1080
1083
  this._snapshotCache = new WeakMap();
1081
1084
  this._fileTimestampsOptimization = new SnapshotOptimization(
1082
- s => s.hasFileTimestamps(),
1083
- s => s.fileTimestamps,
1085
+ (s) => s.hasFileTimestamps(),
1086
+ (s) => s.fileTimestamps,
1084
1087
  (s, v) => s.setFileTimestamps(v)
1085
1088
  );
1086
1089
  this._fileHashesOptimization = new SnapshotOptimization(
1087
- s => s.hasFileHashes(),
1088
- s => s.fileHashes,
1090
+ (s) => s.hasFileHashes(),
1091
+ (s) => s.fileHashes,
1089
1092
  (s, v) => s.setFileHashes(v),
1090
1093
  false
1091
1094
  );
1092
1095
  this._fileTshsOptimization = new SnapshotOptimization(
1093
- s => s.hasFileTshs(),
1094
- s => s.fileTshs,
1096
+ (s) => s.hasFileTshs(),
1097
+ (s) => s.fileTshs,
1095
1098
  (s, v) => s.setFileTshs(v)
1096
1099
  );
1097
1100
  this._contextTimestampsOptimization = new SnapshotOptimization(
1098
- s => s.hasContextTimestamps(),
1099
- s => s.contextTimestamps,
1101
+ (s) => s.hasContextTimestamps(),
1102
+ (s) => s.contextTimestamps,
1100
1103
  (s, v) => s.setContextTimestamps(v)
1101
1104
  );
1102
1105
  this._contextHashesOptimization = new SnapshotOptimization(
1103
- s => s.hasContextHashes(),
1104
- s => s.contextHashes,
1106
+ (s) => s.hasContextHashes(),
1107
+ (s) => s.contextHashes,
1105
1108
  (s, v) => s.setContextHashes(v),
1106
1109
  false
1107
1110
  );
1108
1111
  this._contextTshsOptimization = new SnapshotOptimization(
1109
- s => s.hasContextTshs(),
1110
- s => s.contextTshs,
1112
+ (s) => s.hasContextTshs(),
1113
+ (s) => s.contextTshs,
1111
1114
  (s, v) => s.setContextTshs(v)
1112
1115
  );
1113
1116
  this._missingExistenceOptimization = new SnapshotOptimization(
1114
- s => s.hasMissingExistence(),
1115
- s => s.missingExistence,
1117
+ (s) => s.hasMissingExistence(),
1118
+ (s) => s.missingExistence,
1116
1119
  (s, v) => s.setMissingExistence(v),
1117
1120
  false
1118
1121
  );
1119
1122
  this._managedItemInfoOptimization = new SnapshotOptimization(
1120
- s => s.hasManagedItemInfo(),
1121
- s => s.managedItemInfo,
1123
+ (s) => s.hasManagedItemInfo(),
1124
+ (s) => s.managedItemInfo,
1122
1125
  (s, v) => s.setManagedItemInfo(v),
1123
1126
  false
1124
1127
  );
1125
1128
  this._managedFilesOptimization = new SnapshotOptimization(
1126
- s => s.hasManagedFiles(),
1127
- s => s.managedFiles,
1129
+ (s) => s.hasManagedFiles(),
1130
+ (s) => s.managedFiles,
1128
1131
  (s, v) => s.setManagedFiles(v),
1129
1132
  false,
1130
1133
  true
1131
1134
  );
1132
1135
  this._managedContextsOptimization = new SnapshotOptimization(
1133
- s => s.hasManagedContexts(),
1134
- s => s.managedContexts,
1136
+ (s) => s.hasManagedContexts(),
1137
+ (s) => s.managedContexts,
1135
1138
  (s, v) => s.setManagedContexts(v),
1136
1139
  false,
1137
1140
  true
1138
1141
  );
1139
1142
  this._managedMissingOptimization = new SnapshotOptimization(
1140
- s => s.hasManagedMissing(),
1141
- s => s.managedMissing,
1143
+ (s) => s.hasManagedMissing(),
1144
+ (s) => s.managedMissing,
1142
1145
  (s, v) => s.setManagedMissing(v),
1143
1146
  false,
1144
1147
  true
@@ -1202,32 +1205,32 @@ class FileSystemInfo {
1202
1205
  const _unmanagedPaths = [...unmanagedPaths];
1203
1206
  this.unmanagedPathsWithSlash =
1204
1207
  /** @type {string[]} */
1205
- (_unmanagedPaths.filter(p => typeof p === "string")).map(p =>
1208
+ (_unmanagedPaths.filter((p) => typeof p === "string")).map((p) =>
1206
1209
  join(fs, p, "_").slice(0, -1)
1207
1210
  );
1208
1211
  this.unmanagedPathsRegExps =
1209
1212
  /** @type {RegExp[]} */
1210
- (_unmanagedPaths.filter(p => typeof p !== "string"));
1213
+ (_unmanagedPaths.filter((p) => typeof p !== "string"));
1211
1214
 
1212
1215
  this.managedPaths = [...managedPaths];
1213
1216
  this.managedPathsWithSlash =
1214
1217
  /** @type {string[]} */
1215
- (this.managedPaths.filter(p => typeof p === "string")).map(p =>
1218
+ (this.managedPaths.filter((p) => typeof p === "string")).map((p) =>
1216
1219
  join(fs, p, "_").slice(0, -1)
1217
1220
  );
1218
1221
 
1219
1222
  this.managedPathsRegExps =
1220
1223
  /** @type {RegExp[]} */
1221
- (this.managedPaths.filter(p => typeof p !== "string"));
1224
+ (this.managedPaths.filter((p) => typeof p !== "string"));
1222
1225
  this.immutablePaths = [...immutablePaths];
1223
1226
  this.immutablePathsWithSlash =
1224
1227
  /** @type {string[]} */
1225
- (this.immutablePaths.filter(p => typeof p === "string")).map(p =>
1228
+ (this.immutablePaths.filter((p) => typeof p === "string")).map((p) =>
1226
1229
  join(fs, p, "_").slice(0, -1)
1227
1230
  );
1228
1231
  this.immutablePathsRegExps =
1229
1232
  /** @type {RegExp[]} */
1230
- (this.immutablePaths.filter(p => typeof p !== "string"));
1233
+ (this.immutablePaths.filter((p) => typeof p !== "string"));
1231
1234
 
1232
1235
  this._cachedDeprecatedFileTimestamps = undefined;
1233
1236
  this._cachedDeprecatedContextTimestamps = undefined;
@@ -1605,7 +1608,7 @@ class FileSystemInfo {
1605
1608
  * @param {undefined | boolean | string} expected expected result
1606
1609
  * @returns {string} expected result
1607
1610
  */
1608
- const expectedToString = expected =>
1611
+ const expectedToString = (expected) =>
1609
1612
  expected ? ` (expected ${expected})` : "";
1610
1613
  /** @typedef {{ type: JobType, context: string | undefined, path: string, issuer: Job | undefined, expected: undefined | boolean | string }} Job */
1611
1614
 
@@ -1613,7 +1616,7 @@ class FileSystemInfo {
1613
1616
  * @param {Job} job job
1614
1617
  * @returns {`resolve commonjs file ${string}${string}`|`resolve esm file ${string}${string}`|`resolve esm ${string}${string}`|`resolve directory ${string}`|`file ${string}`|`unknown ${string} ${string}`|`resolve commonjs ${string}${string}`|`directory ${string}`|`file dependencies ${string}`|`directory dependencies ${string}`} result
1615
1618
  */
1616
- const jobToString = job => {
1619
+ const jobToString = (job) => {
1617
1620
  switch (job.type) {
1618
1621
  case RBDT_RESOLVE_CJS:
1619
1622
  return `resolve commonjs ${job.path}${expectedToString(
@@ -1646,7 +1649,7 @@ class FileSystemInfo {
1646
1649
  * @param {Job} job job
1647
1650
  * @returns {string} string value
1648
1651
  */
1649
- const pathToString = job => {
1652
+ const pathToString = (job) => {
1650
1653
  let result = ` at ${jobToString(job)}`;
1651
1654
  /** @type {Job | undefined} */
1652
1655
  (job) = job.issuer;
@@ -1660,7 +1663,7 @@ class FileSystemInfo {
1660
1663
  processAsyncTree(
1661
1664
  Array.from(
1662
1665
  deps,
1663
- dep =>
1666
+ (dep) =>
1664
1667
  /** @type {Job} */ ({
1665
1668
  type: RBDT_RESOLVE_CJS,
1666
1669
  context,
@@ -1676,7 +1679,7 @@ class FileSystemInfo {
1676
1679
  * @param {string} path path
1677
1680
  * @returns {void}
1678
1681
  */
1679
- const resolveDirectory = path => {
1682
+ const resolveDirectory = (path) => {
1680
1683
  const key = `d\n${context}\n${path}`;
1681
1684
  if (resolveResults.has(key)) {
1682
1685
  return callback();
@@ -1935,7 +1938,7 @@ class FileSystemInfo {
1935
1938
  this._warnAboutExperimentalEsmTracking = true;
1936
1939
  }
1937
1940
 
1938
- const lexer = require("es-module-lexer");
1941
+ const lexer = getEsModuleLexer();
1939
1942
 
1940
1943
  lexer.init.then(() => {
1941
1944
  this.fs.readFile(path, (err, content) => {
@@ -2071,7 +2074,7 @@ class FileSystemInfo {
2071
2074
  }
2072
2075
  }
2073
2076
  },
2074
- err => {
2077
+ (err) => {
2075
2078
  if (err) return callback(err);
2076
2079
  for (const l of fileSymlinks) files.delete(l);
2077
2080
  for (const l of directorySymlinks) directories.delete(l);
@@ -2158,7 +2161,7 @@ class FileSystemInfo {
2158
2161
  * @param {Error | typeof INVALID=} err error or invalid flag
2159
2162
  * @returns {void}
2160
2163
  */
2161
- err => {
2164
+ (err) => {
2162
2165
  if (err === INVALID) {
2163
2166
  return callback(null, false);
2164
2167
  }
@@ -2172,9 +2175,9 @@ class FileSystemInfo {
2172
2175
 
2173
2176
  /**
2174
2177
  * @param {number | null | undefined} startTime when processing the files has started
2175
- * @param {Iterable<string> | null} files all files
2176
- * @param {Iterable<string> | null} directories all directories
2177
- * @param {Iterable<string> | null} missing all missing files or directories
2178
+ * @param {Iterable<string> | null | undefined} files all files
2179
+ * @param {Iterable<string> | null | undefined} directories all directories
2180
+ * @param {Iterable<string> | null | undefined} missing all missing files or directories
2178
2181
  * @param {SnapshotOptions | null | undefined} options options object (for future extensions)
2179
2182
  * @param {(err: WebpackError | null, snapshot: Snapshot | null) => void} callback callback function
2180
2183
  * @returns {void}
@@ -2332,7 +2335,7 @@ class FileSystemInfo {
2332
2335
  /**
2333
2336
  * @param {ManagedFiles} capturedFiles captured files
2334
2337
  */
2335
- const processCapturedFiles = capturedFiles => {
2338
+ const processCapturedFiles = (capturedFiles) => {
2336
2339
  switch (mode) {
2337
2340
  case 3:
2338
2341
  this._fileTshsOptimization.optimize(snapshot, capturedFiles);
@@ -2420,7 +2423,7 @@ class FileSystemInfo {
2420
2423
  /**
2421
2424
  * @param {ManagedContexts} capturedDirectories captured directories
2422
2425
  */
2423
- const processCapturedDirectories = capturedDirectories => {
2426
+ const processCapturedDirectories = (capturedDirectories) => {
2424
2427
  switch (mode) {
2425
2428
  case 3:
2426
2429
  this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
@@ -2565,7 +2568,7 @@ class FileSystemInfo {
2565
2568
  /**
2566
2569
  * @param {ManagedMissing} capturedMissing captured missing
2567
2570
  */
2568
- const processCapturedMissing = capturedMissing => {
2571
+ const processCapturedMissing = (capturedMissing) => {
2569
2572
  this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
2570
2573
  for (const path of capturedMissing) {
2571
2574
  const cache = this._fileTimestamps.get(path);
@@ -3345,7 +3348,7 @@ class FileSystemInfo {
3345
3348
  * @param {string} hash hash
3346
3349
  * @returns {void}
3347
3350
  */
3348
- const continueWithHash = hash => {
3351
+ const continueWithHash = (hash) => {
3349
3352
  const cache = this._fileTimestamps.get(path);
3350
3353
  if (cache !== undefined) {
3351
3354
  if (cache !== "ignore") {
@@ -3421,8 +3424,8 @@ class FileSystemInfo {
3421
3424
  return callback(err);
3422
3425
  }
3423
3426
  const files = /** @type {string[]} */ (_files)
3424
- .map(file => file.normalize("NFC"))
3425
- .filter(file => !/^\./.test(file))
3427
+ .map((file) => file.normalize("NFC"))
3428
+ .filter((file) => !/^\./.test(file))
3426
3429
  .sort();
3427
3430
  asyncLib.map(
3428
3431
  files,
@@ -3510,7 +3513,7 @@ class FileSystemInfo {
3510
3513
  fromImmutablePath: () =>
3511
3514
  /** @type {ContextFileSystemInfoEntry | FileSystemInfoEntry | "ignore" | null} */
3512
3515
  (null),
3513
- fromManagedItem: info => ({
3516
+ fromManagedItem: (info) => ({
3514
3517
  safeTime: 0,
3515
3518
  timestampHash: info
3516
3519
  }),
@@ -3643,7 +3646,7 @@ class FileSystemInfo {
3643
3646
  callback();
3644
3647
  });
3645
3648
  },
3646
- err => {
3649
+ (err) => {
3647
3650
  if (err) return callback(/** @type {WebpackError} */ (err));
3648
3651
  const hash = createHash(this._hashFunction);
3649
3652
  hash.update(/** @type {string} */ (entry.timestampHash));
@@ -3674,7 +3677,7 @@ class FileSystemInfo {
3674
3677
  {
3675
3678
  path,
3676
3679
  fromImmutablePath: () => /** @type {ContextHash | ""} */ (""),
3677
- fromManagedItem: info => info || "",
3680
+ fromManagedItem: (info) => info || "",
3678
3681
  fromSymlink: (file, target, callback) => {
3679
3682
  callback(
3680
3683
  null,
@@ -3759,7 +3762,7 @@ class FileSystemInfo {
3759
3762
  callback();
3760
3763
  });
3761
3764
  },
3762
- err => {
3765
+ (err) => {
3763
3766
  if (err) return callback(/** @type {WebpackError} */ (err));
3764
3767
  const hash = createHash(this._hashFunction);
3765
3768
  hash.update(entry.hash);
@@ -3817,7 +3820,7 @@ class FileSystemInfo {
3817
3820
  path,
3818
3821
  fromImmutablePath: () =>
3819
3822
  /** @type {ContextTimestampAndHash | null} */ (null),
3820
- fromManagedItem: info => ({
3823
+ fromManagedItem: (info) => ({
3821
3824
  safeTime: 0,
3822
3825
  timestampHash: info,
3823
3826
  hash: info || ""
@@ -3937,7 +3940,7 @@ class FileSystemInfo {
3937
3940
  callback();
3938
3941
  });
3939
3942
  },
3940
- err => {
3943
+ (err) => {
3941
3944
  if (err) return callback(/** @type {WebpackError} */ (err));
3942
3945
  const hash = createHash(this._hashFunction);
3943
3946
  const tsHash = createHash(this._hashFunction);
@@ -3979,7 +3982,7 @@ class FileSystemInfo {
3979
3982
  return callback(/** @type {WebpackError} */ (err));
3980
3983
  }
3981
3984
  const set = new Set(
3982
- /** @type {string[]} */ (elements).map(element =>
3985
+ /** @type {string[]} */ (elements).map((element) =>
3983
3986
  join(this.fs, path, element)
3984
3987
  )
3985
3988
  );
@@ -26,9 +26,9 @@ class FlagAllModulesAsUsedPlugin {
26
26
  * @returns {void}
27
27
  */
28
28
  apply(compiler) {
29
- compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
29
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
30
30
  const moduleGraph = compilation.moduleGraph;
31
- compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, modules => {
31
+ compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, (modules) => {
32
32
  /** @type {RuntimeSpec} */
33
33
  let runtime;
34
34
  for (const [name, { options }] of compilation.entries) {
@@ -28,7 +28,7 @@ class FlagDependencyExportsPlugin {
28
28
  * @returns {void}
29
29
  */
30
30
  apply(compiler) {
31
- compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
31
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
32
32
  const moduleGraph = compilation.moduleGraph;
33
33
  const cache = compilation.getCache(PLUGIN_NAME);
34
34
  compilation.hooks.finishModules.tapAsync(
@@ -103,7 +103,7 @@ class FlagDependencyExportsPlugin {
103
103
  }
104
104
  );
105
105
  },
106
- err => {
106
+ (err) => {
107
107
  logger.timeEnd("restore cached provided exports");
108
108
  if (err) return callback(err);
109
109
 
@@ -129,7 +129,7 @@ class FlagDependencyExportsPlugin {
129
129
  * @param {DependenciesBlock} depBlock the dependencies block
130
130
  * @returns {void}
131
131
  */
132
- const processDependenciesBlock = depBlock => {
132
+ const processDependenciesBlock = (depBlock) => {
133
133
  for (const dep of depBlock.dependencies) {
134
134
  processDependency(dep);
135
135
  }
@@ -142,7 +142,7 @@ class FlagDependencyExportsPlugin {
142
142
  * @param {Dependency} dep the dependency
143
143
  * @returns {void}
144
144
  */
145
- const processDependency = dep => {
145
+ const processDependency = (dep) => {
146
146
  const exportDesc = dep.getExports(moduleGraph);
147
147
  if (!exportDesc) return;
148
148
  exportsSpecsFromDependencies.set(dep, exportDesc);
@@ -399,7 +399,7 @@ class FlagDependencyExportsPlugin {
399
399
  callback
400
400
  );
401
401
  },
402
- err => {
402
+ (err) => {
403
403
  logger.timeEnd("store provided exports into cache");
404
404
  callback(err);
405
405
  }
@@ -411,13 +411,13 @@ class FlagDependencyExportsPlugin {
411
411
 
412
412
  /** @type {WeakMap<Module, RestoreProvidedData>} */
413
413
  const providedExportsCache = new WeakMap();
414
- compilation.hooks.rebuildModule.tap(PLUGIN_NAME, module => {
414
+ compilation.hooks.rebuildModule.tap(PLUGIN_NAME, (module) => {
415
415
  providedExportsCache.set(
416
416
  module,
417
417
  moduleGraph.getExportsInfo(module).getRestoreProvidedData()
418
418
  );
419
419
  });
420
- compilation.hooks.finishRebuildingModule.tap(PLUGIN_NAME, module => {
420
+ compilation.hooks.finishRebuildingModule.tap(PLUGIN_NAME, (module) => {
421
421
  moduleGraph.getExportsInfo(module).restoreProvided(
422
422
  /** @type {RestoreProvidedData} */
423
423
  (providedExportsCache.get(module))
@@ -41,11 +41,11 @@ class FlagDependencyUsagePlugin {
41
41
  * @returns {void}
42
42
  */
43
43
  apply(compiler) {
44
- compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
44
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
45
45
  const moduleGraph = compilation.moduleGraph;
46
46
  compilation.hooks.optimizeDependencies.tap(
47
47
  { name: PLUGIN_NAME, stage: STAGE_DEFAULT },
48
- modules => {
48
+ (modules) => {
49
49
  if (compilation.moduleMemCaches) {
50
50
  throw new Error(
51
51
  "optimization.usedExports can't be used with cacheUnaffected as export usage is a global effect"
@@ -108,7 +108,7 @@ class FlagDependencyUsagePlugin {
108
108
  if (nestedInfo) {
109
109
  if (
110
110
  exportInfo.setUsedConditionally(
111
- used => used === UsageState.Unused,
111
+ (used) => used === UsageState.Unused,
112
112
  UsageState.OnlyPropertiesUsed,
113
113
  runtime
114
114
  )
@@ -127,7 +127,7 @@ class FlagDependencyUsagePlugin {
127
127
  }
128
128
  if (
129
129
  exportInfo.setUsedConditionally(
130
- v => v !== UsageState.Used,
130
+ (v) => v !== UsageState.Used,
131
131
  UsageState.Used,
132
132
  runtime
133
133
  )
@@ -27,7 +27,7 @@ class FlagEntryExportAsUsedPlugin {
27
27
  * @returns {void}
28
28
  */
29
29
  apply(compiler) {
30
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
30
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
31
31
  const moduleGraph = compilation.moduleGraph;
32
32
  compilation.hooks.seal.tap(PLUGIN_NAME, () => {
33
33
  for (const [