webpack 5.101.3 → 5.102.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 (322) hide show
  1. package/README.md +21 -26
  2. package/lib/APIPlugin.js +30 -36
  3. package/lib/AsyncDependenciesBlock.js +1 -4
  4. package/lib/BannerPlugin.js +0 -1
  5. package/lib/Cache.js +7 -6
  6. package/lib/CacheFacade.js +0 -1
  7. package/lib/Chunk.js +49 -31
  8. package/lib/ChunkGraph.js +35 -25
  9. package/lib/ChunkGroup.js +8 -10
  10. package/lib/ChunkTemplate.js +1 -1
  11. package/lib/CleanPlugin.js +3 -3
  12. package/lib/CodeGenerationResults.js +2 -1
  13. package/lib/CompatibilityPlugin.js +29 -12
  14. package/lib/Compilation.js +204 -185
  15. package/lib/Compiler.js +36 -35
  16. package/lib/ConcatenationScope.js +6 -1
  17. package/lib/ConditionalInitFragment.js +1 -1
  18. package/lib/ConstPlugin.js +6 -5
  19. package/lib/ContextExclusionPlugin.js +0 -1
  20. package/lib/ContextModule.js +22 -20
  21. package/lib/ContextModuleFactory.js +30 -11
  22. package/lib/ContextReplacementPlugin.js +38 -15
  23. package/lib/DefinePlugin.js +4 -8
  24. package/lib/DelegatedModule.js +7 -11
  25. package/lib/DependenciesBlock.js +0 -2
  26. package/lib/Dependency.js +9 -11
  27. package/lib/DependencyTemplates.js +1 -3
  28. package/lib/DllModule.js +1 -7
  29. package/lib/DllReferencePlugin.js +2 -4
  30. package/lib/DynamicEntryPlugin.js +0 -2
  31. package/lib/EntryOptionPlugin.js +0 -5
  32. package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
  33. package/lib/EvalDevToolModulePlugin.js +4 -3
  34. package/lib/EvalSourceMapDevToolPlugin.js +3 -4
  35. package/lib/ExportsInfo.js +50 -49
  36. package/lib/ExternalModule.js +84 -52
  37. package/lib/ExternalModuleFactoryPlugin.js +27 -7
  38. package/lib/ExternalsPlugin.js +24 -17
  39. package/lib/FileSystemInfo.js +96 -78
  40. package/lib/FlagDependencyUsagePlugin.js +3 -4
  41. package/lib/Generator.js +2 -13
  42. package/lib/GraphHelpers.js +0 -3
  43. package/lib/HookWebpackError.js +0 -2
  44. package/lib/HotModuleReplacementPlugin.js +22 -24
  45. package/lib/HotUpdateChunk.js +0 -3
  46. package/lib/IgnorePlugin.js +5 -2
  47. package/lib/InitFragment.js +41 -29
  48. package/lib/InvalidDependenciesModuleWarning.js +0 -1
  49. package/lib/LibManifestPlugin.js +4 -6
  50. package/lib/LoaderOptionsPlugin.js +1 -10
  51. package/lib/MainTemplate.js +8 -19
  52. package/lib/Module.js +32 -20
  53. package/lib/ModuleFactory.js +1 -1
  54. package/lib/ModuleFilenameHelpers.js +41 -24
  55. package/lib/ModuleGraph.js +30 -16
  56. package/lib/ModuleInfoHeaderPlugin.js +0 -1
  57. package/lib/ModuleTemplate.js +0 -2
  58. package/lib/ModuleTypeConstants.js +11 -1
  59. package/lib/MultiCompiler.js +23 -15
  60. package/lib/MultiWatching.js +6 -10
  61. package/lib/NodeStuffPlugin.js +2 -10
  62. package/lib/NormalModule.js +145 -88
  63. package/lib/NormalModuleFactory.js +59 -40
  64. package/lib/OptionsApply.js +1 -1
  65. package/lib/Parser.js +1 -1
  66. package/lib/ProgressPlugin.js +6 -10
  67. package/lib/ProvidePlugin.js +5 -7
  68. package/lib/RawModule.js +1 -6
  69. package/lib/RecordIdsPlugin.js +10 -6
  70. package/lib/ResolverFactory.js +0 -2
  71. package/lib/RuntimeGlobals.js +5 -0
  72. package/lib/RuntimeModule.js +1 -3
  73. package/lib/RuntimePlugin.js +26 -22
  74. package/lib/RuntimeTemplate.js +12 -11
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
  76. package/lib/SourceMapDevToolPlugin.js +6 -11
  77. package/lib/Stats.js +0 -1
  78. package/lib/Template.js +6 -11
  79. package/lib/TemplatedPathPlugin.js +2 -1
  80. package/lib/WatchIgnorePlugin.js +2 -3
  81. package/lib/Watching.js +15 -15
  82. package/lib/WebpackIsIncludedPlugin.js +0 -2
  83. package/lib/WebpackOptionsApply.js +74 -107
  84. package/lib/asset/AssetBytesGenerator.js +166 -0
  85. package/lib/asset/AssetBytesParser.js +37 -0
  86. package/lib/asset/AssetGenerator.js +20 -34
  87. package/lib/asset/AssetModulesPlugin.js +34 -16
  88. package/lib/asset/AssetParser.js +7 -3
  89. package/lib/asset/AssetSourceGenerator.js +1 -1
  90. package/lib/asset/RawDataUrlModule.js +3 -2
  91. package/lib/async-modules/AsyncModuleHelpers.js +6 -4
  92. package/lib/buildChunkGraph.js +0 -1
  93. package/lib/cache/MemoryCachePlugin.js +0 -2
  94. package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
  95. package/lib/cache/PackFileCacheStrategy.js +14 -1
  96. package/lib/cache/ResolverCachePlugin.js +9 -15
  97. package/lib/config/defaults.js +155 -21
  98. package/lib/config/normalization.js +18 -3
  99. package/lib/container/ContainerEntryDependency.js +0 -1
  100. package/lib/container/ContainerEntryModule.js +3 -7
  101. package/lib/container/ContainerPlugin.js +1 -2
  102. package/lib/container/ContainerReferencePlugin.js +0 -1
  103. package/lib/container/FallbackDependency.js +2 -1
  104. package/lib/container/FallbackModule.js +6 -7
  105. package/lib/container/ModuleFederationPlugin.js +0 -1
  106. package/lib/container/RemoteModule.js +8 -8
  107. package/lib/container/RemoteRuntimeModule.js +2 -2
  108. package/lib/css/CssGenerator.js +3 -6
  109. package/lib/css/CssLoadingRuntimeModule.js +6 -9
  110. package/lib/css/CssModulesPlugin.js +11 -13
  111. package/lib/css/CssParser.js +3 -3
  112. package/lib/css/walkCssTokens.js +1 -1
  113. package/lib/debug/ProfilingPlugin.js +35 -8
  114. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
  115. package/lib/dependencies/AMDPlugin.js +2 -2
  116. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
  117. package/lib/dependencies/CachedConstDependency.js +0 -4
  118. package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
  119. package/lib/dependencies/CommonJsExportsDependency.js +2 -1
  120. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
  121. package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
  122. package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
  123. package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
  124. package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
  125. package/lib/dependencies/ConstDependency.js +2 -2
  126. package/lib/dependencies/ContextDependency.js +9 -4
  127. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  128. package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
  129. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
  130. package/lib/dependencies/ContextElementDependency.js +22 -11
  131. package/lib/dependencies/CssIcssImportDependency.js +0 -2
  132. package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
  133. package/lib/dependencies/CssImportDependency.js +0 -8
  134. package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
  135. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
  136. package/lib/dependencies/CssUrlDependency.js +0 -6
  137. package/lib/dependencies/ExportsInfoDependency.js +7 -9
  138. package/lib/dependencies/ExternalModuleDependency.js +0 -3
  139. package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
  140. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  141. package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
  142. package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
  143. package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
  144. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
  145. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
  146. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
  147. package/lib/dependencies/HarmonyImportDependency.js +30 -14
  148. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
  149. package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
  150. package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
  151. package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
  152. package/lib/dependencies/ImportDependency.js +18 -6
  153. package/lib/dependencies/ImportEagerDependency.js +2 -3
  154. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
  155. package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
  156. package/lib/dependencies/ImportMetaPlugin.js +2 -1
  157. package/lib/dependencies/ImportParserPlugin.js +288 -45
  158. package/lib/dependencies/ImportWeakDependency.js +2 -3
  159. package/lib/dependencies/JsonExportsDependency.js +0 -1
  160. package/lib/dependencies/LoaderDependency.js +0 -3
  161. package/lib/dependencies/LoaderImportDependency.js +0 -3
  162. package/lib/dependencies/LoaderPlugin.js +11 -5
  163. package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
  164. package/lib/dependencies/ModuleDependency.js +3 -9
  165. package/lib/dependencies/NullDependency.js +2 -0
  166. package/lib/dependencies/ProvidedDependency.js +6 -8
  167. package/lib/dependencies/PureExpressionDependency.js +0 -1
  168. package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
  169. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
  170. package/lib/dependencies/RequireIncludeDependency.js +2 -2
  171. package/lib/dependencies/RequireResolveDependency.js +2 -2
  172. package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
  173. package/lib/dependencies/StaticExportsDependency.js +3 -5
  174. package/lib/dependencies/URLDependency.js +2 -7
  175. package/lib/dependencies/URLPlugin.js +1 -2
  176. package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
  177. package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
  178. package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
  179. package/lib/dependencies/WorkerDependency.js +2 -3
  180. package/lib/dependencies/WorkerPlugin.js +3 -9
  181. package/lib/dependencies/processExportInfo.js +2 -3
  182. package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
  183. package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
  184. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
  185. package/lib/hmr/LazyCompilationPlugin.js +6 -4
  186. package/lib/hmr/lazyCompilationBackend.js +13 -10
  187. package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
  188. package/lib/ids/NamedChunkIdsPlugin.js +1 -6
  189. package/lib/ids/NamedModuleIdsPlugin.js +1 -5
  190. package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
  191. package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
  192. package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
  193. package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
  194. package/lib/ids/SyncModuleIdsPlugin.js +4 -3
  195. package/lib/index.js +8 -7
  196. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
  197. package/lib/javascript/BasicEvaluatedExpression.js +13 -6
  198. package/lib/javascript/ChunkFormatHelpers.js +1 -1
  199. package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
  200. package/lib/javascript/JavascriptGenerator.js +2 -3
  201. package/lib/javascript/JavascriptModulesPlugin.js +44 -21
  202. package/lib/javascript/JavascriptParser.js +119 -54
  203. package/lib/javascript/JavascriptParserHelpers.js +2 -2
  204. package/lib/javascript/StartupHelpers.js +2 -4
  205. package/lib/json/JsonData.js +1 -1
  206. package/lib/json/JsonGenerator.js +4 -5
  207. package/lib/json/JsonModulesPlugin.js +0 -3
  208. package/lib/json/JsonParser.js +4 -2
  209. package/lib/library/AbstractLibraryPlugin.js +2 -2
  210. package/lib/library/AmdLibraryPlugin.js +0 -1
  211. package/lib/library/AssignLibraryPlugin.js +23 -12
  212. package/lib/library/EnableLibraryPlugin.js +7 -11
  213. package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
  214. package/lib/library/JsonpLibraryPlugin.js +5 -2
  215. package/lib/library/ModuleLibraryPlugin.js +88 -43
  216. package/lib/library/SystemLibraryPlugin.js +0 -1
  217. package/lib/library/UmdLibraryPlugin.js +12 -18
  218. package/lib/logging/Logger.js +12 -10
  219. package/lib/logging/createConsoleLogger.js +15 -14
  220. package/lib/logging/truncateArgs.js +1 -1
  221. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  222. package/lib/node/NodeWatchFileSystem.js +4 -4
  223. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  224. package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
  225. package/lib/node/nodeConsole.js +2 -2
  226. package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
  227. package/lib/optimize/ConcatenatedModule.js +142 -100
  228. package/lib/optimize/InnerGraph.js +17 -11
  229. package/lib/optimize/InnerGraphPlugin.js +0 -3
  230. package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
  231. package/lib/optimize/RuntimeChunkPlugin.js +0 -1
  232. package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
  233. package/lib/optimize/SplitChunksPlugin.js +46 -40
  234. package/lib/performance/SizeLimitsPlugin.js +2 -1
  235. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
  236. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
  237. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
  238. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
  239. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
  240. package/lib/rules/BasicMatcherRulePlugin.js +0 -2
  241. package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
  242. package/lib/rules/RuleSetCompiler.js +8 -6
  243. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  244. package/lib/runtime/CompatRuntimeModule.js +0 -1
  245. package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
  246. package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
  247. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  248. package/lib/runtime/PublicPathRuntimeModule.js +2 -2
  249. package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
  250. package/lib/runtime/SystemContextRuntimeModule.js +0 -2
  251. package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
  252. package/lib/schemes/DataUriPlugin.js +2 -28
  253. package/lib/schemes/FileUriPlugin.js +5 -2
  254. package/lib/schemes/HttpUriPlugin.js +4 -2
  255. package/lib/schemes/VirtualUrlPlugin.js +11 -11
  256. package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
  257. package/lib/serialization/ObjectMiddleware.js +30 -19
  258. package/lib/serialization/SerializerMiddleware.js +1 -3
  259. package/lib/serialization/types.js +1 -1
  260. package/lib/sharing/ConsumeSharedModule.js +3 -5
  261. package/lib/sharing/ConsumeSharedPlugin.js +2 -4
  262. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
  263. package/lib/sharing/ProvideSharedModule.js +3 -7
  264. package/lib/sharing/SharePlugin.js +0 -2
  265. package/lib/sharing/ShareRuntimeModule.js +4 -1
  266. package/lib/sharing/resolveMatchedConfigs.js +14 -6
  267. package/lib/sharing/utils.js +0 -6
  268. package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
  269. package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
  270. package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
  271. package/lib/stats/StatsFactory.js +14 -11
  272. package/lib/url/URLParserPlugin.js +2 -4
  273. package/lib/util/ArrayHelpers.js +4 -4
  274. package/lib/util/AsyncQueue.js +1 -0
  275. package/lib/util/LazySet.js +2 -2
  276. package/lib/util/StackedCacheMap.js +0 -2
  277. package/lib/util/TupleSet.js +9 -4
  278. package/lib/util/URLAbsoluteSpecifier.js +0 -1
  279. package/lib/util/WeakTupleMap.js +1 -1
  280. package/lib/util/chainedImports.js +3 -1
  281. package/lib/util/cleverMerge.js +15 -18
  282. package/lib/util/comparators.js +2 -4
  283. package/lib/util/compileBooleanMatcher.js +11 -9
  284. package/lib/util/concatenate.js +1 -2
  285. package/lib/util/create-schema-validation.js +0 -1
  286. package/lib/util/dataURL.js +39 -0
  287. package/lib/util/deprecation.js +29 -31
  288. package/lib/util/deterministicGrouping.js +34 -30
  289. package/lib/util/extractSourceMap.js +319 -0
  290. package/lib/util/findGraphRoots.js +15 -5
  291. package/lib/util/fs.js +29 -8
  292. package/lib/util/semver.js +9 -8
  293. package/lib/util/smartGrouping.js +41 -26
  294. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  295. package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
  296. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  297. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
  298. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
  299. package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
  300. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
  301. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
  302. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
  303. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
  304. package/lib/wasm-sync/WebAssemblyParser.js +1 -4
  305. package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
  306. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  307. package/lib/web/JsonpTemplatePlugin.js +0 -1
  308. package/lib/webpack.js +21 -8
  309. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
  310. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  311. package/package.json +12 -12
  312. package/schemas/WebpackOptions.check.js +1 -1
  313. package/schemas/WebpackOptions.json +77 -93
  314. package/schemas/plugins/BannerPlugin.check.js +1 -1
  315. package/schemas/plugins/BannerPlugin.json +4 -0
  316. package/schemas/plugins/IgnorePlugin.json +1 -1
  317. package/schemas/plugins/ProgressPlugin.json +1 -1
  318. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  319. package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
  320. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  321. package/types.d.ts +1129 -530
  322. package/SECURITY.md +0 -9
@@ -26,10 +26,7 @@ const makeSerializable = require("../util/makeSerializable");
26
26
  * @typedef {import("tapable").SyncHook<T>} SyncHook
27
27
  */
28
28
 
29
- /**
30
- * @template H
31
- * @typedef {import("tapable").HookMapInterceptor<H>} HookMapInterceptor
32
- */
29
+ /** @typedef {Set<string>} Dependencies */
33
30
 
34
31
  class CacheEntry {
35
32
  /**
@@ -163,11 +160,8 @@ class ResolverCachePlugin {
163
160
  const newResolveContext = {
164
161
  ...resolveContext,
165
162
  stack: new Set(),
166
- /** @type {LazySet<string>} */
167
163
  missingDependencies: new LazySet(),
168
- /** @type {LazySet<string>} */
169
164
  fileDependencies: new LazySet(),
170
- /** @type {LazySet<string>} */
171
165
  contextDependencies: new LazySet()
172
166
  };
173
167
  /** @type {ResolveRequest[] | undefined} */
@@ -186,8 +180,8 @@ class ResolverCachePlugin {
186
180
  const propagate = (key) => {
187
181
  if (resolveContext[key]) {
188
182
  addAllToSet(
189
- /** @type {Set<string>} */ (resolveContext[key]),
190
- /** @type {Set<string>} */ (newResolveContext[key])
183
+ /** @type {Dependencies} */ (resolveContext[key]),
184
+ /** @type {Dependencies} */ (newResolveContext[key])
191
185
  );
192
186
  }
193
187
  };
@@ -207,11 +201,11 @@ class ResolverCachePlugin {
207
201
  const missingDependencies = newResolveContext.missingDependencies;
208
202
  fileSystemInfo.createSnapshot(
209
203
  resolveTime,
210
- /** @type {Set<string>} */
204
+ /** @type {Dependencies} */
211
205
  (fileDependencies),
212
- /** @type {Set<string>} */
206
+ /** @type {Dependencies} */
213
207
  (contextDependencies),
214
- /** @type {Set<string>} */
208
+ /** @type {Dependencies} */
215
209
  (missingDependencies),
216
210
  snapshotOptions,
217
211
  (err, snapshot) => {
@@ -404,21 +398,21 @@ class ResolverCachePlugin {
404
398
  cachedResolves++;
405
399
  if (resolveContext.missingDependencies) {
406
400
  addAllToSet(
407
- /** @type {Set<string>} */
401
+ /** @type {Dependencies} */
408
402
  (resolveContext.missingDependencies),
409
403
  snapshot.getMissingIterable()
410
404
  );
411
405
  }
412
406
  if (resolveContext.fileDependencies) {
413
407
  addAllToSet(
414
- /** @type {Set<string>} */
408
+ /** @type {Dependencies} */
415
409
  (resolveContext.fileDependencies),
416
410
  snapshot.getFileIterable()
417
411
  );
418
412
  }
419
413
  if (resolveContext.contextDependencies) {
420
414
  addAllToSet(
421
- /** @type {Set<string>} */
415
+ /** @type {Dependencies} */
422
416
  (resolveContext.contextDependencies),
423
417
  snapshot.getContextIterable()
424
418
  );
@@ -9,8 +9,10 @@ const fs = require("fs");
9
9
  const path = require("path");
10
10
  const {
11
11
  ASSET_MODULE_TYPE,
12
+ ASSET_MODULE_TYPE_BYTES,
12
13
  ASSET_MODULE_TYPE_INLINE,
13
14
  ASSET_MODULE_TYPE_RESOURCE,
15
+ ASSET_MODULE_TYPE_SOURCE,
14
16
  CSS_MODULE_TYPE,
15
17
  CSS_MODULE_TYPE_AUTO,
16
18
  CSS_MODULE_TYPE_GLOBAL,
@@ -30,14 +32,11 @@ const {
30
32
  getTargetsProperties
31
33
  } = require("./target");
32
34
 
33
- /** @typedef {import("../../declarations/WebpackOptions").CacheOptions} CacheOptions */
34
35
  /** @typedef {import("../../declarations/WebpackOptions").CacheOptionsNormalized} CacheOptionsNormalized */
35
36
  /** @typedef {import("../../declarations/WebpackOptions").Context} Context */
36
37
  /** @typedef {import("../../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */
37
- /** @typedef {import("../../declarations/WebpackOptions").CssParserOptions} CssParserOptions */
38
38
  /** @typedef {import("../../declarations/WebpackOptions").EntryDescription} EntryDescription */
39
39
  /** @typedef {import("../../declarations/WebpackOptions").EntryNormalized} Entry */
40
- /** @typedef {import("../../declarations/WebpackOptions").EntryStaticNormalized} EntryStaticNormalized */
41
40
  /** @typedef {import("../../declarations/WebpackOptions").Environment} Environment */
42
41
  /** @typedef {import("../../declarations/WebpackOptions").Experiments} Experiments */
43
42
  /** @typedef {import("../../declarations/WebpackOptions").ExperimentsNormalized} ExperimentsNormalized */
@@ -50,13 +49,12 @@ const {
50
49
  /** @typedef {import("../../declarations/WebpackOptions").JsonGeneratorOptions} JsonGeneratorOptions */
51
50
  /** @typedef {import("../../declarations/WebpackOptions").Library} Library */
52
51
  /** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
53
- /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
54
52
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
55
53
  /** @typedef {import("../../declarations/WebpackOptions").Loader} Loader */
56
54
  /** @typedef {import("../../declarations/WebpackOptions").Mode} Mode */
57
55
  /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
58
56
  /** @typedef {import("../../declarations/WebpackOptions").Node} WebpackNode */
59
- /** @typedef {import("../../declarations/WebpackOptions").Optimization} Optimization */
57
+ /** @typedef {import("../../declarations/WebpackOptions").OptimizationNormalized} Optimization */
60
58
  /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
61
59
  /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */
62
60
  /** @typedef {import("../../declarations/WebpackOptions").ParserOptionsByModuleTypeKnown} ParserOptionsByModuleTypeKnown */
@@ -64,14 +62,149 @@ const {
64
62
  /** @typedef {import("../../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
65
63
  /** @typedef {import("../../declarations/WebpackOptions").RuleSetRules} RuleSetRules */
66
64
  /** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */
67
- /** @typedef {import("../../declarations/WebpackOptions").Target} Target */
68
- /** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
69
65
  /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
70
- /** @typedef {import("../Compiler")} Compiler */
71
66
  /** @typedef {import("../Module")} Module */
72
67
  /** @typedef {import("./target").PlatformTargetProperties} PlatformTargetProperties */
73
68
  /** @typedef {import("./target").TargetProperties} TargetProperties */
74
69
 
70
+ /**
71
+ * @template T
72
+ * @typedef {{ [P in keyof T]-?: T[P] extends object ? RecursiveNonNullable<NonNullable<T[P]>> : NonNullable<T[P]> }} RecursiveNonNullable
73
+ */
74
+
75
+ /**
76
+ * @typedef {Output & {
77
+ * uniqueName: NonNullable<Output["uniqueName"]>,
78
+ * filename: NonNullable<Output["filename"]>,
79
+ * cssFilename: NonNullable<Output["cssFilename"]>,
80
+ * chunkFilename: NonNullable<Output["chunkFilename"]>,
81
+ * cssChunkFilename: NonNullable<Output["cssChunkFilename"]>,
82
+ * hotUpdateChunkFilename: NonNullable<Output["hotUpdateChunkFilename"]>,
83
+ * hotUpdateGlobal: NonNullable<Output["hotUpdateGlobal"]>,
84
+ * assetModuleFilename: NonNullable<Output["assetModuleFilename"]>,
85
+ * webassemblyModuleFilename: NonNullable<Output["webassemblyModuleFilename"]>
86
+ * sourceMapFilename: NonNullable<Output["sourceMapFilename"]>,
87
+ * hotUpdateMainFilename: NonNullable<Output["hotUpdateMainFilename"]>,
88
+ * devtoolNamespace: NonNullable<Output["devtoolNamespace"]>,
89
+ * publicPath: NonNullable<Output["publicPath"]>
90
+ * workerPublicPath: NonNullable<Output["workerPublicPath"]>
91
+ * workerWasmLoading: NonNullable<Output["workerWasmLoading"]>
92
+ * workerChunkLoading: NonNullable<Output["workerChunkLoading"]>
93
+ * chunkFormat: NonNullable<Output["chunkFormat"]>,
94
+ * module: NonNullable<Output["module"]>,
95
+ * asyncChunks: NonNullable<Output["asyncChunks"]>,
96
+ * charset: NonNullable<Output["charset"]>,
97
+ * iife: NonNullable<Output["iife"]>,
98
+ * globalObject: NonNullable<Output["globalObject"]>,
99
+ * scriptType: NonNullable<Output["scriptType"]>,
100
+ * path: NonNullable<Output["path"]>,
101
+ * pathinfo: NonNullable<Output["pathinfo"]>,
102
+ * hashFunction: NonNullable<Output["hashFunction"]>,
103
+ * hashDigest: NonNullable<Output["hashDigest"]>,
104
+ * hashDigestLength: NonNullable<Output["hashDigestLength"]>,
105
+ * chunkLoadTimeout: NonNullable<Output["chunkLoadTimeout"]>,
106
+ * chunkLoading: NonNullable<Output["chunkLoading"]>,
107
+ * chunkLoadingGlobal: NonNullable<Output["chunkLoadingGlobal"]>,
108
+ * compareBeforeEmit: NonNullable<Output["compareBeforeEmit"]>,
109
+ * strictModuleErrorHandling: NonNullable<Output["strictModuleErrorHandling"]>,
110
+ * strictModuleExceptionHandling: NonNullable<Output["strictModuleExceptionHandling"]>,
111
+ * importFunctionName: NonNullable<Output["importFunctionName"]>,
112
+ * importMetaName: NonNullable<Output["importMetaName"]>,
113
+ * environment: RecursiveNonNullable<Output["environment"]>,
114
+ * crossOriginLoading: NonNullable<Output["crossOriginLoading"]>,
115
+ * wasmLoading: NonNullable<Output["wasmLoading"]>,
116
+ * }} OutputNormalizedWithDefaults
117
+ */
118
+
119
+ /**
120
+ * @typedef {SnapshotOptions & {
121
+ * managedPaths: NonNullable<SnapshotOptions["managedPaths"]>,
122
+ * unmanagedPaths: NonNullable<SnapshotOptions["unmanagedPaths"]>,
123
+ * immutablePaths: NonNullable<SnapshotOptions["immutablePaths"]>,
124
+ * resolveBuildDependencies: NonNullable<SnapshotOptions["resolveBuildDependencies"]>,
125
+ * buildDependencies: NonNullable<SnapshotOptions["buildDependencies"]>,
126
+ * module: NonNullable<SnapshotOptions["module"]>,
127
+ * resolve: NonNullable<SnapshotOptions["resolve"]>,
128
+ * }} SnapshotNormalizedWithDefaults
129
+ */
130
+
131
+ /**
132
+ * @typedef {Optimization & {
133
+ * runtimeChunk: NonNullable<Optimization["runtimeChunk"]>,
134
+ * splitChunks: NonNullable<Optimization["splitChunks"]>,
135
+ * mergeDuplicateChunks: NonNullable<Optimization["mergeDuplicateChunks"]>,
136
+ * removeAvailableModules: NonNullable<Optimization["removeAvailableModules"]>,
137
+ * removeEmptyChunks: NonNullable<Optimization["removeEmptyChunks"]>,
138
+ * flagIncludedChunks: NonNullable<Optimization["flagIncludedChunks"]>,
139
+ * moduleIds: NonNullable<Optimization["moduleIds"]>,
140
+ * chunkIds: NonNullable<Optimization["chunkIds"]>,
141
+ * sideEffects: NonNullable<Optimization["sideEffects"]>,
142
+ * providedExports: NonNullable<Optimization["providedExports"]>,
143
+ * usedExports: NonNullable<Optimization["usedExports"]>,
144
+ * mangleExports: NonNullable<Optimization["mangleExports"]>,
145
+ * innerGraph: NonNullable<Optimization["innerGraph"]>,
146
+ * concatenateModules: NonNullable<Optimization["concatenateModules"]>,
147
+ * avoidEntryIife: NonNullable<Optimization["avoidEntryIife"]>,
148
+ * emitOnErrors: NonNullable<Optimization["emitOnErrors"]>,
149
+ * checkWasmTypes: NonNullable<Optimization["checkWasmTypes"]>,
150
+ * mangleWasmImports: NonNullable<Optimization["mangleWasmImports"]>,
151
+ * portableRecords: NonNullable<Optimization["portableRecords"]>,
152
+ * realContentHash: NonNullable<Optimization["realContentHash"]>,
153
+ * minimize: NonNullable<Optimization["minimize"]>,
154
+ * minimizer: NonNullable<Exclude<Optimization["minimizer"], "...">>,
155
+ * nodeEnv: NonNullable<Optimization["nodeEnv"]>,
156
+ * }} OptimizationNormalizedWithDefaults
157
+ */
158
+
159
+ /**
160
+ * @typedef {ExternalsPresets & {
161
+ * web: NonNullable<ExternalsPresets["web"]>,
162
+ * node: NonNullable<ExternalsPresets["node"]>,
163
+ * nwjs: NonNullable<ExternalsPresets["nwjs"]>,
164
+ * electron: NonNullable<ExternalsPresets["electron"]>,
165
+ * electronMain: NonNullable<ExternalsPresets["electronMain"]>,
166
+ * electronPreload: NonNullable<ExternalsPresets["electronPreload"]>,
167
+ * electronRenderer: NonNullable<ExternalsPresets["electronRenderer"]>,
168
+ * }} ExternalsPresetsNormalizedWithDefaults
169
+ */
170
+
171
+ /**
172
+ * @typedef {InfrastructureLogging & {
173
+ * stream: NonNullable<InfrastructureLogging["stream"]>,
174
+ * level: NonNullable<InfrastructureLogging["level"]>,
175
+ * debug: NonNullable<InfrastructureLogging["debug"]>,
176
+ * colors: NonNullable<InfrastructureLogging["colors"]>,
177
+ * appendOnly: NonNullable<InfrastructureLogging["appendOnly"]>,
178
+ * }} InfrastructureLoggingNormalizedWithDefaults
179
+ */
180
+
181
+ /**
182
+ * @typedef {WebpackOptionsNormalized
183
+ * & { context: NonNullable<WebpackOptionsNormalized["context"]> }
184
+ * & { infrastructureLogging: InfrastructureLoggingNormalizedWithDefaults }
185
+ * } WebpackOptionsNormalizedWithBaseDefaults
186
+ */
187
+
188
+ /**
189
+ * @typedef {WebpackOptionsNormalizedWithBaseDefaults
190
+ * & { target: NonNullable<WebpackOptionsNormalized["target"]> }
191
+ * & { output: OutputNormalizedWithDefaults }
192
+ * & { optimization: OptimizationNormalizedWithDefaults }
193
+ * & { devtool: NonNullable<WebpackOptionsNormalized["devtool"]> }
194
+ * & { stats: NonNullable<WebpackOptionsNormalized["stats"]> }
195
+ * & { node: NonNullable<WebpackOptionsNormalized["node"]> }
196
+ * & { profile: NonNullable<WebpackOptionsNormalized["profile"]> }
197
+ * & { parallelism: NonNullable<WebpackOptionsNormalized["parallelism"]> }
198
+ * & { snapshot: SnapshotNormalizedWithDefaults }
199
+ * & { externalsPresets: ExternalsPresetsNormalizedWithDefaults }
200
+ * & { externalsType: NonNullable<WebpackOptionsNormalized["externalsType"]> }
201
+ * & { watch: NonNullable<WebpackOptionsNormalized["watch"]> }
202
+ * & { performance: NonNullable<WebpackOptionsNormalized["performance"]> }
203
+ * & { recordsInputPath: NonNullable<WebpackOptionsNormalized["recordsInputPath"]> }
204
+ * & { recordsOutputPath: NonNullable<WebpackOptionsNormalized["recordsOutputPath"]>
205
+ * }} WebpackOptionsNormalizedWithDefaults
206
+ */
207
+
75
208
  /**
76
209
  * @typedef {object} ResolvedOptions
77
210
  * @property {PlatformTargetProperties | false} platform - platform target properties
@@ -140,9 +273,9 @@ const A = (obj, prop, factory) => {
140
273
  newArray = value.slice(0, i);
141
274
  obj[prop] = /** @type {T[P]} */ (/** @type {unknown} */ (newArray));
142
275
  }
143
- const items = /** @type {EXPECTED_ANY[]} */ (
144
- /** @type {unknown} */ (factory())
145
- );
276
+ const items =
277
+ /** @type {EXPECTED_ANY[]} */
278
+ (/** @type {unknown} */ (factory()));
146
279
  if (items !== undefined) {
147
280
  for (const item of items) {
148
281
  newArray.push(item);
@@ -383,20 +516,12 @@ const applyExperimentsDefaults = (
383
516
  D(experiments, "syncWebAssembly", false);
384
517
  D(experiments, "asyncWebAssembly", experiments.futureDefaults);
385
518
  D(experiments, "outputModule", false);
386
- D(experiments, "layers", false);
387
519
  D(experiments, "lazyCompilation", undefined);
388
520
  D(experiments, "buildHttp", undefined);
389
521
  D(experiments, "cacheUnaffected", experiments.futureDefaults);
390
522
  D(experiments, "deferImport", false);
391
523
  F(experiments, "css", () => (experiments.futureDefaults ? true : undefined));
392
524
 
393
- // TODO webpack 6: remove this. topLevelAwait should be enabled by default
394
- let shouldEnableTopLevelAwait = true;
395
- if (typeof experiments.topLevelAwait === "boolean") {
396
- shouldEnableTopLevelAwait = experiments.topLevelAwait;
397
- }
398
- D(experiments, "topLevelAwait", shouldEnableTopLevelAwait);
399
-
400
525
  if (typeof experiments.buildHttp === "object") {
401
526
  D(experiments.buildHttp, "frozen", production);
402
527
  D(experiments.buildHttp, "upgrade", false);
@@ -556,6 +681,7 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
556
681
  F(snapshot, "module", () =>
557
682
  production ? { timestamp: true, hash: true } : { timestamp: true }
558
683
  );
684
+ F(snapshot, "contextModule", () => ({ timestamp: true }));
559
685
  F(snapshot, "resolve", () =>
560
686
  production ? { timestamp: true, hash: true } : { timestamp: true }
561
687
  );
@@ -931,12 +1057,20 @@ const applyModuleDefaults = (
931
1057
  ]
932
1058
  },
933
1059
  {
934
- assert: { type: JSON_MODULE_TYPE },
1060
+ with: { type: JSON_MODULE_TYPE },
935
1061
  type: JSON_MODULE_TYPE
936
1062
  },
937
1063
  {
938
- with: { type: JSON_MODULE_TYPE },
1064
+ assert: { type: JSON_MODULE_TYPE },
939
1065
  type: JSON_MODULE_TYPE
1066
+ },
1067
+ {
1068
+ with: { type: "text" },
1069
+ type: ASSET_MODULE_TYPE_SOURCE
1070
+ },
1071
+ {
1072
+ with: { type: "bytes" },
1073
+ type: ASSET_MODULE_TYPE_BYTES
940
1074
  }
941
1075
  );
942
1076
  return rules;
@@ -15,13 +15,13 @@ const util = require("util");
15
15
  /** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
16
16
  /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
17
17
  /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptionsNormalized */
18
+ /** @typedef {import("../../declarations/WebpackOptions").OptimizationNormalized} OptimizationNormalized */
18
19
  /** @typedef {import("../../declarations/WebpackOptions").OptimizationRuntimeChunk} OptimizationRuntimeChunk */
19
20
  /** @typedef {import("../../declarations/WebpackOptions").OptimizationRuntimeChunkNormalized} OptimizationRuntimeChunkNormalized */
20
21
  /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputNormalized */
21
- /** @typedef {import("../../declarations/WebpackOptions").Plugins} Plugins */
22
+ /** @typedef {import("../../declarations/WebpackOptions").PluginsNormalized} PluginsNormalized */
22
23
  /** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
23
24
  /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
24
- /** @typedef {import("../Entrypoint")} Entrypoint */
25
25
  /** @typedef {import("../WebpackError")} WebpackError */
26
26
 
27
27
  const handledDeprecatedNoEmitOnErrors = util.deprecate(
@@ -287,6 +287,12 @@ const getNormalizedWebpackOptions = (config) => ({
287
287
  cacheGroups: cloneObject(splitChunks.cacheGroups)
288
288
  }
289
289
  ),
290
+ minimizer:
291
+ optimization.minimizer !== undefined
292
+ ? /** @type {OptimizationNormalized["minimizer"]} */ (
293
+ nestedArray(optimization.minimizer, (p) => p.filter(Boolean))
294
+ )
295
+ : optimization.minimizer,
290
296
  emitOnErrors:
291
297
  optimization.noEmitOnErrors !== undefined
292
298
  ? handledDeprecatedNoEmitOnErrors(
@@ -410,7 +416,9 @@ const getNormalizedWebpackOptions = (config) => ({
410
416
  ...performance
411
417
  };
412
418
  }),
413
- plugins: /** @type {Plugins} */ (nestedArray(config.plugins, (p) => [...p])),
419
+ plugins: /** @type {PluginsNormalized} */ (
420
+ nestedArray(config.plugins, (p) => p.filter(Boolean))
421
+ ),
414
422
  profile: config.profile,
415
423
  recordsInputPath:
416
424
  config.recordsInputPath !== undefined
@@ -448,6 +456,13 @@ const getNormalizedWebpackOptions = (config) => ({
448
456
  timestamp: module.timestamp,
449
457
  hash: module.hash
450
458
  })),
459
+ contextModule: optionalNestedConfig(
460
+ snapshot.contextModule,
461
+ (contextModule) => ({
462
+ timestamp: contextModule.timestamp,
463
+ hash: contextModule.hash
464
+ })
465
+ ),
451
466
  immutablePaths: optionalNestedArray(snapshot.immutablePaths, (p) => [...p]),
452
467
  managedPaths: optionalNestedArray(snapshot.managedPaths, (p) => [...p]),
453
468
  unmanagedPaths: optionalNestedArray(snapshot.unmanagedPaths, (p) => [...p])
@@ -8,7 +8,6 @@
8
8
  const Dependency = require("../Dependency");
9
9
  const makeSerializable = require("../util/makeSerializable");
10
10
 
11
- /** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */
12
11
  /** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */
13
12
 
14
13
  class ContainerEntryDependency extends Dependency {
@@ -16,25 +16,21 @@ const StaticExportsDependency = require("../dependencies/StaticExportsDependency
16
16
  const makeSerializable = require("../util/makeSerializable");
17
17
  const ContainerExposedDependency = require("./ContainerExposedDependency");
18
18
 
19
- /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
20
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
21
- /** @typedef {import("../ChunkGroup")} ChunkGroup */
19
+ /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
22
20
  /** @typedef {import("../Compilation")} Compilation */
23
21
  /** @typedef {import("../Module").BuildCallback} BuildCallback */
24
22
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
25
23
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
26
24
  /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
25
+ /** @typedef {import("../Module").LibIdent} LibIdent */
27
26
  /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
28
27
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
29
28
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
30
29
  /** @typedef {import("../RequestShortener")} RequestShortener */
31
30
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
32
- /** @typedef {import("../WebpackError")} WebpackError */
33
31
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
34
32
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
35
- /** @typedef {import("../util/Hash")} Hash */
36
33
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
37
- /** @typedef {import("./ContainerEntryDependency")} ContainerEntryDependency */
38
34
 
39
35
  /**
40
36
  * @typedef {object} ExposeOptions
@@ -83,7 +79,7 @@ class ContainerEntryModule extends Module {
83
79
 
84
80
  /**
85
81
  * @param {LibIdentOptions} options options
86
- * @returns {string | null} an identifier for library inclusion
82
+ * @returns {LibIdent | null} an identifier for library inclusion
87
83
  */
88
84
  libIdent(options) {
89
85
  return `${this.layer ? `(${this.layer})/` : ""}webpack/container/entry/${
@@ -14,7 +14,6 @@ const { parseOptions } = require("./options");
14
14
 
15
15
  /** @typedef {import("../../declarations/plugins/container/ContainerPlugin").ContainerPluginOptions} ContainerPluginOptions */
16
16
  /** @typedef {import("../Compiler")} Compiler */
17
- /** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */
18
17
  /** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */
19
18
 
20
19
  const getModuleFederationPlugin = memoize(() =>
@@ -83,7 +82,7 @@ class ContainerPlugin {
83
82
  const dep = new ContainerEntryDependency(name, exposes, shareScope);
84
83
  dep.loc = { name };
85
84
  compilation.addEntry(
86
- /** @type {string} */ (compilation.options.context),
85
+ compilation.options.context,
87
86
  dep,
88
87
  {
89
88
  name,
@@ -17,7 +17,6 @@ const RemoteToExternalDependency = require("./RemoteToExternalDependency");
17
17
  const { parseOptions } = require("./options");
18
18
 
19
19
  /** @typedef {import("../../declarations/plugins/container/ContainerReferencePlugin").ContainerReferencePluginOptions} ContainerReferencePluginOptions */
20
- /** @typedef {import("../../declarations/plugins/container/ContainerReferencePlugin").RemotesConfig} RemotesConfig */
21
20
  /** @typedef {import("../Compiler")} Compiler */
22
21
 
23
22
  const validate = createSchemaValidation(
@@ -8,12 +8,13 @@
8
8
  const Dependency = require("../Dependency");
9
9
  const makeSerializable = require("../util/makeSerializable");
10
10
 
11
+ /** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */
11
12
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
12
13
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
13
14
 
14
15
  class FallbackDependency extends Dependency {
15
16
  /**
16
- * @param {string[]} requests requests
17
+ * @param {ExternalRequests} requests requests
17
18
  */
18
19
  constructor(requests) {
19
20
  super();
@@ -14,31 +14,30 @@ const Template = require("../Template");
14
14
  const makeSerializable = require("../util/makeSerializable");
15
15
  const FallbackItemDependency = require("./FallbackItemDependency");
16
16
 
17
- /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
17
+ /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
18
18
  /** @typedef {import("../Chunk")} Chunk */
19
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
20
- /** @typedef {import("../ChunkGroup")} ChunkGroup */
21
19
  /** @typedef {import("../Compilation")} Compilation */
22
20
  /** @typedef {import("../Module").BuildCallback} BuildCallback */
23
21
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
24
22
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
25
23
  /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
24
+ /** @typedef {import("../Module").LibIdent} LibIdent */
25
+ /** @typedef {import("../Module").NameForCondition} NameForCondition */
26
26
  /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
27
27
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
28
28
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
29
29
  /** @typedef {import("../RequestShortener")} RequestShortener */
30
30
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
31
- /** @typedef {import("../WebpackError")} WebpackError */
32
31
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
33
32
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
34
- /** @typedef {import("../util/Hash")} Hash */
35
33
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
34
+ /** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */
36
35
 
37
36
  const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
38
37
 
39
38
  class FallbackModule extends Module {
40
39
  /**
41
- * @param {string[]} requests list of requests to choose one
40
+ * @param {ExternalRequests} requests list of requests to choose one
42
41
  */
43
42
  constructor(requests) {
44
43
  super(WEBPACK_MODULE_TYPE_FALLBACK);
@@ -63,7 +62,7 @@ class FallbackModule extends Module {
63
62
 
64
63
  /**
65
64
  * @param {LibIdentOptions} options options
66
- * @returns {string | null} an identifier for library inclusion
65
+ * @returns {LibIdent | null} an identifier for library inclusion
67
66
  */
68
67
  libIdent(options) {
69
68
  return `${this.layer ? `(${this.layer})/` : ""}webpack/container/fallback/${
@@ -16,7 +16,6 @@ const HoistContainerReferences = require("./HoistContainerReferencesPlugin");
16
16
 
17
17
  /** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").ExternalsType} ExternalsType */
18
18
  /** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").ModuleFederationPluginOptions} ModuleFederationPluginOptions */
19
- /** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").Shared} Shared */
20
19
  /** @typedef {import("../Compiler")} Compiler */
21
20
  /** @typedef {import("../Dependency")} Dependency */
22
21
 
@@ -16,31 +16,31 @@ const makeSerializable = require("../util/makeSerializable");
16
16
  const FallbackDependency = require("./FallbackDependency");
17
17
  const RemoteToExternalDependency = require("./RemoteToExternalDependency");
18
18
 
19
- /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
20
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
21
- /** @typedef {import("../ChunkGroup")} ChunkGroup */
19
+ /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
22
20
  /** @typedef {import("../Compilation")} Compilation */
23
21
  /** @typedef {import("../Module").BuildCallback} BuildCallback */
24
22
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
25
23
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
26
24
  /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
25
+ /** @typedef {import("../Module").LibIdent} LibIdent */
26
+ /** @typedef {import("../Module").NameForCondition} NameForCondition */
27
27
  /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
28
28
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
29
29
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
30
30
  /** @typedef {import("../RequestShortener")} RequestShortener */
31
31
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
32
- /** @typedef {import("../WebpackError")} WebpackError */
33
32
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
34
33
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
35
- /** @typedef {import("../util/Hash")} Hash */
36
34
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
37
35
 
38
36
  const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
39
37
 
38
+ /** @typedef {string[]} ExternalRequests */
39
+
40
40
  class RemoteModule extends Module {
41
41
  /**
42
42
  * @param {string} request request string
43
- * @param {string[]} externalRequests list of external requests to containers
43
+ * @param {ExternalRequests} externalRequests list of external requests to containers
44
44
  * @param {string} internalRequest name of exposed module in container
45
45
  * @param {string} shareScope the used share scope name
46
46
  */
@@ -72,7 +72,7 @@ class RemoteModule extends Module {
72
72
 
73
73
  /**
74
74
  * @param {LibIdentOptions} options options
75
- * @returns {string | null} an identifier for library inclusion
75
+ * @returns {LibIdent | null} an identifier for library inclusion
76
76
  */
77
77
  libIdent(options) {
78
78
  return `${this.layer ? `(${this.layer})/` : ""}webpack/container/remote/${
@@ -131,7 +131,7 @@ class RemoteModule extends Module {
131
131
  }
132
132
 
133
133
  /**
134
- * @returns {string | null} absolute path which should be used for condition matching (usually the resource path)
134
+ * @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path)
135
135
  */
136
136
  nameForCondition() {
137
137
  return this.request;
@@ -28,9 +28,9 @@ class RemoteRuntimeModule extends RuntimeModule {
28
28
  const compilation = /** @type {Compilation} */ (this.compilation);
29
29
  const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
30
30
  const { runtimeTemplate, moduleGraph } = compilation;
31
- /** @type {Record<ChunkId, (string | number)[]>} */
31
+ /** @type {Record<ChunkId, ModuleId[]>} */
32
32
  const chunkToRemotesMapping = {};
33
- /** @type {Record<ModuleId, [string, string, string | number | null]>} */
33
+ /** @type {Record<ModuleId, [string, string, ModuleId]>} */
34
34
  const idToExternalAndNameMapping = {};
35
35
  for (const chunk of /** @type {Chunk} */ (
36
36
  this.chunk
@@ -24,6 +24,7 @@ const memoize = require("../util/memoize");
24
24
  /** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
25
25
  /** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
26
26
  /** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
27
+ /** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
27
28
  /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
28
29
  /** @typedef {import("../Dependency")} Dependency */
29
30
  /** @typedef {import("../DependencyTemplate").CssData} CssData */
@@ -124,7 +125,7 @@ class CssGenerator extends Generator {
124
125
  */
125
126
  const handleDependency = (dependency) => {
126
127
  const constructor =
127
- /** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
128
+ /** @type {DependencyConstructor} */
128
129
  (dependency.constructor);
129
130
  const template = generateContext.dependencyTemplates.get(constructor);
130
131
  if (!template) {
@@ -170,11 +171,7 @@ class CssGenerator extends Generator {
170
171
  usedIdentifiers.add(identifier);
171
172
  generateContext.concatenationScope.registerExport(name, identifier);
172
173
  source.add(
173
- `${
174
- generateContext.runtimeTemplate.supportsConst()
175
- ? "const"
176
- : "var"
177
- } ${identifier} = ${JSON.stringify(v)};\n`
174
+ `${generateContext.runtimeTemplate.renderConst()} ${identifier} = ${JSON.stringify(v)};\n`
178
175
  );
179
176
  }
180
177
  return source;