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
@@ -16,6 +16,7 @@ const ArrayQueue = require("./util/ArrayQueue");
16
16
 
17
17
  /** @template T @typedef {import("tapable").AsyncSeriesHook<T>} AsyncSeriesHook<T> */
18
18
  /** @template T @template R @typedef {import("tapable").SyncBailHook<T, R>} SyncBailHook<T, R> */
19
+ /** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
19
20
  /** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */
20
21
  /** @typedef {import("./Compiler")} Compiler */
21
22
  /** @typedef {import("./Stats")} Stats */
@@ -44,6 +45,8 @@ const ArrayQueue = require("./util/ArrayQueue");
44
45
  * @property {number=} parallelism how many Compilers are allows to run at the same time in parallel
45
46
  */
46
47
 
48
+ /** @typedef {ReadonlyArray<WebpackOptions> & MultiCompilerOptions} MultiWebpackOptions */
49
+
47
50
  const CLASS_NAME = "MultiCompiler";
48
51
 
49
52
  module.exports = class MultiCompiler {
@@ -54,7 +57,7 @@ module.exports = class MultiCompiler {
54
57
  constructor(compilers, options) {
55
58
  if (!Array.isArray(compilers)) {
56
59
  /** @type {Compiler[]} */
57
- compilers = Object.keys(compilers).map(name => {
60
+ compilers = Object.keys(compilers).map((name) => {
58
61
  /** @type {Record<string, Compiler>} */
59
62
  (compilers)[name].name = name;
60
63
  return /** @type {Record<string, Compiler>} */ (compilers)[name];
@@ -65,16 +68,16 @@ module.exports = class MultiCompiler {
65
68
  /** @type {SyncHook<[MultiStats]>} */
66
69
  done: new SyncHook(["stats"]),
67
70
  /** @type {MultiHook<SyncHook<[string | null, number]>>} */
68
- invalid: new MultiHook(compilers.map(c => c.hooks.invalid)),
71
+ invalid: new MultiHook(compilers.map((c) => c.hooks.invalid)),
69
72
  /** @type {MultiHook<AsyncSeriesHook<[Compiler]>>} */
70
- run: new MultiHook(compilers.map(c => c.hooks.run)),
73
+ run: new MultiHook(compilers.map((c) => c.hooks.run)),
71
74
  /** @type {SyncHook<[]>} */
72
75
  watchClose: new SyncHook([]),
73
76
  /** @type {MultiHook<AsyncSeriesHook<[Compiler]>>} */
74
- watchRun: new MultiHook(compilers.map(c => c.hooks.watchRun)),
77
+ watchRun: new MultiHook(compilers.map((c) => c.hooks.watchRun)),
75
78
  /** @type {MultiHook<SyncBailHook<[string, string, EXPECTED_ANY[] | undefined], true | void>>} */
76
79
  infrastructureLog: new MultiHook(
77
- compilers.map(c => c.hooks.infrastructureLog)
80
+ compilers.map((c) => c.hooks.infrastructureLog)
78
81
  )
79
82
  });
80
83
  this.compilers = compilers;
@@ -94,7 +97,7 @@ module.exports = class MultiCompiler {
94
97
  const compilerIndex = index;
95
98
  let compilerDone = false;
96
99
  // eslint-disable-next-line no-loop-func
97
- compiler.hooks.done.tap(CLASS_NAME, stats => {
100
+ compiler.hooks.done.tap(CLASS_NAME, (stats) => {
98
101
  if (!compilerDone) {
99
102
  compilerDone = true;
100
103
  doneCompilers++;
@@ -124,7 +127,7 @@ module.exports = class MultiCompiler {
124
127
  * @param {WebpackError} warning warning
125
128
  */
126
129
  const addWarning = (compiler, warning) => {
127
- compiler.hooks.thisCompilation.tap(CLASS_NAME, compilation => {
130
+ compiler.hooks.thisCompilation.tap(CLASS_NAME, (compilation) => {
128
131
  compilation.warnings.push(warning);
129
132
  });
130
133
  };
@@ -152,7 +155,7 @@ module.exports = class MultiCompiler {
152
155
 
153
156
  get options() {
154
157
  return Object.assign(
155
- this.compilers.map(c => c.options),
158
+ this.compilers.map((c) => c.options),
156
159
  this._options
157
160
  );
158
161
  }
@@ -254,7 +257,7 @@ module.exports = class MultiCompiler {
254
257
  * @param {Compiler} compiler compiler
255
258
  * @returns {boolean} target was found
256
259
  */
257
- const targetFound = compiler => {
260
+ const targetFound = (compiler) => {
258
261
  for (const edge of edges) {
259
262
  if (edge.target === compiler) {
260
263
  return true;
@@ -276,7 +279,7 @@ module.exports = class MultiCompiler {
276
279
  const dependencies = this.dependencies.get(source);
277
280
  if (dependencies) {
278
281
  for (const dep of dependencies) {
279
- const target = this.compilers.find(c => c.name === dep);
282
+ const target = this.compilers.find((c) => c.name === dep);
280
283
  if (!target) {
281
284
  missing.push(dep);
282
285
  } else {
@@ -289,8 +292,10 @@ module.exports = class MultiCompiler {
289
292
  }
290
293
  }
291
294
  /** @type {string[]} */
292
- const errors = missing.map(m => `Compiler dependency \`${m}\` not found.`);
293
- const stack = this.compilers.filter(c => !targetFound(c));
295
+ const errors = missing.map(
296
+ (m) => `Compiler dependency \`${m}\` not found.`
297
+ );
298
+ const stack = this.compilers.filter((c) => !targetFound(c));
294
299
  while (stack.length > 0) {
295
300
  const current = stack.pop();
296
301
  for (const edge of edges) {
@@ -307,7 +312,7 @@ module.exports = class MultiCompiler {
307
312
  /** @type {string[]} */
308
313
  const lines = [...edges]
309
314
  .sort(sortEdges)
310
- .map(edge => `${edge.source.name} -> ${edge.target.name}`);
315
+ .map((edge) => `${edge.source.name} -> ${edge.target.name}`);
311
316
  lines.unshift("Circular dependency found in compiler dependencies.");
312
317
  errors.unshift(lines.join("\n"));
313
318
  }
@@ -334,7 +339,7 @@ module.exports = class MultiCompiler {
334
339
  * @param {string} d dependency
335
340
  * @returns {boolean} when dependency was fulfilled
336
341
  */
337
- const isDependencyFulfilled = d => fulfilledNames.has(d);
342
+ const isDependencyFulfilled = (d) => fulfilledNames.has(d);
338
343
  /**
339
344
  * @returns {Compiler[]} compilers
340
345
  */
@@ -358,12 +363,12 @@ module.exports = class MultiCompiler {
358
363
  * @param {Callback<Stats[]>} callback callback
359
364
  * @returns {void}
360
365
  */
361
- const runCompilers = callback => {
366
+ const runCompilers = (callback) => {
362
367
  if (remainingCompilers.length === 0) return callback(null);
363
368
  asyncLib.map(
364
369
  getReadyCompilers(),
365
370
  (compiler, callback) => {
366
- fn(compiler, err => {
371
+ fn(compiler, (err) => {
367
372
  if (err) return callback(err);
368
373
  fulfilledNames.add(compiler.name);
369
374
  runCompilers(callback);
@@ -400,7 +405,7 @@ module.exports = class MultiCompiler {
400
405
  // running-outdated -> blocked [running--] (when compilation is done)
401
406
 
402
407
  /** @type {Node[]} */
403
- const nodes = this.compilers.map(compiler => ({
408
+ const nodes = this.compilers.map((compiler) => ({
404
409
  compiler,
405
410
  setupResult: undefined,
406
411
  result: undefined,
@@ -472,7 +477,7 @@ module.exports = class MultiCompiler {
472
477
  * @param {Node} node node
473
478
  * @returns {void}
474
479
  */
475
- const nodeInvalidFromParent = node => {
480
+ const nodeInvalidFromParent = (node) => {
476
481
  if (node.state === "done") {
477
482
  node.state = "blocked";
478
483
  } else if (node.state === "running") {
@@ -486,7 +491,7 @@ module.exports = class MultiCompiler {
486
491
  * @param {Node} node node
487
492
  * @returns {void}
488
493
  */
489
- const nodeInvalid = node => {
494
+ const nodeInvalid = (node) => {
490
495
  if (node.state === "done") {
491
496
  node.state = "pending";
492
497
  } else if (node.state === "running") {
@@ -500,7 +505,7 @@ module.exports = class MultiCompiler {
500
505
  * @param {Node} node node
501
506
  * @returns {void}
502
507
  */
503
- const nodeChange = node => {
508
+ const nodeChange = (node) => {
504
509
  nodeInvalid(node);
505
510
  if (node.state === "pending") {
506
511
  node.state = "blocked";
@@ -538,7 +543,7 @@ module.exports = class MultiCompiler {
538
543
  if (
539
544
  node.state === "queued" ||
540
545
  (node.state === "blocked" &&
541
- node.parents.every(p => p.state === "done"))
546
+ node.parents.every((p) => p.state === "done"))
542
547
  ) {
543
548
  running++;
544
549
  node.state = "starting";
@@ -554,7 +559,7 @@ module.exports = class MultiCompiler {
554
559
  if (
555
560
  !errored &&
556
561
  running === 0 &&
557
- nodes.every(node => node.state === "done")
562
+ nodes.every((node) => node.state === "done")
558
563
  ) {
559
564
  const stats = [];
560
565
  for (const node of nodes) {
@@ -574,7 +579,7 @@ module.exports = class MultiCompiler {
574
579
  }
575
580
 
576
581
  /**
577
- * @param {WatchOptions|WatchOptions[]} watchOptions the watcher's options
582
+ * @param {WatchOptions | WatchOptions[]} watchOptions the watcher's options
578
583
  * @param {Callback<MultiStats>} handler signals when the call finishes
579
584
  * @returns {MultiWatching} a compiler watcher
580
585
  */
@@ -653,7 +658,7 @@ module.exports = class MultiCompiler {
653
658
  (compiler, callback) => {
654
659
  compiler.close(callback);
655
660
  },
656
- error => {
661
+ (error) => {
657
662
  callback(error);
658
663
  }
659
664
  );
package/lib/MultiStats.js CHANGED
@@ -25,6 +25,8 @@ const indent = (str, prefix) => {
25
25
  return prefix + rem;
26
26
  };
27
27
 
28
+ /** @typedef {undefined | string | boolean | StatsOptions} ChildrenStatsOptions */
29
+ /** @typedef {Omit<StatsOptions, "children"> & { children?: ChildrenStatsOptions | ChildrenStatsOptions[] }} MultiStatsOptions */
28
30
  /** @typedef {{ version: boolean, hash: boolean, errorsCount: boolean, warningsCount: boolean, errors: boolean, warnings: boolean, children: NormalizedStatsOptions[] }} ChildOptions */
29
31
 
30
32
  class MultiStats {
@@ -36,25 +38,25 @@ class MultiStats {
36
38
  }
37
39
 
38
40
  get hash() {
39
- return this.stats.map(stat => stat.hash).join("");
41
+ return this.stats.map((stat) => stat.hash).join("");
40
42
  }
41
43
 
42
44
  /**
43
45
  * @returns {boolean} true if a child compilation encountered an error
44
46
  */
45
47
  hasErrors() {
46
- return this.stats.some(stat => stat.hasErrors());
48
+ return this.stats.some((stat) => stat.hasErrors());
47
49
  }
48
50
 
49
51
  /**
50
52
  * @returns {boolean} true if a child compilation had a warning
51
53
  */
52
54
  hasWarnings() {
53
- return this.stats.some(stat => stat.hasWarnings());
55
+ return this.stats.some((stat) => stat.hasWarnings());
54
56
  }
55
57
 
56
58
  /**
57
- * @param {string | boolean | StatsOptions | undefined} options stats options
59
+ * @param {undefined | string | boolean | MultiStatsOptions} options stats options
58
60
  * @param {CreateStatsOptionsContext} context context
59
61
  * @returns {ChildOptions} context context
60
62
  */
@@ -80,6 +82,9 @@ class MultiStats {
80
82
  const childOptions = Array.isArray(childrenOptions)
81
83
  ? childrenOptions[idx]
82
84
  : childrenOptions;
85
+ if (typeof childOptions === "boolean") {
86
+ return stat.compilation.createStatsOptions(childOptions, context);
87
+ }
83
88
  return stat.compilation.createStatsOptions(
84
89
  {
85
90
  ...baseOptions,
@@ -93,18 +98,18 @@ class MultiStats {
93
98
  );
94
99
  });
95
100
  return {
96
- version: children.every(o => o.version),
97
- hash: children.every(o => o.hash),
98
- errorsCount: children.every(o => o.errorsCount),
99
- warningsCount: children.every(o => o.warningsCount),
100
- errors: children.every(o => o.errors),
101
- warnings: children.every(o => o.warnings),
101
+ version: children.every((o) => o.version),
102
+ hash: children.every((o) => o.hash),
103
+ errorsCount: children.every((o) => o.errorsCount),
104
+ warningsCount: children.every((o) => o.warningsCount),
105
+ errors: children.every((o) => o.errors),
106
+ warnings: children.every((o) => o.warnings),
102
107
  children
103
108
  };
104
109
  }
105
110
 
106
111
  /**
107
- * @param {(string | boolean | StatsOptions)=} options stats options
112
+ * @param {(string | boolean | MultiStatsOptions)=} options stats options
108
113
  * @returns {StatsCompilation} json output
109
114
  */
110
115
  toJson(options) {
@@ -130,7 +135,7 @@ class MultiStats {
130
135
  obj.version = obj.children[0].version;
131
136
  }
132
137
  if (childOptions.hash) {
133
- obj.hash = obj.children.map(j => j.hash).join("");
138
+ obj.hash = obj.children.map((j) => j.hash).join("");
134
139
  }
135
140
  /**
136
141
  * @param {StatsCompilation} j stats error
@@ -179,7 +184,7 @@ class MultiStats {
179
184
  }
180
185
 
181
186
  /**
182
- * @param {(string | boolean | StatsOptions)=} options stats options
187
+ * @param {(string | boolean | MultiStatsOptions)=} options stats options
183
188
  * @returns {string} string output
184
189
  */
185
190
  toString(options) {
@@ -67,7 +67,7 @@ class MultiWatching {
67
67
  (watching, finishedCallback) => {
68
68
  watching.close(finishedCallback);
69
69
  },
70
- err => {
70
+ (err) => {
71
71
  this.compiler.hooks.watchClose.call();
72
72
  if (typeof callback === "function") {
73
73
  this.compiler.running = false;
@@ -16,10 +16,10 @@ class NoEmitOnErrorsPlugin {
16
16
  * @returns {void}
17
17
  */
18
18
  apply(compiler) {
19
- compiler.hooks.shouldEmit.tap(PLUGIN_NAME, compilation => {
19
+ compiler.hooks.shouldEmit.tap(PLUGIN_NAME, (compilation) => {
20
20
  if (compilation.getStats().hasErrors()) return false;
21
21
  });
22
- compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
22
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
23
23
  compilation.hooks.shouldRecord.tap(PLUGIN_NAME, () => {
24
24
  if (compilation.getStats().hasErrors()) return false;
25
25
  });
@@ -74,7 +74,7 @@ class NodeStuffPlugin {
74
74
 
75
75
  if (localOptions.global !== false) {
76
76
  const withWarning = localOptions.global === "warn";
77
- parser.hooks.expression.for("global").tap(PLUGIN_NAME, expr => {
77
+ parser.hooks.expression.for("global").tap(PLUGIN_NAME, (expr) => {
78
78
  const dep = new ConstDependency(
79
79
  RuntimeGlobals.global,
80
80
  /** @type {Range} */ (expr.range),
@@ -94,7 +94,7 @@ class NodeStuffPlugin {
94
94
  );
95
95
  }
96
96
  });
97
- parser.hooks.rename.for("global").tap(PLUGIN_NAME, expr => {
97
+ parser.hooks.rename.for("global").tap(PLUGIN_NAME, (expr) => {
98
98
  const dep = new ConstDependency(
99
99
  RuntimeGlobals.global,
100
100
  /** @type {Range} */ (expr.range),
@@ -115,10 +115,11 @@ class NodeStuffPlugin {
115
115
  const setModuleConstant = (expressionName, fn, warning) => {
116
116
  parser.hooks.expression
117
117
  .for(expressionName)
118
- .tap(PLUGIN_NAME, expr => {
118
+ .tap(PLUGIN_NAME, (expr) => {
119
119
  const dep = new CachedConstDependency(
120
120
  JSON.stringify(fn(parser.state.module)),
121
- /** @type {Range} */ (expr.range),
121
+ /** @type {Range} */
122
+ (expr.range),
122
123
  expressionName
123
124
  );
124
125
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
@@ -143,7 +144,7 @@ class NodeStuffPlugin {
143
144
  const setUrlModuleConstant = (expressionName, fn) => {
144
145
  parser.hooks.expression
145
146
  .for(expressionName)
146
- .tap(PLUGIN_NAME, expr => {
147
+ .tap(PLUGIN_NAME, (expr) => {
147
148
  const dep = new ExternalModuleDependency(
148
149
  "url",
149
150
  [
@@ -186,14 +187,19 @@ class NodeStuffPlugin {
186
187
  "__filename is a Node.js feature and isn't available in browsers."
187
188
  );
188
189
  break;
189
- case "node-module":
190
+ case "node-module": {
191
+ const importMetaName =
192
+ /** @type {string} */
193
+ (compilation.outputOptions.importMetaName);
194
+
190
195
  setUrlModuleConstant(
191
196
  "__filename",
192
- functionName => `${functionName}(import.meta.url)`
197
+ (functionName) => `${functionName}(${importMetaName}.url)`
193
198
  );
194
199
  break;
200
+ }
195
201
  case true:
196
- setModuleConstant("__filename", module =>
202
+ setModuleConstant("__filename", (module) =>
197
203
  relative(
198
204
  /** @type {InputFileSystem} */ (compiler.inputFileSystem),
199
205
  context,
@@ -205,7 +211,7 @@ class NodeStuffPlugin {
205
211
 
206
212
  parser.hooks.evaluateIdentifier
207
213
  .for("__filename")
208
- .tap(PLUGIN_NAME, expr => {
214
+ .tap(PLUGIN_NAME, (expr) => {
209
215
  if (!parser.state.module) return;
210
216
  const resource = parseResource(parser.state.module.resource);
211
217
  return evaluateToString(resource.path)(expr);
@@ -223,15 +229,20 @@ class NodeStuffPlugin {
223
229
  "__dirname is a Node.js feature and isn't available in browsers."
224
230
  );
225
231
  break;
226
- case "node-module":
232
+ case "node-module": {
233
+ const importMetaName =
234
+ /** @type {string} */
235
+ (compilation.outputOptions.importMetaName);
236
+
227
237
  setUrlModuleConstant(
228
238
  "__dirname",
229
- functionName =>
230
- `${functionName}(import.meta.url + "/..").slice(0, -1)`
239
+ (functionName) =>
240
+ `${functionName}(${importMetaName}.url + "/..").slice(0, -1)`
231
241
  );
232
242
  break;
243
+ }
233
244
  case true:
234
- setModuleConstant("__dirname", module =>
245
+ setModuleConstant("__dirname", (module) =>
235
246
  relative(
236
247
  /** @type {InputFileSystem} */ (compiler.inputFileSystem),
237
248
  context,
@@ -243,10 +254,11 @@ class NodeStuffPlugin {
243
254
 
244
255
  parser.hooks.evaluateIdentifier
245
256
  .for("__dirname")
246
- .tap(PLUGIN_NAME, expr => {
257
+ .tap(PLUGIN_NAME, (expr) => {
247
258
  if (!parser.state.module) return;
248
259
  return evaluateToString(
249
- /** @type {string} */ (parser.state.module.context)
260
+ /** @type {string} */
261
+ (parser.state.module.context)
250
262
  )(expr);
251
263
  });
252
264
  }
@@ -40,7 +40,8 @@ const {
40
40
  compareLocations,
41
41
  compareSelect,
42
42
  concatComparators,
43
- keepOriginalOrder
43
+ keepOriginalOrder,
44
+ sortWithSourceOrder
44
45
  } = require("./util/comparators");
45
46
  const createHash = require("./util/createHash");
46
47
  const { createFakeHook } = require("./util/deprecation");
@@ -99,6 +100,8 @@ const memoize = require("./util/memoize");
99
100
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
100
101
  /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
101
102
  /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
103
+ /** @typedef {import("./dependencies/HarmonyImportSideEffectDependency")} HarmonyImportSideEffectDependency */
104
+ /** @typedef {import("./dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */
102
105
  /**
103
106
  * @template T
104
107
  * @typedef {import("./util/deprecation").FakeHook<T>} FakeHook
@@ -160,17 +163,17 @@ const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
160
163
  const { sourceRoot } = sourceMap;
161
164
  /** @type {(source: string) => string} */
162
165
  const mapper = !sourceRoot
163
- ? source => source
166
+ ? (source) => source
164
167
  : sourceRoot.endsWith("/")
165
- ? source =>
168
+ ? (source) =>
166
169
  source.startsWith("/")
167
170
  ? `${sourceRoot.slice(0, -1)}${source}`
168
171
  : `${sourceRoot}${source}`
169
- : source =>
172
+ : (source) =>
170
173
  source.startsWith("/")
171
174
  ? `${sourceRoot}${source}`
172
175
  : `${sourceRoot}/${source}`;
173
- const newSources = sourceMap.sources.map(source =>
176
+ const newSources = sourceMap.sources.map((source) =>
174
177
  contextifySourceUrl(context, mapper(source), associatedObjectForCache)
175
178
  );
176
179
  return {
@@ -185,7 +188,7 @@ const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
185
188
  * @param {string | Buffer} input the input
186
189
  * @returns {string} the converted string
187
190
  */
188
- const asString = input => {
191
+ const asString = (input) => {
189
192
  if (Buffer.isBuffer(input)) {
190
193
  return input.toString("utf8");
191
194
  }
@@ -196,7 +199,7 @@ const asString = input => {
196
199
  * @param {string | Buffer} input the input
197
200
  * @returns {Buffer} the converted buffer
198
201
  */
199
- const asBuffer = input => {
202
+ const asBuffer = (input) => {
200
203
  if (!Buffer.isBuffer(input)) {
201
204
  return Buffer.from(input, "utf8");
202
205
  }
@@ -276,14 +279,14 @@ class NormalModule extends Module {
276
279
  beforeParse: new SyncHook(["module"]),
277
280
  beforeSnapshot: new SyncHook(["module"]),
278
281
  // TODO webpack 6 deprecate
279
- readResourceForScheme: new HookMap(scheme => {
282
+ readResourceForScheme: new HookMap((scheme) => {
280
283
  const hook =
281
284
  /** @type {NormalModuleCompilationHooks} */
282
285
  (hooks).readResource.for(scheme);
283
286
  return createFakeHook(
284
287
  /** @type {AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>} */ ({
285
288
  tap: (options, fn) =>
286
- hook.tap(options, loaderContext =>
289
+ hook.tap(options, (loaderContext) =>
287
290
  fn(
288
291
  loaderContext.resource,
289
292
  /** @type {NormalModule} */ (loaderContext._module)
@@ -298,7 +301,7 @@ class NormalModule extends Module {
298
301
  )
299
302
  ),
300
303
  tapPromise: (options, fn) =>
301
- hook.tapPromise(options, loaderContext =>
304
+ hook.tapPromise(options, (loaderContext) =>
302
305
  fn(
303
306
  loaderContext.resource,
304
307
  /** @type {NormalModule} */ (loaderContext._module)
@@ -596,19 +599,19 @@ class NormalModule extends Module {
596
599
  */
597
600
  const getResolveContext = () => ({
598
601
  fileDependencies: {
599
- add: d =>
602
+ add: (d) =>
600
603
  /** @type {LoaderContext<EXPECTED_ANY>} */ (
601
604
  loaderContext
602
605
  ).addDependency(d)
603
606
  },
604
607
  contextDependencies: {
605
- add: d =>
608
+ add: (d) =>
606
609
  /** @type {LoaderContext<EXPECTED_ANY>} */ (
607
610
  loaderContext
608
611
  ).addContextDependency(d)
609
612
  },
610
613
  missingDependencies: {
611
- add: d =>
614
+ add: (d) =>
612
615
  /** @type {LoaderContext<EXPECTED_ANY>} */ (
613
616
  loaderContext
614
617
  ).addMissingDependency(d)
@@ -657,7 +660,7 @@ class NormalModule extends Module {
657
660
  * @param {HashFunction=} type type
658
661
  * @returns {Hash} hash
659
662
  */
660
- createHash: type =>
663
+ createHash: (type) =>
661
664
  createHash(
662
665
  type ||
663
666
  /** @type {HashFunction} */
@@ -671,7 +674,7 @@ class NormalModule extends Module {
671
674
  * @param {import("../declarations/LoaderContext").Schema=} schema schema
672
675
  * @returns {T} options
673
676
  */
674
- getOptions: schema => {
677
+ getOptions: (schema) => {
675
678
  const loader = this.getCurrentLoader(
676
679
  /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext)
677
680
  );
@@ -713,7 +716,7 @@ class NormalModule extends Module {
713
716
 
714
717
  return /** @type {T} */ (options);
715
718
  },
716
- emitWarning: warning => {
719
+ emitWarning: (warning) => {
717
720
  if (!(warning instanceof Error)) {
718
721
  warning = new NonErrorEmittedError(warning);
719
722
  }
@@ -723,7 +726,7 @@ class NormalModule extends Module {
723
726
  })
724
727
  );
725
728
  },
726
- emitError: error => {
729
+ emitError: (error) => {
727
730
  if (!(error instanceof Error)) {
728
731
  error = new NonErrorEmittedError(error);
729
732
  }
@@ -733,7 +736,7 @@ class NormalModule extends Module {
733
736
  })
734
737
  );
735
738
  },
736
- getLogger: name => {
739
+ getLogger: (name) => {
737
740
  const currentLoader = this.getCurrentLoader(
738
741
  /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext)
739
742
  );
@@ -799,7 +802,7 @@ class NormalModule extends Module {
799
802
  );
800
803
  assetsInfo.set(name, assetInfo);
801
804
  },
802
- addBuildDependency: dep => {
805
+ addBuildDependency: (dep) => {
803
806
  const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
804
807
 
805
808
  if (buildInfo.buildDependencies === undefined) {
@@ -1187,7 +1190,7 @@ class NormalModule extends Module {
1187
1190
 
1188
1191
  const hooks = NormalModule.getCompilationHooks(compilation);
1189
1192
 
1190
- return this._doBuild(options, compilation, resolver, fs, hooks, err => {
1193
+ return this._doBuild(options, compilation, resolver, fs, hooks, (err) => {
1191
1194
  // if we have an error mark module as failed and exit
1192
1195
  if (err) {
1193
1196
  this.markModuleAsErrored(err);
@@ -1199,9 +1202,9 @@ class NormalModule extends Module {
1199
1202
  * @param {Error} e error
1200
1203
  * @returns {void}
1201
1204
  */
1202
- const handleParseError = e => {
1205
+ const handleParseError = (e) => {
1203
1206
  const source = /** @type {Source} */ (this._source).source();
1204
- const loaders = this.loaders.map(item =>
1207
+ const loaders = this.loaders.map((item) =>
1205
1208
  contextify(
1206
1209
  /** @type {string} */ (options.context),
1207
1210
  item.loader,
@@ -1217,10 +1220,11 @@ class NormalModule extends Module {
1217
1220
  const handleParseResult = () => {
1218
1221
  this.dependencies.sort(
1219
1222
  concatComparators(
1220
- compareSelect(a => a.loc, compareLocations),
1223
+ compareSelect((a) => a.loc, compareLocations),
1221
1224
  keepOriginalOrder(this.dependencies)
1222
1225
  )
1223
1226
  );
1227
+ sortWithSourceOrder(this.dependencies, new WeakMap());
1224
1228
  this._initBuildHash(compilation);
1225
1229
  this._lastSuccessfulBuildMeta =
1226
1230
  /** @type {BuildMeta} */
@@ -1248,7 +1252,7 @@ class NormalModule extends Module {
1248
1252
  /**
1249
1253
  * @param {LazySet<string>} deps deps
1250
1254
  */
1251
- const checkDependencies = deps => {
1255
+ const checkDependencies = (deps) => {
1252
1256
  for (const dep of deps) {
1253
1257
  if (!ABSOLUTE_PATH_REGEX.test(dep)) {
1254
1258
  if (nonAbsoluteDependencies === undefined) {