webpack 5.104.1 → 5.105.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 (323) hide show
  1. package/README.md +2 -2
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +85 -15
  4. package/lib/AbstractMethodError.js +1 -0
  5. package/lib/AsyncDependenciesBlock.js +17 -2
  6. package/lib/AsyncDependencyToInitialChunkError.js +3 -0
  7. package/lib/AutomaticPrefetchPlugin.js +1 -1
  8. package/lib/BannerPlugin.js +5 -1
  9. package/lib/CacheFacade.js +2 -2
  10. package/lib/CaseSensitiveModulesWarning.js +1 -0
  11. package/lib/Chunk.js +9 -5
  12. package/lib/ChunkGraph.js +30 -9
  13. package/lib/ChunkGroup.js +6 -3
  14. package/lib/ChunkRenderError.js +9 -2
  15. package/lib/CleanPlugin.js +4 -1
  16. package/lib/CodeGenerationError.js +7 -1
  17. package/lib/CodeGenerationResults.js +10 -3
  18. package/lib/CommentCompilationWarning.js +2 -1
  19. package/lib/Compilation.js +284 -236
  20. package/lib/Compiler.js +4 -3
  21. package/lib/ConcatenationScope.js +2 -1
  22. package/lib/ConcurrentCompilationError.js +3 -3
  23. package/lib/ContextModule.js +248 -111
  24. package/lib/ContextModuleFactory.js +14 -2
  25. package/lib/DefinePlugin.js +15 -8
  26. package/lib/DelegatedModule.js +6 -0
  27. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  28. package/lib/Dependency.js +6 -1
  29. package/lib/DependencyTemplates.js +3 -2
  30. package/lib/DllModule.js +2 -0
  31. package/lib/DllReferencePlugin.js +1 -0
  32. package/lib/DotenvPlugin.js +11 -5
  33. package/lib/DynamicEntryPlugin.js +8 -1
  34. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  35. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  36. package/lib/ExportsInfo.js +8 -4
  37. package/lib/ExternalModule.js +16 -0
  38. package/lib/ExternalModuleFactoryPlugin.js +9 -2
  39. package/lib/ExternalsPlugin.js +2 -1
  40. package/lib/FalseIIFEUmdWarning.js +1 -0
  41. package/lib/FileSystemInfo.js +49 -25
  42. package/lib/FlagDependencyExportsPlugin.js +8 -1
  43. package/lib/FlagDependencyUsagePlugin.js +9 -7
  44. package/lib/HarmonyLinkingError.js +1 -0
  45. package/lib/HookWebpackError.js +2 -0
  46. package/lib/HotModuleReplacementPlugin.js +16 -2
  47. package/lib/IgnoreWarningsPlugin.js +5 -2
  48. package/lib/InitFragment.js +1 -0
  49. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  50. package/lib/LibManifestPlugin.js +1 -0
  51. package/lib/ManifestPlugin.js +8 -1
  52. package/lib/Module.js +7 -4
  53. package/lib/ModuleBuildError.js +3 -1
  54. package/lib/ModuleDependencyError.js +1 -0
  55. package/lib/ModuleDependencyWarning.js +1 -0
  56. package/lib/ModuleError.js +4 -1
  57. package/lib/ModuleFilenameHelpers.js +4 -2
  58. package/lib/ModuleGraph.js +3 -0
  59. package/lib/ModuleGraphConnection.js +10 -1
  60. package/lib/ModuleHashingError.js +2 -0
  61. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  62. package/lib/ModuleNotFoundError.js +1 -0
  63. package/lib/ModuleParseError.js +5 -1
  64. package/lib/ModuleProfile.js +1 -1
  65. package/lib/ModuleRestoreError.js +2 -0
  66. package/lib/ModuleSourceTypeConstants.js +1 -11
  67. package/lib/ModuleStoreError.js +2 -0
  68. package/lib/ModuleWarning.js +3 -1
  69. package/lib/MultiCompiler.js +11 -7
  70. package/lib/MultiWatching.js +2 -2
  71. package/lib/NoModeWarning.js +1 -0
  72. package/lib/NodeStuffInWebError.js +1 -0
  73. package/lib/NormalModule.js +28 -5
  74. package/lib/NormalModuleFactory.js +20 -4
  75. package/lib/OptionsApply.js +3 -1
  76. package/lib/ProgressPlugin.js +4 -0
  77. package/lib/RawModule.js +2 -0
  78. package/lib/RuntimeModule.js +10 -0
  79. package/lib/RuntimePlugin.js +7 -9
  80. package/lib/RuntimeTemplate.js +14 -7
  81. package/lib/SourceMapDevToolPlugin.js +30 -23
  82. package/lib/Template.js +10 -5
  83. package/lib/TemplatedPathPlugin.js +4 -2
  84. package/lib/UnhandledSchemeError.js +1 -0
  85. package/lib/UnsupportedFeatureWarning.js +3 -0
  86. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  87. package/lib/WatchIgnorePlugin.js +1 -1
  88. package/lib/Watching.js +5 -0
  89. package/lib/WebpackError.js +4 -0
  90. package/lib/WebpackOptionsApply.js +61 -41
  91. package/lib/asset/AssetBytesGenerator.js +1 -0
  92. package/lib/asset/AssetGenerator.js +18 -3
  93. package/lib/asset/AssetModulesPlugin.js +33 -2
  94. package/lib/asset/AssetParser.js +4 -0
  95. package/lib/asset/AssetSourceGenerator.js +1 -0
  96. package/lib/asset/RawDataUrlModule.js +4 -0
  97. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  98. package/lib/buildChunkGraph.js +31 -2
  99. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  100. package/lib/cache/PackFileCacheStrategy.js +41 -8
  101. package/lib/cache/getLazyHashedEtag.js +13 -4
  102. package/lib/cache/mergeEtags.js +3 -1
  103. package/lib/cli.js +3 -1
  104. package/lib/config/defaults.js +65 -44
  105. package/lib/config/normalization.js +96 -0
  106. package/lib/container/ContainerEntryDependency.js +3 -0
  107. package/lib/container/ContainerEntryModule.js +7 -0
  108. package/lib/container/ContainerExposedDependency.js +1 -0
  109. package/lib/container/FallbackDependency.js +1 -0
  110. package/lib/container/FallbackItemDependency.js +1 -0
  111. package/lib/container/FallbackModule.js +4 -0
  112. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  113. package/lib/container/ModuleFederationPlugin.js +1 -1
  114. package/lib/container/RemoteModule.js +24 -0
  115. package/lib/css/CssGenerator.js +31 -4
  116. package/lib/css/CssModulesPlugin.js +26 -30
  117. package/lib/css/CssParser.js +12 -9
  118. package/lib/debug/ProfilingPlugin.js +1 -0
  119. package/lib/dependencies/AMDDefineDependency.js +3 -1
  120. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  121. package/lib/dependencies/AMDPlugin.js +1 -1
  122. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  123. package/lib/dependencies/CachedConstDependency.js +1 -0
  124. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  125. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  126. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  127. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  128. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  129. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  130. package/lib/dependencies/ConstDependency.js +1 -0
  131. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  132. package/lib/dependencies/ContextElementDependency.js +1 -0
  133. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  134. package/lib/dependencies/CssIcssExportDependency.js +7 -4
  135. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  136. package/lib/dependencies/CssUrlDependency.js +2 -3
  137. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  138. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  139. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  140. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -1
  141. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  142. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  143. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  144. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  145. package/lib/dependencies/HarmonyImportDependency.js +1 -1
  146. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +269 -5
  147. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  148. package/lib/dependencies/ImportDependency.js +1 -0
  149. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  150. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  151. package/lib/dependencies/ImportParserPlugin.js +7 -12
  152. package/lib/dependencies/LoaderPlugin.js +3 -0
  153. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  154. package/lib/dependencies/ModuleDependency.js +1 -0
  155. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  156. package/lib/dependencies/ProvidedDependency.js +1 -0
  157. package/lib/dependencies/RequireContextPlugin.js +1 -0
  158. package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
  159. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  160. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  161. package/lib/dependencies/WorkerDependency.js +9 -3
  162. package/lib/dependencies/WorkerPlugin.js +1 -0
  163. package/lib/dependencies/getFunctionExpression.js +3 -1
  164. package/lib/electron/ElectronTargetPlugin.js +3 -1
  165. package/lib/errors/BuildCycleError.js +4 -1
  166. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  167. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  168. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  169. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  170. package/lib/hmr/lazyCompilationBackend.js +3 -2
  171. package/lib/ids/ChunkModuleIdRangePlugin.js +9 -7
  172. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
  173. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
  174. package/lib/ids/HashedModuleIdsPlugin.js +3 -8
  175. package/lib/ids/IdHelpers.js +10 -8
  176. package/lib/ids/NamedChunkIdsPlugin.js +7 -5
  177. package/lib/ids/NamedModuleIdsPlugin.js +1 -0
  178. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  179. package/lib/ids/OccurrenceModuleIdsPlugin.js +18 -10
  180. package/lib/ids/SyncModuleIdsPlugin.js +30 -20
  181. package/lib/index.js +2 -2
  182. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  183. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  184. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  185. package/lib/javascript/JavascriptParser.js +47 -14
  186. package/lib/json/JsonGenerator.js +1 -0
  187. package/lib/json/JsonParser.js +9 -2
  188. package/lib/library/AbstractLibraryPlugin.js +4 -1
  189. package/lib/library/AmdLibraryPlugin.js +2 -1
  190. package/lib/library/AssignLibraryPlugin.js +6 -2
  191. package/lib/library/EnableLibraryPlugin.js +1 -0
  192. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  193. package/lib/library/JsonpLibraryPlugin.js +1 -1
  194. package/lib/library/ModuleLibraryPlugin.js +130 -13
  195. package/lib/library/SystemLibraryPlugin.js +4 -1
  196. package/lib/library/UmdLibraryPlugin.js +4 -3
  197. package/lib/logging/Logger.js +9 -5
  198. package/lib/logging/createConsoleLogger.js +4 -0
  199. package/lib/logging/truncateArgs.js +1 -1
  200. package/lib/node/CommonJsChunkLoadingPlugin.js +6 -4
  201. package/lib/node/NodeEnvironmentPlugin.js +1 -0
  202. package/lib/node/NodeTargetPlugin.js +10 -1
  203. package/lib/node/NodeTemplatePlugin.js +1 -0
  204. package/lib/node/NodeWatchFileSystem.js +6 -0
  205. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
  206. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  207. package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
  208. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
  209. package/lib/node/nodeConsole.js +18 -1
  210. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  211. package/lib/optimize/AggressiveSplittingPlugin.js +15 -6
  212. package/lib/optimize/ConcatenatedModule.js +33 -19
  213. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  214. package/lib/optimize/InnerGraph.js +5 -3
  215. package/lib/optimize/InnerGraphPlugin.js +25 -25
  216. package/lib/optimize/LimitChunkCountPlugin.js +3 -2
  217. package/lib/optimize/MangleExportsPlugin.js +14 -2
  218. package/lib/optimize/MergeDuplicateChunksPlugin.js +5 -1
  219. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  220. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  221. package/lib/optimize/RealContentHashPlugin.js +37 -27
  222. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  223. package/lib/optimize/RuntimeChunkPlugin.js +3 -5
  224. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  225. package/lib/optimize/SplitChunksPlugin.js +23 -5
  226. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  227. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  228. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  229. package/lib/performance/SizeLimitsPlugin.js +6 -6
  230. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
  231. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
  232. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
  233. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
  234. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  235. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  236. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  237. package/lib/rules/RuleSetCompiler.js +6 -0
  238. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  239. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  240. package/lib/runtime/CompatRuntimeModule.js +1 -0
  241. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  242. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -0
  243. package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
  244. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  245. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  246. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  247. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +16 -32
  248. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  249. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  250. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  251. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  252. package/lib/schemes/HttpUriPlugin.js +39 -20
  253. package/lib/schemes/VirtualUrlPlugin.js +28 -2
  254. package/lib/serialization/BinaryMiddleware.js +4 -0
  255. package/lib/serialization/FileMiddleware.js +9 -4
  256. package/lib/serialization/ObjectMiddleware.js +34 -11
  257. package/lib/serialization/PlainObjectSerializer.js +2 -0
  258. package/lib/sharing/ConsumeSharedModule.js +60 -0
  259. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  260. package/lib/sharing/ProvideSharedModule.js +4 -0
  261. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  262. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  263. package/lib/sharing/utils.js +8 -6
  264. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -12
  265. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  266. package/lib/stats/StatsFactory.js +2 -2
  267. package/lib/url/URLParserPlugin.js +5 -3
  268. package/lib/util/AppendOnlyStackedSet.js +57 -0
  269. package/lib/util/Hash.js +1 -0
  270. package/lib/util/IterableHelpers.js +1 -0
  271. package/lib/util/LazyBucketSortedSet.js +1 -0
  272. package/lib/util/LazySet.js +1 -0
  273. package/lib/util/ParallelismFactorCalculator.js +1 -0
  274. package/lib/util/SortableSet.js +1 -0
  275. package/lib/util/StringXor.js +1 -0
  276. package/lib/util/binarySearchBounds.js +15 -8
  277. package/lib/util/chainedImports.js +1 -1
  278. package/lib/util/cleverMerge.js +6 -1
  279. package/lib/util/comparators.js +21 -1
  280. package/lib/util/compileBooleanMatcher.js +3 -3
  281. package/lib/util/concatenate.js +3 -2
  282. package/lib/util/conventions.js +3 -2
  283. package/lib/util/deterministicGrouping.js +13 -1
  284. package/lib/util/extractSourceMap.js +12 -13
  285. package/lib/util/fs.js +15 -19
  286. package/lib/util/hash/BatchedHash.js +4 -0
  287. package/lib/util/hash/BulkUpdateHash.js +8 -1
  288. package/lib/util/hash/hash-digest.js +1 -0
  289. package/lib/util/hash/wasm-hash.js +18 -2
  290. package/lib/util/identifier.js +7 -2
  291. package/lib/util/magicComment.js +1 -1
  292. package/lib/util/propertyName.js +1 -1
  293. package/lib/util/registerExternalSerializer.js +1 -0
  294. package/lib/util/runtime.js +15 -1
  295. package/lib/util/semver.js +1 -0
  296. package/lib/util/serialization.js +2 -2
  297. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -0
  298. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  299. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  300. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  301. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  302. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  303. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  304. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  305. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  306. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  307. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  308. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  309. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  310. package/lib/webpack.js +16 -4
  311. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  312. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
  313. package/package.json +33 -36
  314. package/schemas/WebpackOptions.check.js +1 -1
  315. package/schemas/WebpackOptions.json +121 -55
  316. package/schemas/plugins/BannerPlugin.json +2 -2
  317. package/schemas/plugins/IgnorePlugin.json +1 -1
  318. package/schemas/plugins/ManifestPlugin.json +3 -3
  319. package/schemas/plugins/ProgressPlugin.json +1 -1
  320. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  321. package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
  322. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  323. package/types.d.ts +440 -137
@@ -111,6 +111,8 @@ const TREE_DEPENDENCIES = {
111
111
  [RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty]
112
112
  };
113
113
 
114
+ const FULLHASH_REGEXP = /\[(?:full)?hash(?::\d+)?\]/;
115
+
114
116
  const PLUGIN_NAME = "RuntimePlugin";
115
117
 
116
118
  class RuntimePlugin {
@@ -266,7 +268,7 @@ class RuntimePlugin {
266
268
 
267
269
  if (
268
270
  typeof publicPath !== "string" ||
269
- /\[(full)?hash\]/.test(publicPath)
271
+ /\[(?:full)?hash\]/.test(publicPath)
270
272
  ) {
271
273
  module.fullHash = true;
272
274
  }
@@ -314,9 +316,7 @@ class RuntimePlugin {
314
316
  .tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
315
317
  if (
316
318
  typeof compilation.outputOptions.chunkFilename === "string" &&
317
- /\[(full)?hash(:\d+)?\]/.test(
318
- compilation.outputOptions.chunkFilename
319
- )
319
+ FULLHASH_REGEXP.test(compilation.outputOptions.chunkFilename)
320
320
  ) {
321
321
  set.add(RuntimeGlobals.getFullHash);
322
322
  }
@@ -342,9 +342,7 @@ class RuntimePlugin {
342
342
  .tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
343
343
  if (
344
344
  typeof compilation.outputOptions.cssChunkFilename === "string" &&
345
- /\[(full)?hash(:\d+)?\]/.test(
346
- compilation.outputOptions.cssChunkFilename
347
- )
345
+ FULLHASH_REGEXP.test(compilation.outputOptions.cssChunkFilename)
348
346
  ) {
349
347
  set.add(RuntimeGlobals.getFullHash);
350
348
  }
@@ -374,7 +372,7 @@ class RuntimePlugin {
374
372
  .for(RuntimeGlobals.getChunkUpdateScriptFilename)
375
373
  .tap(PLUGIN_NAME, (chunk, set) => {
376
374
  if (
377
- /\[(full)?hash(:\d+)?\]/.test(
375
+ FULLHASH_REGEXP.test(
378
376
  compilation.outputOptions.hotUpdateChunkFilename
379
377
  )
380
378
  ) {
@@ -396,7 +394,7 @@ class RuntimePlugin {
396
394
  .for(RuntimeGlobals.getUpdateManifestFilename)
397
395
  .tap(PLUGIN_NAME, (chunk, set) => {
398
396
  if (
399
- /\[(full)?hash(:\d+)?\]/.test(
397
+ FULLHASH_REGEXP.test(
400
398
  compilation.outputOptions.hotUpdateMainFilename
401
399
  )
402
400
  ) {
@@ -84,7 +84,7 @@ function getGlobalObject(definition) {
84
84
  // iife
85
85
  // call expression
86
86
  // expression in parentheses
87
- /^([_\p{L}][_0-9\p{L}]*)?\(.*\)$/iu.test(trimmed)
87
+ /^(?:[_\p{L}][_0-9\p{L}]*)?\(.*\)$/iu.test(trimmed)
88
88
  ) {
89
89
  return trimmed;
90
90
  }
@@ -356,6 +356,7 @@ class RuntimeTemplate {
356
356
  * @returns {string} comment
357
357
  */
358
358
  comment({ request, chunkName, chunkReason, message, exportName }) {
359
+ /** @type {string} */
359
360
  let content;
360
361
  if (this.outputOptions.pathinfo) {
361
362
  content = [message, request, chunkName, chunkReason]
@@ -678,6 +679,7 @@ class RuntimeTemplate {
678
679
  runtimeRequirements
679
680
  });
680
681
 
682
+ /** @type {string} */
681
683
  let appending;
682
684
  let idExpr = JSON.stringify(chunkGraph.getModuleId(module));
683
685
  const comment = this.comment({
@@ -711,7 +713,10 @@ class RuntimeTemplate {
711
713
 
712
714
  if (isModuleDeferred) {
713
715
  runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
714
- const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType);
716
+
717
+ let mode = getMakeDeferredNamespaceModeFromExportsType(exportsType);
718
+ if (mode) mode = `${mode} | 16`;
719
+
715
720
  const asyncDeps = Array.from(
716
721
  getOutgoingAsyncModules(chunkGraph.moduleGraph, module),
717
722
  (m) => chunkGraph.getModuleId(m)
@@ -852,14 +857,14 @@ class RuntimeTemplate {
852
857
  * @param {object} options options object
853
858
  * @param {boolean=} options.update whether a new variable should be created or the existing one updated
854
859
  * @param {Module} options.module the module
860
+ * @param {Module} options.originModule module in which the statement is emitted
855
861
  * @param {ModuleGraph} options.moduleGraph the module graph
856
862
  * @param {ChunkGraph} options.chunkGraph the chunk graph
857
- * @param {string} options.request the request that should be printed as comment
863
+ * @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
858
864
  * @param {string} options.importVar name of the import variable
859
- * @param {Module} options.originModule module in which the statement is emitted
865
+ * @param {string=} options.request the request that should be printed as comment
860
866
  * @param {boolean=} options.weak true, if this is a weak dependency
861
- * @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
862
- * @param {ModuleDependency} options.dependency module dependency
867
+ * @param {ModuleDependency=} options.dependency module dependency
863
868
  * @returns {[string, string]} the import statement and the compat statement
864
869
  */
865
870
  importStatement({
@@ -918,6 +923,8 @@ class RuntimeTemplate {
918
923
  (originModule.buildMeta).strictHarmonyModule
919
924
  );
920
925
  runtimeRequirements.add(RuntimeGlobals.require);
926
+
927
+ /** @type {string} */
921
928
  let importContent;
922
929
 
923
930
  const isModuleDeferred =
@@ -961,7 +968,7 @@ class RuntimeTemplate {
961
968
  * @param {string | string[]} options.exportName the export name
962
969
  * @param {Module} options.originModule the origin module
963
970
  * @param {boolean | undefined} options.asiSafe true, if location is safe for ASI, a bracket can be emitted
964
- * @param {boolean} options.isCall true, if expression will be called
971
+ * @param {boolean | undefined} options.isCall true, if expression will be called
965
972
  * @param {boolean | null} options.callContext when false, call context will not be preserved
966
973
  * @param {boolean} options.defaultInterop when true and accessing the default exports, interop code will be generated
967
974
  * @param {string} options.importVar the identifier name of the import variable
@@ -51,9 +51,9 @@ const validate = createSchemaValidation(
51
51
  */
52
52
 
53
53
  const METACHARACTERS_REGEXP = /[-[\]\\/{}()*+?.^$|]/g;
54
- const CONTENT_HASH_DETECT_REGEXP = /\[contenthash(:\w+)?\]/;
54
+ const CONTENT_HASH_DETECT_REGEXP = /\[contenthash(?::\w+)?\]/;
55
55
  const CSS_AND_JS_MODULE_EXTENSIONS_REGEXP = /\.((c|m)?js|css)($|\?)/i;
56
- const CSS_EXTENSION_DETECT_REGEXP = /\.css($|\?)/i;
56
+ const CSS_EXTENSION_DETECT_REGEXP = /\.css(?:$|\?)/i;
57
57
  const MAP_URL_COMMENT_REGEXP = /\[map\]/g;
58
58
  const URL_COMMENT_REGEXP = /\[url\]/g;
59
59
  const URL_FORMATTING_REGEXP = /^\n\/\/(.*)$/;
@@ -93,18 +93,19 @@ const getTaskForFile = (
93
93
  compilation,
94
94
  cacheItem
95
95
  ) => {
96
+ /** @type {string | Buffer} */
96
97
  let source;
97
- /** @type {RawSourceMap} */
98
+ /** @type {null | RawSourceMap} */
98
99
  let sourceMap;
99
100
  /**
100
101
  * Check if asset can build source map
101
102
  */
102
103
  if (asset.sourceAndMap) {
103
104
  const sourceAndMap = asset.sourceAndMap(options);
104
- sourceMap = /** @type {RawSourceMap} */ (sourceAndMap.map);
105
+ sourceMap = sourceAndMap.map;
105
106
  source = sourceAndMap.source;
106
107
  } else {
107
- sourceMap = /** @type {RawSourceMap} */ (asset.map(options));
108
+ sourceMap = asset.map(options);
108
109
  source = asset.source();
109
110
  }
110
111
  if (!sourceMap || typeof source !== "string") return;
@@ -173,6 +174,7 @@ class SourceMapDevToolPlugin {
173
174
  const options = this.options;
174
175
  options.test = options.test || CSS_AND_JS_MODULE_EXTENSIONS_REGEXP;
175
176
 
177
+ /** @type {(filename: string) => boolean} */
176
178
  const matchObject = ModuleFilenameHelpers.matchObject.bind(
177
179
  undefined,
178
180
  options
@@ -310,7 +312,7 @@ class SourceMapDevToolPlugin {
310
312
 
311
313
  if (
312
314
  typeof module === "string" &&
313
- /^(data|https?):/.test(module)
315
+ /^(?:data|https?):/.test(module)
314
316
  ) {
315
317
  moduleToSourceNameMapping.set(module, module);
316
318
  continue;
@@ -416,7 +418,9 @@ class SourceMapDevToolPlugin {
416
418
  asyncLib.each(
417
419
  tasks,
418
420
  (task, callback) => {
421
+ /** @type {Record<string, Source>} */
419
422
  const assets = Object.create(null);
423
+ /** @type {Record<string, AssetInfo | undefined>} */
420
424
  const assetsInfo = Object.create(null);
421
425
  const file = task.file;
422
426
  const chunk = fileToChunk.get(file);
@@ -434,24 +438,27 @@ class SourceMapDevToolPlugin {
434
438
  moduleToSourceNameMapping.get(m)
435
439
  );
436
440
  sourceMap.sources = /** @type {string[]} */ (moduleFilenames);
437
- sourceMap.ignoreList = options.ignoreList
438
- ? sourceMap.sources.reduce(
439
- /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
440
- (acc, sourceName, idx) => {
441
- const rule = /** @type {Rules} */ (
442
- options.ignoreList
443
- );
444
- if (
445
- ModuleFilenameHelpers.matchPart(sourceName, rule)
446
- ) {
447
- acc.push(idx);
448
- }
449
- return acc;
441
+ if (options.ignoreList) {
442
+ const ignoreList = sourceMap.sources.reduce(
443
+ /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
444
+ (acc, sourceName, idx) => {
445
+ const rule = /** @type {Rules} */ (
446
+ options.ignoreList
447
+ );
448
+ if (
449
+ ModuleFilenameHelpers.matchPart(sourceName, rule)
450
+ ) {
451
+ acc.push(idx);
450
452
  }
451
- ),
452
- []
453
- )
454
- : [];
453
+ return acc;
454
+ }
455
+ ),
456
+ []
457
+ );
458
+ if (ignoreList.length > 0) {
459
+ sourceMap.ignoreList = ignoreList;
460
+ }
461
+ }
455
462
 
456
463
  if (options.noSources) {
457
464
  sourceMap.sourcesContent = undefined;
package/lib/Template.js CHANGED
@@ -36,10 +36,10 @@ const NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS =
36
36
  const FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g;
37
37
  const INDENT_MULTILINE_REGEX = /^\t/gm;
38
38
  const LINE_SEPARATOR_REGEX = /\r?\n/g;
39
- const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/;
40
- const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g;
39
+ const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-z$_])/i;
40
+ const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-z0-9$]+/gi;
41
41
  const COMMENT_END_REGEX = /\*\//g;
42
- const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
42
+ const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-z0-9_!§$()=\-^°]+/gi;
43
43
  const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
44
44
 
45
45
  /**
@@ -83,10 +83,14 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
83
83
  * @typedef {(module: Module) => boolean} ModuleFilterPredicate
84
84
  */
85
85
 
86
+ /**
87
+ * @typedef {object} Stringable
88
+ * @property {() => string} toString
89
+ */
90
+
86
91
  class Template {
87
92
  /**
88
- * @template {EXPECTED_FUNCTION} T
89
- * @param {T} fn a runtime function (.runtime.js) "template"
93
+ * @param {Stringable} fn a runtime function (.runtime.js) "template"
90
94
  * @returns {string} the updated and normalized function string
91
95
  */
92
96
  static getFunctionContent(fn) {
@@ -359,6 +363,7 @@ class Template {
359
363
  const source = new ConcatSource();
360
364
  for (const module of runtimeModules) {
361
365
  const codeGenerationResults = renderContext.codeGenerationResults;
366
+ /** @type {undefined | Source} */
362
367
  let runtimeSource;
363
368
  if (codeGenerationResults) {
364
369
  runtimeSource = codeGenerationResults.getSource(
@@ -18,7 +18,7 @@ const { parseResource } = require("./util/identifier");
18
18
  /** @typedef {import("./Compilation").PathData} PathData */
19
19
  /** @typedef {import("./Compiler")} Compiler */
20
20
 
21
- const REGEXP = /\[\\*([\w:]+)\\*\]/gi;
21
+ const REGEXP = /\[\\*([\w:]+)\\*\]/g;
22
22
 
23
23
  /** @type {PathData["prepareId"]} */
24
24
  const prepareId = (id) => {
@@ -32,7 +32,7 @@ const prepareId = (id) => {
32
32
  } + "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_") + "`;
33
33
  }
34
34
 
35
- return id.replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_");
35
+ return id.replace(/(^[.-]|[^a-z0-9_-])+/gi, "_");
36
36
  };
37
37
 
38
38
  /**
@@ -52,6 +52,7 @@ const prepareId = (id) => {
52
52
  const hashLength = (replacer, handler, assetInfo, hashName) => {
53
53
  /** @type {Replacer} */
54
54
  const fn = (match, arg, input) => {
55
+ /** @type {string} */
55
56
  let result;
56
57
  const length = arg && Number.parseInt(arg, 10);
57
58
 
@@ -107,6 +108,7 @@ const replacer = (value, allowEmpty) => {
107
108
  return fn;
108
109
  };
109
110
 
111
+ /** @type {Map<string, (...args: EXPECTED_ANY[]) => EXPECTED_ANY>} */
110
112
  const deprecationCache = new Map();
111
113
  const deprecatedFunction = (() => () => {})();
112
114
  /**
@@ -20,6 +20,7 @@ class UnhandledSchemeError extends WebpackError {
20
20
  `\nYou may need an additional plugin to handle "${scheme}:" URIs.`
21
21
  );
22
22
  this.file = resource;
23
+ /** @type {string} */
23
24
  this.name = "UnhandledSchemeError";
24
25
  }
25
26
  }
@@ -18,8 +18,11 @@ class UnsupportedFeatureWarning extends WebpackError {
18
18
  constructor(message, loc) {
19
19
  super(message);
20
20
 
21
+ /** @type {string} */
21
22
  this.name = "UnsupportedFeatureWarning";
23
+ /** @type {DependencyLocation} */
22
24
  this.loc = loc;
25
+ /** @type {boolean} */
23
26
  this.hideStack = true;
24
27
  }
25
28
  }
@@ -48,6 +48,7 @@ class DeprecatedOptionWarning extends WebpackError {
48
48
  constructor(option, value, suggestion) {
49
49
  super();
50
50
 
51
+ /** @type {string} */
51
52
  this.name = "DeprecatedOptionWarning";
52
53
  this.message =
53
54
  "configuration\n" +
@@ -8,9 +8,9 @@
8
8
  const { groupBy } = require("./util/ArrayHelpers");
9
9
  const createSchemaValidation = require("./util/create-schema-validation");
10
10
 
11
+ /** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */
11
12
  /** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */
12
13
  /** @typedef {import("./Compiler")} Compiler */
13
- /** @typedef {import("./util/fs").TimeInfoEntries} TimeInfoEntries */
14
14
  /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
15
15
  /** @typedef {import("./util/fs").WatchMethod} WatchMethod */
16
16
  /** @typedef {import("./util/fs").Watcher} Watcher */
package/lib/Watching.js CHANGED
@@ -15,6 +15,7 @@ const Stats = require("./Stats");
15
15
  /** @typedef {import("./logging/Logger").Logger} Logger */
16
16
  /** @typedef {import("./util/fs").TimeInfoEntries} TimeInfoEntries */
17
17
  /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
18
+ /** @typedef {import("./util/fs").Watcher} Watcher */
18
19
 
19
20
  /**
20
21
  * @template T
@@ -31,8 +32,10 @@ class Watching {
31
32
  * @param {Callback<Stats>} handler completion handler
32
33
  */
33
34
  constructor(compiler, watchOptions, handler) {
35
+ /** @type {null | number} */
34
36
  this.startTime = null;
35
37
  this.invalid = false;
38
+ /** @type {Callback<Stats>} */
36
39
  this.handler = handler;
37
40
  /** @type {ErrorCallback[]} */
38
41
  this.callbacks = [];
@@ -64,7 +67,9 @@ class Watching {
64
67
  this._initial = true;
65
68
  this._invalidReported = true;
66
69
  this._needRecords = true;
70
+ /** @type {undefined | null | Watcher} */
67
71
  this.watcher = undefined;
72
+ /** @type {undefined | null | Watcher} */
68
73
  this.pausedWatcher = undefined;
69
74
  /** @type {CollectedFiles | undefined} */
70
75
  this._collectedChangedFiles = undefined;
@@ -37,6 +37,9 @@ class WebpackError extends Error {
37
37
  this.file = undefined;
38
38
  }
39
39
 
40
+ /**
41
+ * @returns {string} inspect message
42
+ */
40
43
  [inspect]() {
41
44
  return (
42
45
  this.stack +
@@ -74,4 +77,5 @@ class WebpackError extends Error {
74
77
 
75
78
  makeSerializable(WebpackError, "webpack/lib/WebpackError");
76
79
 
80
+ /** @type {typeof WebpackError} */
77
81
  module.exports = WebpackError;
@@ -74,8 +74,9 @@ const DefaultStatsPrinterPlugin = require("./stats/DefaultStatsPrinterPlugin");
74
74
 
75
75
  const { cleverMerge } = require("./util/cleverMerge");
76
76
 
77
- /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
77
+ /** @typedef {import("./webpack").WebpackPluginFunction} WebpackPluginFunction */
78
78
  /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
79
+ /** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */
79
80
  /** @typedef {import("./Compiler")} Compiler */
80
81
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
81
82
  /** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
@@ -90,9 +91,10 @@ class WebpackOptionsApply extends OptionsApply {
90
91
  /**
91
92
  * @param {WebpackOptions} options options object
92
93
  * @param {Compiler} compiler compiler object
94
+ * @param {WebpackOptionsInterception=} interception intercepted options
93
95
  * @returns {WebpackOptions} options object
94
96
  */
95
- process(options, compiler) {
97
+ process(options, compiler, interception) {
96
98
  compiler.outputPath = options.output.path;
97
99
  compiler.recordsInputPath = options.recordsInputPath || null;
98
100
  compiler.recordsOutputPath = options.recordsOutputPath || null;
@@ -113,11 +115,7 @@ class WebpackOptionsApply extends OptionsApply {
113
115
  // Some older versions of Node.js don't support all built-in modules via import, only via `require`,
114
116
  // but it seems like there shouldn't be a warning here since these versions are rarely used in real applications
115
117
  new NodeTargetPlugin(
116
- options.output.module &&
117
- compiler.platform.node === null &&
118
- compiler.platform.web === null
119
- ? "module-import"
120
- : "node-commonjs"
118
+ options.output.module ? "module-import" : "node-commonjs"
121
119
  ).apply(compiler);
122
120
 
123
121
  // Handle external CSS `@import` and `url()`
@@ -129,8 +127,8 @@ class WebpackOptionsApply extends OptionsApply {
129
127
  "module",
130
128
  ({ request, dependencyType, contextInfo }, callback) => {
131
129
  if (
132
- /\.css(\?|$)/.test(contextInfo.issuer) &&
133
- /^(\/\/|https?:\/\/|#)/.test(request)
130
+ /\.css(?:\?|$)/.test(contextInfo.issuer) &&
131
+ /^(?:\/\/|https?:\/\/|#)/.test(request)
134
132
  ) {
135
133
  if (dependencyType === "url") {
136
134
  return callback(null, `asset ${request}`);
@@ -156,7 +154,7 @@ class WebpackOptionsApply extends OptionsApply {
156
154
  const ExternalsPlugin = require("./ExternalsPlugin");
157
155
 
158
156
  new ExternalsPlugin(type, ({ request, dependencyType }, callback) => {
159
- if (/^(\/\/|https?:\/\/|#|std:|jsr:|npm:)/.test(request)) {
157
+ if (/^(?:\/\/|https?:\/\/|#|std:|jsr:|npm:)/.test(request)) {
160
158
  if (dependencyType === "url") {
161
159
  return callback(null, `asset ${request}`);
162
160
  } else if (
@@ -166,7 +164,7 @@ class WebpackOptionsApply extends OptionsApply {
166
164
  options.experiments.css
167
165
  ) {
168
166
  return callback(null, `css-import ${request}`);
169
- } else if (/^(\/\/|https?:\/\/|std:|jsr:|npm:)/.test(request)) {
167
+ } else if (/^(?:\/\/|https?:\/\/|std:|jsr:|npm:)/.test(request)) {
170
168
  return callback(null, `${type} ${request}`);
171
169
  }
172
170
  }
@@ -315,37 +313,59 @@ class WebpackOptionsApply extends OptionsApply {
315
313
  ).apply(compiler);
316
314
  }
317
315
 
318
- if (options.devtool) {
319
- if (options.devtool.includes("source-map")) {
320
- const hidden = options.devtool.includes("hidden");
321
- const inline = options.devtool.includes("inline");
322
- const evalWrapped = options.devtool.includes("eval");
323
- const cheap = options.devtool.includes("cheap");
324
- const moduleMaps = options.devtool.includes("module");
325
- const noSources = options.devtool.includes("nosources");
326
- const debugIds = options.devtool.includes("debugids");
327
- const Plugin = evalWrapped
328
- ? require("./EvalSourceMapDevToolPlugin")
329
- : require("./SourceMapDevToolPlugin");
330
- new Plugin({
331
- filename: inline ? null : options.output.sourceMapFilename,
332
- moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
333
- fallbackModuleFilenameTemplate:
334
- options.output.devtoolFallbackModuleFilenameTemplate,
335
- append: hidden ? false : undefined,
336
- module: moduleMaps ? true : !cheap,
337
- columns: !cheap,
338
- noSources,
339
- namespace: options.output.devtoolNamespace,
340
- debugIds
341
- }).apply(compiler);
342
- } else if (options.devtool.includes("eval")) {
343
- const EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin");
316
+ let devtool =
317
+ interception === undefined ? options.devtool : interception.devtool;
318
+ devtool = Array.isArray(devtool)
319
+ ? devtool
320
+ : typeof devtool === "string"
321
+ ? [{ type: "all", use: devtool }]
322
+ : [];
323
+
324
+ for (const item of devtool) {
325
+ const { type, use } = item;
326
+
327
+ if (use) {
328
+ if (use.includes("source-map")) {
329
+ const hidden = use.includes("hidden");
330
+ const inline = use.includes("inline");
331
+ const evalWrapped = use.includes("eval");
332
+ const cheap = use.includes("cheap");
333
+ const moduleMaps = use.includes("module");
334
+ const noSources = use.includes("nosources");
335
+ const debugIds = use.includes("debugids");
336
+ const Plugin = evalWrapped
337
+ ? require("./EvalSourceMapDevToolPlugin")
338
+ : require("./SourceMapDevToolPlugin");
339
+ const assetExt =
340
+ type === "javascript"
341
+ ? /\.((c|m)?js)($|\?)/i
342
+ : type === "css"
343
+ ? /\.(css)($|\?)/i
344
+ : /\.((c|m)?js|css)($|\?)/i;
345
+
346
+ new Plugin({
347
+ test: evalWrapped ? undefined : assetExt,
348
+ filename: inline ? null : options.output.sourceMapFilename,
349
+ moduleFilenameTemplate:
350
+ options.output.devtoolModuleFilenameTemplate,
351
+ fallbackModuleFilenameTemplate:
352
+ options.output.devtoolFallbackModuleFilenameTemplate,
353
+ append: hidden ? false : undefined,
354
+ module: moduleMaps ? true : !cheap,
355
+ columns: !cheap,
356
+ noSources,
357
+ namespace: options.output.devtoolNamespace,
358
+ debugIds
359
+ }).apply(compiler);
360
+ } else if (use.includes("eval")) {
361
+ const EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin");
344
362
 
345
- new EvalDevToolModulePlugin({
346
- moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
347
- namespace: options.output.devtoolNamespace
348
- }).apply(compiler);
363
+ new EvalDevToolModulePlugin({
364
+ moduleFilenameTemplate:
365
+ options.output.devtoolModuleFilenameTemplate,
366
+ namespace: options.output.devtoolNamespace
367
+ }).apply(compiler);
368
+ }
349
369
  }
350
370
  }
351
371
 
@@ -60,6 +60,7 @@ class AssetSourceGenerator extends Generator {
60
60
  runtimeRequirements.add(RuntimeGlobals.requireScope);
61
61
  runtimeRequirements.add(RuntimeGlobals.toBinary);
62
62
 
63
+ /** @type {string} */
63
64
  let sourceContent;
64
65
  if (concatenationScope) {
65
66
  concatenationScope.registerNamespaceExport(
@@ -43,6 +43,7 @@ const getMimeTypes = memoize(() => require("mime-types"));
43
43
  /** @typedef {import("../Compilation").AssetInfo} AssetInfo */
44
44
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
45
45
  /** @typedef {import("../Generator").UpdateHashContext} UpdateHashContext */
46
+ /** @typedef {import("../Module")} Module */
46
47
  /** @typedef {import("../Module").NameForCondition} NameForCondition */
47
48
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
48
49
  /** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
@@ -54,6 +55,8 @@ const getMimeTypes = memoize(() => require("mime-types"));
54
55
  /** @typedef {import("../util/Hash")} Hash */
55
56
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
56
57
 
58
+ /** @typedef {(source: string | Buffer, context: { filename: string, module: Module }) => string} DataUrlFunction */
59
+
57
60
  /**
58
61
  * @template T
59
62
  * @template U
@@ -62,12 +65,13 @@ const getMimeTypes = memoize(() => require("mime-types"));
62
65
  * @returns {T[] & U[]} array
63
66
  */
64
67
  const mergeMaybeArrays = (a, b) => {
68
+ /** @type {Set<T | U | null | undefined | string | Set<T> | Set<U>>} */
65
69
  const set = new Set();
66
70
  if (Array.isArray(a)) for (const item of a) set.add(item);
67
71
  else set.add(a);
68
72
  if (Array.isArray(b)) for (const item of b) set.add(item);
69
73
  else set.add(b);
70
- return [...set];
74
+ return /** @type {T[] & U[]} */ ([.../** @type {Set<T | U>} */ (set)]);
71
75
  };
72
76
 
73
77
  /**
@@ -204,11 +208,17 @@ class AssetGenerator extends Generator {
204
208
  emit
205
209
  ) {
206
210
  super();
211
+ /** @type {AssetGeneratorOptions["dataUrl"] | undefined} */
207
212
  this.dataUrlOptions = dataUrlOptions;
213
+ /** @type {AssetModuleFilename | undefined} */
208
214
  this.filename = filename;
215
+ /** @type {RawPublicPath | undefined} */
209
216
  this.publicPath = publicPath;
217
+ /** @type {AssetModuleOutputPath | undefined} */
210
218
  this.outputPath = outputPath;
219
+ /** @type {boolean | undefined} */
211
220
  this.emit = emit;
221
+ /** @type {ModuleGraph} */
212
222
  this._moduleGraph = moduleGraph;
213
223
  }
214
224
 
@@ -333,6 +343,7 @@ class AssetGenerator extends Generator {
333
343
  runtimeTemplate
334
344
  );
335
345
 
346
+ /** @type {undefined | string} */
336
347
  let assetPath;
337
348
 
338
349
  if (generatorOptions.publicPath !== undefined && type === JAVASCRIPT_TYPE) {
@@ -457,6 +468,7 @@ class AssetGenerator extends Generator {
457
468
  generateDataUri(module) {
458
469
  const source = /** @type {Source} */ (module.originalSource());
459
470
 
471
+ /** @type {string} */
460
472
  let encodedSource;
461
473
 
462
474
  if (typeof this.dataUrlOptions === "function") {
@@ -480,6 +492,7 @@ class AssetGenerator extends Generator {
480
492
  }
481
493
  const mimeType = this.getMimeType(module);
482
494
 
495
+ /** @type {string} */
483
496
  let encodedContent;
484
497
 
485
498
  if (
@@ -490,7 +503,9 @@ class AssetGenerator extends Generator {
490
503
  /** @type {string} */ (module.resourceResolveData.encodedContent)
491
504
  ).equals(source.buffer())
492
505
  ) {
493
- encodedContent = module.resourceResolveData.encodedContent;
506
+ encodedContent =
507
+ /** @type {string} */
508
+ (module.resourceResolveData.encodedContent);
494
509
  } else {
495
510
  encodedContent = encodeDataUri(
496
511
  /** @type {"base64" | false} */ (encoding),
@@ -520,10 +535,10 @@ class AssetGenerator extends Generator {
520
535
  concatenationScope
521
536
  } = generateContext;
522
537
 
538
+ /** @type {string} */
523
539
  let content;
524
540
 
525
541
  const needContent = type === JAVASCRIPT_TYPE || type === CSS_URL_TYPE;
526
-
527
542
  const data = getData ? getData() : undefined;
528
543
 
529
544
  if (