webpack 5.99.9 → 5.100.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 (308) hide show
  1. package/bin/webpack.js +8 -2
  2. package/hot/log.js +15 -15
  3. package/hot/poll.js +1 -0
  4. package/lib/APIPlugin.js +3 -3
  5. package/lib/AbstractMethodError.js +1 -0
  6. package/lib/AutomaticPrefetchPlugin.js +1 -0
  7. package/lib/BannerPlugin.js +1 -1
  8. package/lib/CaseSensitiveModulesWarning.js +4 -4
  9. package/lib/Chunk.js +6 -6
  10. package/lib/ChunkGraph.js +37 -31
  11. package/lib/ChunkGroup.js +4 -4
  12. package/lib/ChunkTemplate.js +1 -1
  13. package/lib/CleanPlugin.js +94 -17
  14. package/lib/CodeGenerationResults.js +1 -1
  15. package/lib/CompatibilityPlugin.js +5 -2
  16. package/lib/Compilation.js +67 -45
  17. package/lib/Compiler.js +46 -16
  18. package/lib/ConcatenationScope.js +15 -6
  19. package/lib/ConstPlugin.js +5 -3
  20. package/lib/ContextModule.js +16 -12
  21. package/lib/ContextModuleFactory.js +4 -3
  22. package/lib/ContextReplacementPlugin.js +4 -2
  23. package/lib/CssModule.js +2 -2
  24. package/lib/DefinePlugin.js +111 -3
  25. package/lib/DelegatedModuleFactoryPlugin.js +18 -18
  26. package/lib/Dependency.js +11 -4
  27. package/lib/DependencyTemplate.js +1 -0
  28. package/lib/DllEntryPlugin.js +3 -1
  29. package/lib/DllPlugin.js +4 -3
  30. package/lib/DllReferencePlugin.js +2 -2
  31. package/lib/DynamicEntryPlugin.js +1 -1
  32. package/lib/EntryOptionPlugin.js +5 -0
  33. package/lib/ErrorHelpers.js +4 -4
  34. package/lib/EvalDevToolModulePlugin.js +3 -3
  35. package/lib/EvalSourceMapDevToolPlugin.js +7 -7
  36. package/lib/ExportsInfo.js +48 -39
  37. package/lib/ExternalModule.js +15 -11
  38. package/lib/ExternalModuleFactoryPlugin.js +5 -2
  39. package/lib/FileSystemInfo.js +51 -36
  40. package/lib/FlagDependencyExportsPlugin.js +14 -7
  41. package/lib/FlagDependencyUsagePlugin.js +1 -1
  42. package/lib/Generator.js +14 -1
  43. package/lib/HookWebpackError.js +1 -0
  44. package/lib/HotModuleReplacementPlugin.js +77 -50
  45. package/lib/IgnorePlugin.js +5 -2
  46. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  47. package/lib/JavascriptMetaInfoPlugin.js +0 -1
  48. package/lib/LibManifestPlugin.js +4 -2
  49. package/lib/LoaderOptionsPlugin.js +6 -4
  50. package/lib/MainTemplate.js +2 -2
  51. package/lib/Module.js +21 -6
  52. package/lib/ModuleFactory.js +1 -0
  53. package/lib/ModuleGraph.js +24 -2
  54. package/lib/ModuleGraphConnection.js +5 -5
  55. package/lib/ModuleInfoHeaderPlugin.js +2 -1
  56. package/lib/ModuleParseError.js +1 -0
  57. package/lib/ModuleSourceTypesConstants.js +12 -12
  58. package/lib/ModuleTemplate.js +1 -1
  59. package/lib/ModuleTypeConstants.js +21 -21
  60. package/lib/MultiCompiler.js +6 -6
  61. package/lib/NormalModule.js +31 -44
  62. package/lib/NormalModuleFactory.js +34 -20
  63. package/lib/NormalModuleReplacementPlugin.js +1 -1
  64. package/lib/NullFactory.js +1 -0
  65. package/lib/OptimizationStages.js +1 -1
  66. package/lib/Parser.js +1 -0
  67. package/lib/ProgressPlugin.js +12 -5
  68. package/lib/ProvidePlugin.js +5 -1
  69. package/lib/RawModule.js +14 -0
  70. package/lib/RecordIdsPlugin.js +3 -3
  71. package/lib/RuntimeGlobals.js +175 -155
  72. package/lib/RuntimeModule.js +1 -0
  73. package/lib/RuntimePlugin.js +33 -7
  74. package/lib/RuntimeTemplate.js +111 -11
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
  76. package/lib/SourceMapDevToolPlugin.js +19 -17
  77. package/lib/Template.js +2 -2
  78. package/lib/TemplatedPathPlugin.js +1 -1
  79. package/lib/WarnDeprecatedOptionPlugin.js +7 -8
  80. package/lib/WatchIgnorePlugin.js +4 -3
  81. package/lib/WebpackIsIncludedPlugin.js +2 -1
  82. package/lib/WebpackOptionsApply.js +115 -27
  83. package/lib/asset/AssetGenerator.js +15 -11
  84. package/lib/asset/AssetModulesPlugin.js +19 -17
  85. package/lib/asset/AssetSourceGenerator.js +4 -4
  86. package/lib/asset/RawDataUrlModule.js +4 -2
  87. package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
  88. package/lib/buildChunkGraph.js +6 -3
  89. package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
  90. package/lib/cache/IdleFileCachePlugin.js +7 -4
  91. package/lib/cache/MemoryCachePlugin.js +1 -0
  92. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  93. package/lib/cache/PackFileCacheStrategy.js +26 -20
  94. package/lib/cache/ResolverCachePlugin.js +16 -8
  95. package/lib/cli.js +15 -10
  96. package/lib/config/browserslistTargetHandler.js +3 -3
  97. package/lib/config/defaults.js +25 -17
  98. package/lib/config/normalization.js +2 -1
  99. package/lib/config/target.js +6 -5
  100. package/lib/container/ContainerPlugin.js +1 -1
  101. package/lib/container/ContainerReferencePlugin.js +1 -1
  102. package/lib/container/FallbackModule.js +2 -1
  103. package/lib/container/HoistContainerReferencesPlugin.js +1 -1
  104. package/lib/container/ModuleFederationPlugin.js +2 -2
  105. package/lib/container/RemoteModule.js +1 -1
  106. package/lib/css/CssGenerator.js +9 -6
  107. package/lib/css/CssModulesPlugin.js +44 -31
  108. package/lib/css/CssParser.js +6 -4
  109. package/lib/css/walkCssTokens.js +33 -37
  110. package/lib/debug/ProfilingPlugin.js +6 -6
  111. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
  112. package/lib/dependencies/AMDPlugin.js +12 -8
  113. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
  114. package/lib/dependencies/CachedConstDependency.js +1 -5
  115. package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
  116. package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
  117. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
  118. package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
  119. package/lib/dependencies/CommonJsPlugin.js +15 -16
  120. package/lib/dependencies/ContextDependencyHelpers.js +2 -1
  121. package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
  122. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
  123. package/lib/dependencies/CssIcssExportDependency.js +1 -1
  124. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  125. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  126. package/lib/dependencies/DynamicExports.js +9 -9
  127. package/lib/dependencies/ExportsInfoDependency.js +1 -1
  128. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
  129. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  130. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
  131. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  132. package/lib/dependencies/HarmonyImportDependency.js +11 -5
  133. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
  134. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
  135. package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
  136. package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
  137. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  138. package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
  139. package/lib/dependencies/ImportMetaPlugin.js +2 -2
  140. package/lib/dependencies/ImportParserPlugin.js +40 -9
  141. package/lib/dependencies/ImportPlugin.js +3 -1
  142. package/lib/dependencies/LoaderPlugin.js +1 -0
  143. package/lib/dependencies/ModuleDependency.js +3 -1
  144. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
  145. package/lib/dependencies/RequireContextPlugin.js +3 -1
  146. package/lib/dependencies/RequireEnsurePlugin.js +6 -6
  147. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
  148. package/lib/dependencies/RequireIncludePlugin.js +1 -0
  149. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  150. package/lib/dependencies/SystemPlugin.js +1 -1
  151. package/lib/dependencies/URLContextDependency.js +65 -0
  152. package/lib/dependencies/URLPlugin.js +17 -157
  153. package/lib/dependencies/WorkerPlugin.js +23 -10
  154. package/lib/dependencies/processExportInfo.js +2 -1
  155. package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
  156. package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
  157. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
  158. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  159. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
  160. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  161. package/lib/hmr/LazyCompilationPlugin.js +4 -2
  162. package/lib/hmr/lazyCompilationBackend.js +4 -2
  163. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
  164. package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
  165. package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
  166. package/lib/ids/HashedModuleIdsPlugin.js +5 -4
  167. package/lib/ids/IdHelpers.js +21 -17
  168. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  169. package/lib/ids/NamedModuleIdsPlugin.js +4 -4
  170. package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
  171. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  172. package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
  173. package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
  174. package/lib/ids/SyncModuleIdsPlugin.js +1 -1
  175. package/lib/index.js +13 -3
  176. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
  177. package/lib/javascript/BasicEvaluatedExpression.js +2 -1
  178. package/lib/javascript/ChunkHelpers.js +1 -0
  179. package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
  180. package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
  181. package/lib/javascript/JavascriptGenerator.js +14 -2
  182. package/lib/javascript/JavascriptModulesPlugin.js +68 -27
  183. package/lib/javascript/JavascriptParser.js +117 -76
  184. package/lib/javascript/JavascriptParserHelpers.js +41 -41
  185. package/lib/javascript/StartupHelpers.js +17 -17
  186. package/lib/json/JsonGenerator.js +4 -2
  187. package/lib/json/JsonModulesPlugin.js +2 -2
  188. package/lib/json/JsonParser.js +1 -1
  189. package/lib/library/AbstractLibraryPlugin.js +6 -2
  190. package/lib/library/AssignLibraryPlugin.js +21 -6
  191. package/lib/library/EnableLibraryPlugin.js +23 -3
  192. package/lib/library/UmdLibraryPlugin.js +15 -6
  193. package/lib/logging/createConsoleLogger.js +3 -3
  194. package/lib/logging/runtime.js +9 -9
  195. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
  196. package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
  197. package/lib/node/nodeConsole.js +4 -2
  198. package/lib/optimize/AggressiveMergingPlugin.js +45 -46
  199. package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
  200. package/lib/optimize/ConcatenatedModule.js +227 -57
  201. package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
  202. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
  203. package/lib/optimize/InnerGraph.js +115 -112
  204. package/lib/optimize/InnerGraphPlugin.js +2 -2
  205. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  206. package/lib/optimize/MangleExportsPlugin.js +4 -3
  207. package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
  208. package/lib/optimize/MinChunkSizePlugin.js +6 -3
  209. package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
  210. package/lib/optimize/RealContentHashPlugin.js +26 -20
  211. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
  212. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  213. package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
  214. package/lib/optimize/SplitChunksPlugin.js +16 -13
  215. package/lib/rules/BasicEffectRulePlugin.js +4 -2
  216. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  217. package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
  218. package/lib/rules/RuleSetCompiler.js +19 -5
  219. package/lib/rules/UseEffectRulePlugin.js +17 -9
  220. package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
  221. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
  222. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
  223. package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
  224. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
  225. package/lib/schemes/FileUriPlugin.js +1 -1
  226. package/lib/schemes/HttpUriPlugin.js +27 -19
  227. package/lib/schemes/VirtualUrlPlugin.js +222 -0
  228. package/lib/serialization/AggregateErrorSerializer.js +1 -1
  229. package/lib/serialization/BinaryMiddleware.js +5 -4
  230. package/lib/serialization/FileMiddleware.js +7 -4
  231. package/lib/serialization/ObjectMiddleware.js +14 -8
  232. package/lib/serialization/Serializer.js +5 -3
  233. package/lib/serialization/SerializerMiddleware.js +2 -0
  234. package/lib/sharing/ConsumeSharedModule.js +1 -1
  235. package/lib/sharing/ConsumeSharedPlugin.js +3 -3
  236. package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
  237. package/lib/sharing/ProvideSharedModule.js +1 -1
  238. package/lib/sharing/ProvideSharedPlugin.js +3 -2
  239. package/lib/sharing/SharePlugin.js +2 -1
  240. package/lib/sharing/ShareRuntimeModule.js +3 -5
  241. package/lib/sharing/utils.js +34 -34
  242. package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
  243. package/lib/stats/DefaultStatsPresetPlugin.js +13 -13
  244. package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
  245. package/lib/stats/StatsFactory.js +6 -3
  246. package/lib/stats/StatsPrinter.js +6 -7
  247. package/lib/url/URLParserPlugin.js +266 -0
  248. package/lib/util/ArrayQueue.js +1 -1
  249. package/lib/util/AsyncQueue.js +1 -1
  250. package/lib/util/Hash.js +2 -0
  251. package/lib/util/IterableHelpers.js +1 -1
  252. package/lib/util/LazyBucketSortedSet.js +2 -1
  253. package/lib/util/LazySet.js +11 -6
  254. package/lib/util/ParallelismFactorCalculator.js +1 -1
  255. package/lib/util/SetHelpers.js +3 -3
  256. package/lib/util/SortableSet.js +2 -2
  257. package/lib/util/StackedCacheMap.js +3 -1
  258. package/lib/util/StackedMap.js +2 -2
  259. package/lib/util/StringXor.js +1 -0
  260. package/lib/util/TupleSet.js +1 -0
  261. package/lib/util/URLAbsoluteSpecifier.js +1 -1
  262. package/lib/util/cleverMerge.js +95 -58
  263. package/lib/util/comparators.js +154 -127
  264. package/lib/util/compileBooleanMatcher.js +8 -3
  265. package/lib/util/concatenate.js +8 -7
  266. package/lib/util/conventions.js +72 -73
  267. package/lib/util/create-schema-validation.js +2 -1
  268. package/lib/util/createHash.js +10 -4
  269. package/lib/util/deprecation.js +69 -66
  270. package/lib/util/deterministicGrouping.js +4 -2
  271. package/lib/util/extractUrlAndGlobal.js +1 -1
  272. package/lib/util/findGraphRoots.js +2 -2
  273. package/lib/util/fs.js +30 -23
  274. package/lib/util/hash/md4.js +2 -2
  275. package/lib/util/hash/wasm-hash.js +4 -2
  276. package/lib/util/identifier.js +13 -12
  277. package/lib/util/internalSerializables.js +2 -0
  278. package/lib/util/magicComment.js +5 -5
  279. package/lib/util/processAsyncTree.js +1 -1
  280. package/lib/util/propertyAccess.js +1 -1
  281. package/lib/util/propertyName.js +1 -1
  282. package/lib/util/registerExternalSerializer.js +1 -2
  283. package/lib/util/removeBOM.js +1 -1
  284. package/lib/util/runtime.js +29 -21
  285. package/lib/util/semver.js +1 -1
  286. package/lib/util/serialization.js +3 -0
  287. package/lib/util/source.js +3 -2
  288. package/lib/validateSchema.js +1 -0
  289. package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
  290. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
  291. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
  292. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  293. package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
  294. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
  295. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
  296. package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
  297. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
  298. package/lib/webpack.js +4 -5
  299. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  300. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
  301. package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
  302. package/package.json +119 -113
  303. package/schemas/WebpackOptions.check.js +1 -1
  304. package/schemas/WebpackOptions.json +17 -0
  305. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  306. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  307. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  308. package/types.d.ts +1243 -409
@@ -441,8 +441,9 @@ class ModuleGraph {
441
441
  /** @type {Dependency} */ (connection.dependency),
442
442
  connection
443
443
  );
444
- if (connection.dependency === dependency)
444
+ if (connection.dependency === dependency) {
445
445
  foundConnection = connection;
446
+ }
446
447
  }
447
448
  mgm._unassignedConnections.length = 0;
448
449
  if (foundConnection !== undefined) {
@@ -752,6 +753,26 @@ class ModuleGraph {
752
753
  return mgm.async;
753
754
  }
754
755
 
756
+ /**
757
+ * @param {Module} module the module
758
+ * @returns {boolean} true, if the module is used as a deferred module at least once
759
+ */
760
+ isDeferred(module) {
761
+ if (this.isAsync(module)) return false;
762
+ const connections = this.getIncomingConnections(module);
763
+ for (const connection of connections) {
764
+ if (
765
+ !connection.dependency ||
766
+ connection.dependency instanceof
767
+ require("./dependencies/CommonJsSelfReferenceDependency")
768
+ ) {
769
+ continue;
770
+ }
771
+ if (connection.dependency.defer) return true;
772
+ }
773
+ return false;
774
+ }
775
+
755
776
  /**
756
777
  * @param {Module} module the module
757
778
  * @returns {void}
@@ -860,12 +881,13 @@ class ModuleGraph {
860
881
  */
861
882
  module => {
862
883
  const moduleGraph = moduleGraphForModuleMap.get(module);
863
- if (!moduleGraph)
884
+ if (!moduleGraph) {
864
885
  throw new Error(
865
886
  `${
866
887
  deprecateMessage
867
888
  }There was no ModuleGraph assigned to the Module for backward-compat (Use the new API)`
868
889
  );
890
+ }
869
891
  return moduleGraph;
870
892
  },
871
893
  `${deprecateMessage}: Use new ModuleGraph API`,
@@ -132,7 +132,7 @@ class ModuleGraphConnection {
132
132
 
133
133
  get explanation() {
134
134
  if (this.explanations === undefined) return "";
135
- return Array.from(this.explanations).join(" ");
135
+ return [...this.explanations].join(" ");
136
136
  }
137
137
 
138
138
  /**
@@ -190,10 +190,10 @@ class ModuleGraphConnection {
190
190
  /** @typedef {typeof CIRCULAR_CONNECTION} CIRCULAR_CONNECTION */
191
191
 
192
192
  module.exports = ModuleGraphConnection;
193
- module.exports.addConnectionStates = addConnectionStates;
194
- module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
195
- TRANSITIVE_ONLY
196
- );
197
193
  module.exports.CIRCULAR_CONNECTION = /** @type {typeof CIRCULAR_CONNECTION} */ (
198
194
  CIRCULAR_CONNECTION
199
195
  );
196
+ module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
197
+ TRANSITIVE_ONLY
198
+ );
199
+ module.exports.addConnectionStates = addConnectionStates;
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const { ConcatSource, RawSource, CachedSource } = require("webpack-sources");
8
+ const { CachedSource, ConcatSource, RawSource } = require("webpack-sources");
9
9
  const { UsageState } = require("./ExportsInfo");
10
10
  const Template = require("./Template");
11
11
  const CssModulesPlugin = require("./css/CssModulesPlugin");
@@ -310,4 +310,5 @@ class ModuleInfoHeaderPlugin {
310
310
  return new RawSource(headerStr);
311
311
  }
312
312
  }
313
+
313
314
  module.exports = ModuleInfoHeaderPlugin;
@@ -62,6 +62,7 @@ class ModuleParseError extends WebpackError {
62
62
 
63
63
  if (
64
64
  Buffer.isBuffer(source) ||
65
+ // eslint-disable-next-line no-control-regex
65
66
  /[\0\u0001\u0002\u0003\u0004\u0005\u0006\u0007]/.test(source)
66
67
  ) {
67
68
  // binary file
@@ -102,22 +102,22 @@ const CONSUME_SHARED_TYPES = new Set(["consume-shared"]);
102
102
  */
103
103
  const SHARED_INIT_TYPES = new Set(["share-init"]);
104
104
 
105
- module.exports.NO_TYPES = NO_TYPES;
106
- module.exports.JS_TYPE = JS_TYPE;
107
- module.exports.JS_TYPES = JS_TYPES;
108
- module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;
109
- module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;
110
- module.exports.JS_AND_CSS_EXPORT_TYPES = JS_AND_CSS_EXPORT_TYPES;
111
- module.exports.ASSET_TYPES = ASSET_TYPES;
112
- module.exports.ASSET_AND_JS_TYPES = ASSET_AND_JS_TYPES;
113
105
  module.exports.ASSET_AND_CSS_URL_TYPES = ASSET_AND_CSS_URL_TYPES;
114
106
  module.exports.ASSET_AND_JS_AND_CSS_URL_TYPES = ASSET_AND_JS_AND_CSS_URL_TYPES;
107
+ module.exports.ASSET_AND_JS_TYPES = ASSET_AND_JS_TYPES;
108
+ module.exports.ASSET_TYPES = ASSET_TYPES;
109
+ module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
110
+ module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
115
111
  module.exports.CSS_TYPE = CSS_TYPE;
116
112
  module.exports.CSS_TYPES = CSS_TYPES;
117
113
  module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
118
- module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
119
- module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
120
- module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
114
+ module.exports.JS_AND_CSS_EXPORT_TYPES = JS_AND_CSS_EXPORT_TYPES;
115
+ module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;
116
+ module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;
117
+ module.exports.JS_TYPE = JS_TYPE;
118
+ module.exports.JS_TYPES = JS_TYPES;
119
+ module.exports.NO_TYPES = NO_TYPES;
121
120
  module.exports.REMOTE_AND_SHARE_INIT_TYPES = REMOTE_AND_SHARE_INIT_TYPES;
122
- module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
121
+ module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
123
122
  module.exports.SHARED_INIT_TYPES = SHARED_INIT_TYPES;
123
+ module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
@@ -163,7 +163,7 @@ Object.defineProperty(ModuleTemplate.prototype, "runtimeTemplate", {
163
163
  * @this {ModuleTemplate}
164
164
  * @returns {RuntimeTemplate} output options
165
165
  */
166
- function () {
166
+ function runtimeTemplate() {
167
167
  return this._runtimeTemplate;
168
168
  },
169
169
  "ModuleTemplate.runtimeTemplate is deprecated (use Compilation.runtimeTemplate instead)",
@@ -144,40 +144,40 @@ const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY = "lazy-compilation-proxy";
144
144
  /** @typedef {JavaScriptModuleTypes | JSONModuleType | WebAssemblyModuleTypes | CSSModuleTypes | AssetModuleTypes | WebpackModuleTypes | UnknownModuleTypes} ModuleTypes */
145
145
 
146
146
  module.exports.ASSET_MODULE_TYPE = ASSET_MODULE_TYPE;
147
+ module.exports.ASSET_MODULE_TYPE_INLINE = ASSET_MODULE_TYPE_INLINE;
147
148
  module.exports.ASSET_MODULE_TYPE_RAW_DATA_URL = ASSET_MODULE_TYPE_RAW_DATA_URL;
148
- module.exports.ASSET_MODULE_TYPE_SOURCE = ASSET_MODULE_TYPE_SOURCE;
149
149
  module.exports.ASSET_MODULE_TYPE_RESOURCE = ASSET_MODULE_TYPE_RESOURCE;
150
- module.exports.ASSET_MODULE_TYPE_INLINE = ASSET_MODULE_TYPE_INLINE;
151
- module.exports.JAVASCRIPT_MODULE_TYPE_AUTO = JAVASCRIPT_MODULE_TYPE_AUTO;
152
- module.exports.JAVASCRIPT_MODULE_TYPE_DYNAMIC = JAVASCRIPT_MODULE_TYPE_DYNAMIC;
153
- module.exports.JAVASCRIPT_MODULE_TYPE_ESM = JAVASCRIPT_MODULE_TYPE_ESM;
150
+ module.exports.ASSET_MODULE_TYPE_SOURCE = ASSET_MODULE_TYPE_SOURCE;
151
+ module.exports.CSS_MODULES = [
152
+ CSS_MODULE_TYPE,
153
+ CSS_MODULE_TYPE_GLOBAL,
154
+ CSS_MODULE_TYPE_MODULE,
155
+ CSS_MODULE_TYPE_AUTO
156
+ ];
157
+ module.exports.CSS_MODULE_TYPE = CSS_MODULE_TYPE;
158
+ module.exports.CSS_MODULE_TYPE_AUTO = CSS_MODULE_TYPE_AUTO;
159
+ module.exports.CSS_MODULE_TYPE_GLOBAL = CSS_MODULE_TYPE_GLOBAL;
160
+ module.exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE;
154
161
  module.exports.JAVASCRIPT_MODULES = [
155
162
  JAVASCRIPT_MODULE_TYPE_AUTO,
156
163
  JAVASCRIPT_MODULE_TYPE_DYNAMIC,
157
164
  JAVASCRIPT_MODULE_TYPE_ESM
158
165
  ];
166
+ module.exports.JAVASCRIPT_MODULE_TYPE_AUTO = JAVASCRIPT_MODULE_TYPE_AUTO;
167
+ module.exports.JAVASCRIPT_MODULE_TYPE_DYNAMIC = JAVASCRIPT_MODULE_TYPE_DYNAMIC;
168
+ module.exports.JAVASCRIPT_MODULE_TYPE_ESM = JAVASCRIPT_MODULE_TYPE_ESM;
159
169
  module.exports.JSON_MODULE_TYPE = JSON_MODULE_TYPE;
160
- module.exports.WEBASSEMBLY_MODULE_TYPE_ASYNC = WEBASSEMBLY_MODULE_TYPE_ASYNC;
161
- module.exports.WEBASSEMBLY_MODULE_TYPE_SYNC = WEBASSEMBLY_MODULE_TYPE_SYNC;
162
170
  module.exports.WEBASSEMBLY_MODULES = [
163
171
  WEBASSEMBLY_MODULE_TYPE_SYNC,
164
172
  WEBASSEMBLY_MODULE_TYPE_SYNC
165
173
  ];
166
- module.exports.CSS_MODULE_TYPE = CSS_MODULE_TYPE;
167
- module.exports.CSS_MODULE_TYPE_GLOBAL = CSS_MODULE_TYPE_GLOBAL;
168
- module.exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE;
169
- module.exports.CSS_MODULE_TYPE_AUTO = CSS_MODULE_TYPE_AUTO;
170
- module.exports.CSS_MODULES = [
171
- CSS_MODULE_TYPE,
172
- CSS_MODULE_TYPE_GLOBAL,
173
- CSS_MODULE_TYPE_MODULE,
174
- CSS_MODULE_TYPE_AUTO
175
- ];
176
- module.exports.WEBPACK_MODULE_TYPE_RUNTIME = WEBPACK_MODULE_TYPE_RUNTIME;
177
- module.exports.WEBPACK_MODULE_TYPE_FALLBACK = WEBPACK_MODULE_TYPE_FALLBACK;
178
- module.exports.WEBPACK_MODULE_TYPE_REMOTE = WEBPACK_MODULE_TYPE_REMOTE;
179
- module.exports.WEBPACK_MODULE_TYPE_PROVIDE = WEBPACK_MODULE_TYPE_PROVIDE;
174
+ module.exports.WEBASSEMBLY_MODULE_TYPE_ASYNC = WEBASSEMBLY_MODULE_TYPE_ASYNC;
175
+ module.exports.WEBASSEMBLY_MODULE_TYPE_SYNC = WEBASSEMBLY_MODULE_TYPE_SYNC;
180
176
  module.exports.WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE =
181
177
  WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE;
178
+ module.exports.WEBPACK_MODULE_TYPE_FALLBACK = WEBPACK_MODULE_TYPE_FALLBACK;
182
179
  module.exports.WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY =
183
180
  WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY;
181
+ module.exports.WEBPACK_MODULE_TYPE_PROVIDE = WEBPACK_MODULE_TYPE_PROVIDE;
182
+ module.exports.WEBPACK_MODULE_TYPE_REMOTE = WEBPACK_MODULE_TYPE_REMOTE;
183
+ module.exports.WEBPACK_MODULE_TYPE_RUNTIME = WEBPACK_MODULE_TYPE_RUNTIME;
@@ -6,7 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const asyncLib = require("neo-async");
9
- const { SyncHook, MultiHook } = require("tapable");
9
+ const { MultiHook, SyncHook } = require("tapable");
10
10
 
11
11
  const ConcurrentCompilationError = require("./ConcurrentCompilationError");
12
12
  const MultiStats = require("./MultiStats");
@@ -305,7 +305,7 @@ module.exports = class MultiCompiler {
305
305
  }
306
306
  if (edges.size > 0) {
307
307
  /** @type {string[]} */
308
- const lines = Array.from(edges)
308
+ const lines = [...edges]
309
309
  .sort(sortEdges)
310
310
  .map(edge => `${edge.source.name} -> ${edge.target.name}`);
311
311
  lines.unshift("Circular dependency found in compiler dependencies.");
@@ -324,7 +324,7 @@ module.exports = class MultiCompiler {
324
324
  * @deprecated This method should have been private
325
325
  * @param {Compiler[]} compilers the child compilers
326
326
  * @param {RunWithDependenciesHandler} fn a handler to run for each compiler
327
- * @param {Callback<MultiStats>} callback the compiler's handler
327
+ * @param {Callback<Stats[]>} callback the compiler's handler
328
328
  * @returns {void}
329
329
  */
330
330
  runWithDependencies(compilers, fn, callback) {
@@ -355,7 +355,7 @@ module.exports = class MultiCompiler {
355
355
  return readyCompilers;
356
356
  };
357
357
  /**
358
- * @param {Callback<MultiStats>} callback callback
358
+ * @param {Callback<Stats[]>} callback callback
359
359
  * @returns {void}
360
360
  */
361
361
  const runCompilers = callback => {
@@ -370,7 +370,7 @@ module.exports = class MultiCompiler {
370
370
  });
371
371
  },
372
372
  (err, results) => {
373
- callback(err, /** @type {TODO} */ (results));
373
+ callback(err, results);
374
374
  }
375
375
  );
376
376
  };
@@ -598,7 +598,7 @@ module.exports = class MultiCompiler {
598
598
  }
599
599
  return watching;
600
600
  },
601
- (compiler, watching, callback) => {
601
+ (compiler, watching, _callback) => {
602
602
  if (compiler.watching !== watching) return;
603
603
  if (!watching.running) watching.invalidate();
604
604
  },
@@ -5,14 +5,14 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const querystring = require("querystring");
8
9
  const parseJson = require("json-parse-even-better-errors");
9
10
  const { getContext, runLoaders } = require("loader-runner");
10
- const querystring = require("querystring");
11
11
  const {
12
+ AsyncSeriesBailHook,
12
13
  HookMap,
13
14
  SyncHook,
14
- SyncWaterfallHook,
15
- AsyncSeriesBailHook
15
+ SyncWaterfallHook
16
16
  } = require("tapable");
17
17
  const {
18
18
  CachedSource,
@@ -38,22 +38,23 @@ const { isSubset } = require("./util/SetHelpers");
38
38
  const { getScheme } = require("./util/URLAbsoluteSpecifier");
39
39
  const {
40
40
  compareLocations,
41
- concatComparators,
42
41
  compareSelect,
42
+ concatComparators,
43
43
  keepOriginalOrder
44
44
  } = require("./util/comparators");
45
45
  const createHash = require("./util/createHash");
46
46
  const { createFakeHook } = require("./util/deprecation");
47
47
  const { join } = require("./util/fs");
48
48
  const {
49
- contextify,
50
49
  absolutify,
50
+ contextify,
51
51
  makePathsRelative
52
52
  } = require("./util/identifier");
53
53
  const makeSerializable = require("./util/makeSerializable");
54
54
  const memoize = require("./util/memoize");
55
55
 
56
56
  /** @typedef {import("webpack-sources").Source} Source */
57
+ /** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
57
58
  /** @typedef {import("../declarations/WebpackOptions").Mode} Mode */
58
59
  /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
59
60
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
@@ -64,6 +65,7 @@ const memoize = require("./util/memoize");
64
65
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
65
66
  /** @typedef {import("./Generator")} Generator */
66
67
  /** @typedef {import("./Generator").GenerateErrorFn} GenerateErrorFn */
68
+ /** @typedef {import("./Generator").GenerateContextData} GenerateContextData */
67
69
  /** @typedef {import("./Module").BuildInfo} BuildInfo */
68
70
  /** @typedef {import("./Module").BuildMeta} BuildMeta */
69
71
  /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
@@ -78,7 +80,7 @@ const memoize = require("./util/memoize");
78
80
  /** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */
79
81
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
80
82
  /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
81
- /** @typedef {import("./ModuleTypeConstants").JavaScriptModuleTypes} JavaScriptModuleTypes */
83
+ /** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */
82
84
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
83
85
  /** @typedef {import("./NormalModuleFactory").ResourceDataWithData} ResourceDataWithData */
84
86
  /** @typedef {import("./NormalModuleFactory").ResourceSchemeData} ResourceSchemeData */
@@ -115,18 +117,6 @@ const memoize = require("./util/memoize");
115
117
  * @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} NormalModuleLoaderContext
116
118
  */
117
119
 
118
- /**
119
- * @typedef {object} SourceMap
120
- * @property {number} version
121
- * @property {string[]} sources
122
- * @property {string} mappings
123
- * @property {string=} file
124
- * @property {string=} sourceRoot
125
- * @property {string[]=} sourcesContent
126
- * @property {string[]=} names
127
- * @property {string=} debugId
128
- */
129
-
130
120
  const getInvalidDependenciesModuleWarning = memoize(() =>
131
121
  require("./InvalidDependenciesModuleWarning")
132
122
  );
@@ -159,12 +149,14 @@ const contextifySourceUrl = (context, source, associatedObjectForCache) => {
159
149
 
160
150
  /**
161
151
  * @param {string} context absolute context path
162
- * @param {SourceMap} sourceMap a source map
152
+ * @param {string | RawSourceMap} sourceMap a source map
163
153
  * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
164
- * @returns {SourceMap} new source map
154
+ * @returns {string | RawSourceMap} new source map
165
155
  */
166
156
  const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
167
- if (!Array.isArray(sourceMap.sources)) return sourceMap;
157
+ if (typeof sourceMap === "string" || !Array.isArray(sourceMap.sources)) {
158
+ return sourceMap;
159
+ }
168
160
  const { sourceRoot } = sourceMap;
169
161
  /** @type {(source: string) => string} */
170
162
  const mapper = !sourceRoot
@@ -195,7 +187,7 @@ const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
195
187
  */
196
188
  const asString = input => {
197
189
  if (Buffer.isBuffer(input)) {
198
- return input.toString("utf-8");
190
+ return input.toString("utf8");
199
191
  }
200
192
  return input;
201
193
  };
@@ -206,7 +198,7 @@ const asString = input => {
206
198
  */
207
199
  const asBuffer = input => {
208
200
  if (!Buffer.isBuffer(input)) {
209
- return Buffer.from(input, "utf-8");
201
+ return Buffer.from(input, "utf8");
210
202
  }
211
203
  return input;
212
204
  };
@@ -229,7 +221,7 @@ makeSerializable(
229
221
  "NonErrorEmittedError"
230
222
  );
231
223
 
232
- /** @typedef {[string | Buffer, string | SourceMapSource, PreparsedAst]} Result */
224
+ /** @typedef {[string | Buffer, string | RawSourceMap | undefined, PreparsedAst | undefined]} Result */
233
225
 
234
226
  /**
235
227
  * @typedef {object} NormalModuleCompilationHooks
@@ -246,7 +238,7 @@ makeSerializable(
246
238
  /**
247
239
  * @typedef {object} NormalModuleCreateData
248
240
  * @property {string=} layer an optional layer in which the module is
249
- * @property {JavaScriptModuleTypes | ""} type module type. When deserializing, this is set to an empty string "".
241
+ * @property {ModuleTypes | ""} type module type. When deserializing, this is set to an empty string "".
250
242
  * @property {string} request request string
251
243
  * @property {string} userRequest request intended by user (without loaders from config)
252
244
  * @property {string} rawRequest request without resolving
@@ -265,8 +257,6 @@ makeSerializable(
265
257
  /** @type {WeakMap<Compilation, NormalModuleCompilationHooks>} */
266
258
  const compilationHooksMap = new WeakMap();
267
259
 
268
- /** @typedef {Map<string, EXPECTED_ANY>} CodeGeneratorData */
269
-
270
260
  class NormalModule extends Module {
271
261
  /**
272
262
  * @param {Compilation} compilation the compilation
@@ -407,7 +397,7 @@ class NormalModule extends Module {
407
397
  this._isEvaluatingSideEffects = false;
408
398
  /** @type {WeakSet<ModuleGraph> | undefined} */
409
399
  this._addedSideEffectsBailout = undefined;
410
- /** @type {CodeGeneratorData} */
400
+ /** @type {GenerateContextData} */
411
401
  this._codeGeneratorData = new Map();
412
402
  }
413
403
 
@@ -543,7 +533,7 @@ class NormalModule extends Module {
543
533
  * @param {string} context the compilation context
544
534
  * @param {string} name the asset name
545
535
  * @param {string | Buffer} content the content
546
- * @param {(string | SourceMap)=} sourceMap an optional source map
536
+ * @param {(string | RawSourceMap)=} sourceMap an optional source map
547
537
  * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
548
538
  * @returns {Source} the created source
549
539
  */
@@ -571,7 +561,8 @@ class NormalModule extends Module {
571
561
  name,
572
562
  contextifySourceMap(
573
563
  context,
574
- /** @type {SourceMap} */ (sourceMap),
564
+ /** @type {RawSourceMap} */
565
+ (sourceMap),
575
566
  associatedObjectForCache
576
567
  )
577
568
  );
@@ -865,7 +856,7 @@ class NormalModule extends Module {
865
856
  /**
866
857
  * @param {string} context the compilation context
867
858
  * @param {string | Buffer} content the content
868
- * @param {(string | SourceMapSource | null)=} sourceMap an optional source map
859
+ * @param {(string | RawSourceMap | null)=} sourceMap an optional source map
869
860
  * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
870
861
  * @returns {Source} the created source
871
862
  */
@@ -886,11 +877,7 @@ class NormalModule extends Module {
886
877
  return new SourceMapSource(
887
878
  content,
888
879
  contextifySourceUrl(context, identifier, associatedObjectForCache),
889
- contextifySourceMap(
890
- context,
891
- /** @type {TODO} */ (sourceMap),
892
- associatedObjectForCache
893
- )
880
+ contextifySourceMap(context, sourceMap, associatedObjectForCache)
894
881
  );
895
882
  }
896
883
 
@@ -924,10 +911,10 @@ class NormalModule extends Module {
924
911
 
925
912
  /**
926
913
  * @param {Error | null} err err
927
- * @param {(Result | null)=} _result result
914
+ * @param {(Result | null)=} result_ result
928
915
  * @returns {void}
929
916
  */
930
- const processResult = (err, _result) => {
917
+ const processResult = (err, result_) => {
931
918
  if (err) {
932
919
  if (!(err instanceof Error)) {
933
920
  err = new NonErrorEmittedError(err);
@@ -943,7 +930,8 @@ class NormalModule extends Module {
943
930
  return callback(error);
944
931
  }
945
932
  const result = hooks.processResult.call(
946
- /** @type {Result} */ (_result),
933
+ /** @type {Result} */
934
+ (result_),
947
935
  this
948
936
  );
949
937
  const source = result[0];
@@ -1263,8 +1251,9 @@ class NormalModule extends Module {
1263
1251
  const checkDependencies = deps => {
1264
1252
  for (const dep of deps) {
1265
1253
  if (!ABSOLUTE_PATH_REGEX.test(dep)) {
1266
- if (nonAbsoluteDependencies === undefined)
1254
+ if (nonAbsoluteDependencies === undefined) {
1267
1255
  nonAbsoluteDependencies = new Set();
1256
+ }
1268
1257
  nonAbsoluteDependencies.add(dep);
1269
1258
  deps.delete(dep);
1270
1259
  try {
@@ -1389,8 +1378,9 @@ class NormalModule extends Module {
1389
1378
  if (this.factoryMeta.sideEffectFree === false) return true;
1390
1379
  }
1391
1380
  if (this.buildMeta !== undefined && this.buildMeta.sideEffectFree) {
1392
- if (this._isEvaluatingSideEffects)
1381
+ if (this._isEvaluatingSideEffects) {
1393
1382
  return ModuleGraphConnection.CIRCULAR_CONNECTION;
1383
+ }
1394
1384
  this._isEvaluatingSideEffects = true;
1395
1385
  /** @type {ConnectionState} */
1396
1386
  let current = false;
@@ -1463,9 +1453,6 @@ class NormalModule extends Module {
1463
1453
  runtimeRequirements.add(RuntimeGlobals.thisAsExports);
1464
1454
  }
1465
1455
 
1466
- /**
1467
- * @type {() => CodeGeneratorData}
1468
- */
1469
1456
  const getData = () => this._codeGeneratorData;
1470
1457
 
1471
1458
  const sources = new Map();
@@ -9,10 +9,10 @@ const { getContext } = require("loader-runner");
9
9
  const asyncLib = require("neo-async");
10
10
  const {
11
11
  AsyncSeriesBailHook,
12
- SyncWaterfallHook,
12
+ HookMap,
13
13
  SyncBailHook,
14
14
  SyncHook,
15
- HookMap
15
+ SyncWaterfallHook
16
16
  } = require("tapable");
17
17
  const ChunkGraph = require("./ChunkGraph");
18
18
  const Module = require("./Module");
@@ -304,7 +304,7 @@ class NormalModuleFactory extends ModuleFactory {
304
304
  generator: new HookMap(
305
305
  () => new SyncHook(["generator", "generatorOptions"])
306
306
  ),
307
- /** @type {HookMap<SyncBailHook<[TODO, ResolveData], Module | void>>} */
307
+ /** @type {HookMap<SyncBailHook<[CreateData, ResolveData], Module | void>>} */
308
308
  createModuleClass: new HookMap(
309
309
  () => new SyncBailHook(["createData", "resolveData"])
310
310
  )
@@ -352,24 +352,26 @@ class NormalModuleFactory extends ModuleFactory {
352
352
  // direct module
353
353
  if (result instanceof Module) return callback(null, result);
354
354
 
355
- if (typeof result === "object")
355
+ if (typeof result === "object") {
356
356
  throw new Error(
357
357
  `${deprecationChangedHookMessage(
358
358
  "resolve",
359
359
  this.hooks.resolve
360
360
  )} Returning a Module object will result in this module used as result.`
361
361
  );
362
+ }
362
363
 
363
364
  this.hooks.afterResolve.callAsync(resolveData, (err, result) => {
364
365
  if (err) return callback(err);
365
366
 
366
- if (typeof result === "object")
367
+ if (typeof result === "object") {
367
368
  throw new Error(
368
369
  deprecationChangedHookMessage(
369
370
  "afterResolve",
370
371
  this.hooks.afterResolve
371
372
  )
372
373
  );
374
+ }
373
375
 
374
376
  // Ignored
375
377
  if (result === false) return callback();
@@ -570,8 +572,11 @@ class NormalModuleFactory extends ModuleFactory {
570
572
 
571
573
  /** @type {ModuleSettings} */
572
574
  const settings = {};
575
+ /** @type {LoaderItem[]} */
573
576
  const useLoadersPost = [];
577
+ /** @type {LoaderItem[]} */
574
578
  const useLoaders = [];
579
+ /** @type {LoaderItem[]} */
575
580
  const useLoadersPre = [];
576
581
 
577
582
  // handle .webpack[] suffix
@@ -630,17 +635,16 @@ class NormalModuleFactory extends ModuleFactory {
630
635
  typeof r.value === "object" &&
631
636
  r.value !== null &&
632
637
  typeof settings[
633
- /** @type {keyof ModuleSettings} */ (r.type)
638
+ /** @type {keyof ModuleSettings} */
639
+ (r.type)
634
640
  ] === "object" &&
635
641
  settings[/** @type {keyof ModuleSettings} */ (r.type)] !== null
636
642
  ) {
637
643
  const type = /** @type {keyof ModuleSettings} */ (r.type);
638
- /** @type {TODO} */
639
- (settings)[type] = cachedCleverMerge(settings[type], r.value);
644
+ settings[type] = cachedCleverMerge(settings[type], r.value);
640
645
  } else {
641
646
  const type = /** @type {keyof ModuleSettings} */ (r.type);
642
- /** @type {TODO} */
643
- (settings)[type] = r.value;
647
+ settings[type] = r.value;
644
648
  }
645
649
  }
646
650
  }
@@ -658,18 +662,27 @@ class NormalModuleFactory extends ModuleFactory {
658
662
  }
659
663
  const allLoaders = /** @type {LoaderItem[]} */ (postLoaders);
660
664
  if (matchResourceData === undefined) {
661
- for (const loader of /** @type {LoaderItem[]} */ (loaders))
665
+ for (const loader of /** @type {LoaderItem[]} */ (loaders)) {
662
666
  allLoaders.push(loader);
663
- for (const loader of /** @type {LoaderItem[]} */ (normalLoaders))
667
+ }
668
+ for (const loader of /** @type {LoaderItem[]} */ (
669
+ normalLoaders
670
+ )) {
664
671
  allLoaders.push(loader);
672
+ }
665
673
  } else {
666
- for (const loader of /** @type {LoaderItem[]} */ (normalLoaders))
674
+ for (const loader of /** @type {LoaderItem[]} */ (
675
+ normalLoaders
676
+ )) {
667
677
  allLoaders.push(loader);
668
- for (const loader of /** @type {LoaderItem[]} */ (loaders))
678
+ }
679
+ for (const loader of /** @type {LoaderItem[]} */ (loaders)) {
669
680
  allLoaders.push(loader);
681
+ }
670
682
  }
671
- for (const loader of /** @type {LoaderItem[]} */ (preLoaders))
683
+ for (const loader of /** @type {LoaderItem[]} */ (preLoaders)) {
672
684
  allLoaders.push(loader);
685
+ }
673
686
  const type = /** @type {string} */ (settings.type);
674
687
  const resolveOptions = settings.resolve;
675
688
  const layer = settings.layer;
@@ -848,7 +861,9 @@ class NormalModuleFactory extends ModuleFactory {
848
861
  }
849
862
 
850
863
  // resource without scheme and without path
851
- else defaultResolve(context);
864
+ else {
865
+ defaultResolve(context);
866
+ }
852
867
  }
853
868
  );
854
869
  }
@@ -920,13 +935,14 @@ class NormalModuleFactory extends ModuleFactory {
920
935
  return callback(null, factoryResult);
921
936
  }
922
937
 
923
- if (typeof result === "object")
938
+ if (typeof result === "object") {
924
939
  throw new Error(
925
940
  deprecationChangedHookMessage(
926
941
  "beforeResolve",
927
942
  this.hooks.beforeResolve
928
943
  )
929
944
  );
945
+ }
930
946
 
931
947
  this.hooks.factorize.callAsync(resolveData, (err, module) => {
932
948
  if (err) {
@@ -999,9 +1015,7 @@ ${hints.join("\n\n")}`;
999
1015
 
1000
1016
  // Check if the extension is missing a leading dot (e.g. "js" instead of ".js")
1001
1017
  let appendResolveExtensionsHint = false;
1002
- const specifiedExtensions = Array.from(
1003
- resolver.options.extensions
1004
- );
1018
+ const specifiedExtensions = [...resolver.options.extensions];
1005
1019
  const expectedExtensions = specifiedExtensions.map(extension => {
1006
1020
  if (LEADING_DOT_EXTENSION_REGEX.test(extension)) {
1007
1021
  appendResolveExtensionsHint = true;
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const { join, dirname } = require("./util/fs");
8
+ const { dirname, join } = require("./util/fs");
9
9
 
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
11
  /** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
@@ -20,4 +20,5 @@ class NullFactory extends ModuleFactory {
20
20
  return callback();
21
21
  }
22
22
  }
23
+
23
24
  module.exports = NullFactory;