webpack 5.101.3 → 5.102.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 (339) 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 +37 -27
  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 +3 -2
  13. package/lib/CompatibilityPlugin.js +29 -12
  14. package/lib/Compilation.js +209 -196
  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 +25 -21
  21. package/lib/ContextModuleFactory.js +30 -11
  22. package/lib/ContextReplacementPlugin.js +38 -15
  23. package/lib/DefinePlugin.js +5 -9
  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 +2 -4
  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 +105 -90
  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 +42 -25
  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 +146 -89
  63. package/lib/NormalModuleFactory.js +132 -42
  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 +22 -12
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
  76. package/lib/SourceMapDevToolPlugin.js +11 -18
  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 +167 -0
  85. package/lib/asset/AssetBytesParser.js +37 -0
  86. package/lib/asset/AssetGenerator.js +22 -37
  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/cache/getLazyHashedEtag.js +1 -1
  98. package/lib/config/browserslistTargetHandler.js +77 -76
  99. package/lib/config/defaults.js +162 -23
  100. package/lib/config/normalization.js +18 -3
  101. package/lib/config/target.js +1 -1
  102. package/lib/container/ContainerEntryDependency.js +0 -1
  103. package/lib/container/ContainerEntryModule.js +3 -7
  104. package/lib/container/ContainerPlugin.js +1 -2
  105. package/lib/container/ContainerReferencePlugin.js +0 -1
  106. package/lib/container/FallbackDependency.js +2 -1
  107. package/lib/container/FallbackModule.js +6 -7
  108. package/lib/container/ModuleFederationPlugin.js +0 -1
  109. package/lib/container/RemoteModule.js +8 -8
  110. package/lib/container/RemoteRuntimeModule.js +2 -2
  111. package/lib/css/CssGenerator.js +3 -6
  112. package/lib/css/CssLoadingRuntimeModule.js +6 -9
  113. package/lib/css/CssModulesPlugin.js +13 -19
  114. package/lib/css/CssParser.js +3 -3
  115. package/lib/css/walkCssTokens.js +2 -2
  116. package/lib/debug/ProfilingPlugin.js +35 -8
  117. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
  118. package/lib/dependencies/AMDPlugin.js +2 -2
  119. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
  120. package/lib/dependencies/CachedConstDependency.js +0 -4
  121. package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
  122. package/lib/dependencies/CommonJsExportsDependency.js +2 -1
  123. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
  124. package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
  125. package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
  126. package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
  127. package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
  128. package/lib/dependencies/ConstDependency.js +2 -2
  129. package/lib/dependencies/ContextDependency.js +9 -4
  130. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  131. package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
  132. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
  133. package/lib/dependencies/ContextElementDependency.js +22 -11
  134. package/lib/dependencies/CssIcssImportDependency.js +0 -2
  135. package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
  136. package/lib/dependencies/CssImportDependency.js +0 -8
  137. package/lib/dependencies/CssLocalIdentifierDependency.js +4 -7
  138. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
  139. package/lib/dependencies/CssUrlDependency.js +0 -6
  140. package/lib/dependencies/ExportsInfoDependency.js +7 -9
  141. package/lib/dependencies/ExternalModuleDependency.js +0 -3
  142. package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
  143. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  144. package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
  145. package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
  146. package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
  147. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
  148. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
  149. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
  150. package/lib/dependencies/HarmonyImportDependency.js +33 -14
  151. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
  152. package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
  153. package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
  154. package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
  155. package/lib/dependencies/ImportContextDependency.js +13 -0
  156. package/lib/dependencies/ImportDependency.js +18 -6
  157. package/lib/dependencies/ImportEagerDependency.js +2 -3
  158. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
  159. package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
  160. package/lib/dependencies/ImportMetaPlugin.js +3 -2
  161. package/lib/dependencies/ImportParserPlugin.js +288 -45
  162. package/lib/dependencies/ImportWeakDependency.js +2 -3
  163. package/lib/dependencies/JsonExportsDependency.js +0 -1
  164. package/lib/dependencies/LoaderDependency.js +0 -3
  165. package/lib/dependencies/LoaderImportDependency.js +0 -3
  166. package/lib/dependencies/LoaderPlugin.js +11 -5
  167. package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
  168. package/lib/dependencies/ModuleDependency.js +3 -9
  169. package/lib/dependencies/NullDependency.js +2 -0
  170. package/lib/dependencies/ProvidedDependency.js +6 -8
  171. package/lib/dependencies/PureExpressionDependency.js +0 -1
  172. package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
  173. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
  174. package/lib/dependencies/RequireIncludeDependency.js +2 -2
  175. package/lib/dependencies/RequireResolveDependency.js +2 -2
  176. package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
  177. package/lib/dependencies/StaticExportsDependency.js +3 -5
  178. package/lib/dependencies/URLDependency.js +2 -7
  179. package/lib/dependencies/URLPlugin.js +1 -2
  180. package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
  181. package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
  182. package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
  183. package/lib/dependencies/WorkerDependency.js +2 -3
  184. package/lib/dependencies/WorkerPlugin.js +4 -12
  185. package/lib/dependencies/processExportInfo.js +2 -3
  186. package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
  187. package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
  188. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
  189. package/lib/hmr/LazyCompilationPlugin.js +6 -4
  190. package/lib/hmr/lazyCompilationBackend.js +13 -10
  191. package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
  192. package/lib/ids/HashedModuleIdsPlugin.js +5 -7
  193. package/lib/ids/IdHelpers.js +1 -1
  194. package/lib/ids/NamedChunkIdsPlugin.js +1 -6
  195. package/lib/ids/NamedModuleIdsPlugin.js +1 -5
  196. package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
  197. package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
  198. package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
  199. package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
  200. package/lib/ids/SyncModuleIdsPlugin.js +4 -3
  201. package/lib/index.js +8 -7
  202. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
  203. package/lib/javascript/BasicEvaluatedExpression.js +13 -6
  204. package/lib/javascript/ChunkFormatHelpers.js +1 -1
  205. package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
  206. package/lib/javascript/JavascriptGenerator.js +2 -3
  207. package/lib/javascript/JavascriptModulesPlugin.js +46 -24
  208. package/lib/javascript/JavascriptParser.js +120 -55
  209. package/lib/javascript/JavascriptParserHelpers.js +2 -2
  210. package/lib/javascript/StartupHelpers.js +2 -4
  211. package/lib/json/JsonData.js +1 -1
  212. package/lib/json/JsonGenerator.js +4 -5
  213. package/lib/json/JsonModulesPlugin.js +0 -3
  214. package/lib/json/JsonParser.js +4 -2
  215. package/lib/library/AbstractLibraryPlugin.js +2 -2
  216. package/lib/library/AmdLibraryPlugin.js +0 -1
  217. package/lib/library/AssignLibraryPlugin.js +23 -12
  218. package/lib/library/EnableLibraryPlugin.js +7 -11
  219. package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
  220. package/lib/library/JsonpLibraryPlugin.js +5 -2
  221. package/lib/library/ModuleLibraryPlugin.js +88 -43
  222. package/lib/library/SystemLibraryPlugin.js +15 -6
  223. package/lib/library/UmdLibraryPlugin.js +12 -18
  224. package/lib/logging/Logger.js +12 -10
  225. package/lib/logging/createConsoleLogger.js +15 -14
  226. package/lib/logging/truncateArgs.js +1 -1
  227. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  228. package/lib/node/NodeWatchFileSystem.js +4 -4
  229. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  230. package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
  231. package/lib/node/nodeConsole.js +2 -2
  232. package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
  233. package/lib/optimize/ConcatenatedModule.js +142 -100
  234. package/lib/optimize/InnerGraph.js +17 -11
  235. package/lib/optimize/InnerGraphPlugin.js +0 -3
  236. package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
  237. package/lib/optimize/RealContentHashPlugin.js +5 -3
  238. package/lib/optimize/RuntimeChunkPlugin.js +0 -1
  239. package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
  240. package/lib/optimize/SplitChunksPlugin.js +46 -40
  241. package/lib/performance/SizeLimitsPlugin.js +2 -1
  242. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
  243. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
  244. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
  245. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
  246. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
  247. package/lib/rules/BasicMatcherRulePlugin.js +0 -2
  248. package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
  249. package/lib/rules/RuleSetCompiler.js +8 -6
  250. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  251. package/lib/runtime/CompatRuntimeModule.js +0 -1
  252. package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
  253. package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
  254. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  255. package/lib/runtime/PublicPathRuntimeModule.js +2 -2
  256. package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
  257. package/lib/runtime/SystemContextRuntimeModule.js +0 -2
  258. package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
  259. package/lib/schemes/DataUriPlugin.js +2 -28
  260. package/lib/schemes/FileUriPlugin.js +5 -2
  261. package/lib/schemes/HttpUriPlugin.js +4 -2
  262. package/lib/schemes/VirtualUrlPlugin.js +11 -11
  263. package/lib/serialization/FileMiddleware.js +1 -1
  264. package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
  265. package/lib/serialization/ObjectMiddleware.js +31 -20
  266. package/lib/serialization/SerializerMiddleware.js +1 -3
  267. package/lib/serialization/types.js +1 -1
  268. package/lib/sharing/ConsumeSharedModule.js +3 -5
  269. package/lib/sharing/ConsumeSharedPlugin.js +2 -4
  270. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
  271. package/lib/sharing/ProvideSharedModule.js +3 -7
  272. package/lib/sharing/SharePlugin.js +0 -2
  273. package/lib/sharing/ShareRuntimeModule.js +4 -1
  274. package/lib/sharing/resolveMatchedConfigs.js +14 -6
  275. package/lib/sharing/utils.js +0 -6
  276. package/lib/stats/DefaultStatsFactoryPlugin.js +179 -95
  277. package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
  278. package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
  279. package/lib/stats/StatsFactory.js +14 -11
  280. package/lib/url/URLParserPlugin.js +2 -4
  281. package/lib/util/ArrayHelpers.js +4 -4
  282. package/lib/util/AsyncQueue.js +1 -0
  283. package/lib/util/Hash.js +35 -5
  284. package/lib/util/LazySet.js +2 -2
  285. package/lib/util/StackedCacheMap.js +0 -2
  286. package/lib/util/TupleSet.js +9 -4
  287. package/lib/util/URLAbsoluteSpecifier.js +0 -1
  288. package/lib/util/WeakTupleMap.js +1 -1
  289. package/lib/util/chainedImports.js +3 -1
  290. package/lib/util/cleverMerge.js +15 -18
  291. package/lib/util/comparators.js +2 -4
  292. package/lib/util/compileBooleanMatcher.js +11 -9
  293. package/lib/util/concatenate.js +1 -2
  294. package/lib/util/create-schema-validation.js +1 -2
  295. package/lib/util/createHash.js +85 -15
  296. package/lib/util/dataURL.js +39 -0
  297. package/lib/util/deprecation.js +29 -31
  298. package/lib/util/deterministicGrouping.js +34 -30
  299. package/lib/util/extractSourceMap.js +319 -0
  300. package/lib/util/findGraphRoots.js +15 -5
  301. package/lib/util/fs.js +29 -8
  302. package/lib/util/hash/BatchedHash.js +47 -8
  303. package/lib/util/hash/wasm-hash.js +53 -13
  304. package/lib/util/semver.js +9 -8
  305. package/lib/util/smartGrouping.js +41 -26
  306. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  307. package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
  308. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  309. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
  310. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
  311. package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
  312. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
  313. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
  314. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
  315. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
  316. package/lib/wasm-sync/WebAssemblyParser.js +1 -13
  317. package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
  318. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  319. package/lib/web/JsonpTemplatePlugin.js +0 -1
  320. package/lib/webpack.js +21 -8
  321. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
  322. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  323. package/package.json +21 -21
  324. package/schemas/WebpackOptions.check.js +1 -1
  325. package/schemas/WebpackOptions.json +93 -96
  326. package/schemas/plugins/BannerPlugin.check.js +1 -1
  327. package/schemas/plugins/BannerPlugin.json +4 -0
  328. package/schemas/plugins/IgnorePlugin.json +1 -1
  329. package/schemas/plugins/ProgressPlugin.json +1 -1
  330. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  331. package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
  332. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  333. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  334. package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
  335. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  336. package/types.d.ts +1699 -706
  337. package/SECURITY.md +0 -9
  338. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
  339. package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
@@ -8,7 +8,11 @@
8
8
  const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
9
9
  const CommentCompilationWarning = require("../CommentCompilationWarning");
10
10
  const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
11
- const { getImportAttributes } = require("../javascript/JavascriptParser");
11
+ const {
12
+ VariableInfo,
13
+ getImportAttributes
14
+ } = require("../javascript/JavascriptParser");
15
+ const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties");
12
16
  const ContextDependencyHelpers = require("./ContextDependencyHelpers");
13
17
  const ImportContextDependency = require("./ImportContextDependency");
14
18
  const ImportDependency = require("./ImportDependency");
@@ -19,10 +23,144 @@ const ImportWeakDependency = require("./ImportWeakDependency");
19
23
  /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
20
24
  /** @typedef {import("../ContextModule").ContextMode} ContextMode */
21
25
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
26
+ /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */
22
27
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
23
28
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
24
29
  /** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
25
30
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
31
+ /** @typedef {import("../javascript/JavascriptParser").ParserState} ParserState */
32
+ /** @typedef {import("../javascript/JavascriptParser").Members} Members */
33
+ /** @typedef {import("../javascript/JavascriptParser").MembersOptionals} MembersOptionals */
34
+ /** @typedef {import("../javascript/JavascriptParser").ArrowFunctionExpression} ArrowFunctionExpression */
35
+ /** @typedef {import("../javascript/JavascriptParser").FunctionExpression} FunctionExpression */
36
+ /** @typedef {import("../javascript/JavascriptParser").Identifier} Identifier */
37
+ /** @typedef {import("../javascript/JavascriptParser").ObjectPattern} ObjectPattern */
38
+ /** @typedef {import("../javascript/JavascriptParser").CallExpression} CallExpression */
39
+
40
+ /** @typedef {{ references: RawReferencedExports, expression: ImportExpression }} ImportSettings */
41
+ /** @typedef {WeakMap<ImportExpression, RawReferencedExports>} State */
42
+
43
+ /** @type {WeakMap<ParserState, State>} */
44
+ const parserStateMap = new WeakMap();
45
+ const dynamicImportTag = Symbol("import()");
46
+
47
+ /**
48
+ * @param {JavascriptParser} parser javascript parser
49
+ * @returns {State} import parser plugin state
50
+ */
51
+ function getState(parser) {
52
+ if (!parserStateMap.has(parser.state)) {
53
+ parserStateMap.set(parser.state, new WeakMap());
54
+ }
55
+ return /** @type {State} */ (parserStateMap.get(parser.state));
56
+ }
57
+
58
+ /**
59
+ * @param {JavascriptParser} parser javascript parser
60
+ * @param {ImportExpression} importCall import expression
61
+ * @param {string} variableName variable name
62
+ */
63
+ function tagDynamicImportReferenced(parser, importCall, variableName) {
64
+ const state = getState(parser);
65
+ /** @type {RawReferencedExports} */
66
+ const references = state.get(importCall) || [];
67
+ state.set(importCall, references);
68
+ parser.tagVariable(
69
+ variableName,
70
+ dynamicImportTag,
71
+ /** @type {ImportSettings} */ ({
72
+ references,
73
+ expression: importCall
74
+ })
75
+ );
76
+ }
77
+
78
+ /**
79
+ * @param {CallExpression} importThen import().then() call
80
+ * @returns {Identifier | ObjectPattern | undefined} the dynamic imported namespace obj
81
+ */
82
+ function getFulfilledCallbackNamespaceObj(importThen) {
83
+ const fulfilledCallback = importThen.arguments[0];
84
+ if (
85
+ fulfilledCallback &&
86
+ (fulfilledCallback.type === "ArrowFunctionExpression" ||
87
+ fulfilledCallback.type === "FunctionExpression") &&
88
+ fulfilledCallback.params[0] &&
89
+ (fulfilledCallback.params[0].type === "Identifier" ||
90
+ fulfilledCallback.params[0].type === "ObjectPattern")
91
+ ) {
92
+ return fulfilledCallback.params[0];
93
+ }
94
+ }
95
+
96
+ /**
97
+ * @param {JavascriptParser} parser javascript parser
98
+ * @param {ImportExpression} importCall import expression
99
+ * @param {ArrowFunctionExpression | FunctionExpression} fulfilledCallback the fulfilled callback
100
+ * @param {Identifier | ObjectPattern} namespaceObjArg the argument of namespace object=
101
+ */
102
+ function walkImportThenFulfilledCallback(
103
+ parser,
104
+ importCall,
105
+ fulfilledCallback,
106
+ namespaceObjArg
107
+ ) {
108
+ const arrow = fulfilledCallback.type === "ArrowFunctionExpression";
109
+ const wasTopLevel = parser.scope.topLevelScope;
110
+ parser.scope.topLevelScope = arrow ? (wasTopLevel ? "arrow" : false) : false;
111
+ const scopeParams = [...fulfilledCallback.params];
112
+
113
+ // Add function name in scope for recursive calls
114
+ if (!arrow && fulfilledCallback.id) {
115
+ scopeParams.push(fulfilledCallback.id);
116
+ }
117
+
118
+ parser.inFunctionScope(!arrow, scopeParams, () => {
119
+ if (namespaceObjArg.type === "Identifier") {
120
+ tagDynamicImportReferenced(parser, importCall, namespaceObjArg.name);
121
+ } else {
122
+ parser.enterDestructuringAssignment(namespaceObjArg, importCall);
123
+ const referencedPropertiesInDestructuring =
124
+ parser.destructuringAssignmentPropertiesFor(importCall);
125
+ if (referencedPropertiesInDestructuring) {
126
+ const state = getState(parser);
127
+ const references = /** @type {RawReferencedExports} */ (
128
+ state.get(importCall)
129
+ );
130
+ /** @type {RawReferencedExports} */
131
+ const refsInDestructuring = [];
132
+ traverseDestructuringAssignmentProperties(
133
+ referencedPropertiesInDestructuring,
134
+ (stack) => refsInDestructuring.push(stack.map((p) => p.id))
135
+ );
136
+ for (const ids of refsInDestructuring) {
137
+ references.push(ids);
138
+ }
139
+ }
140
+ }
141
+ for (const param of fulfilledCallback.params) {
142
+ parser.walkPattern(param);
143
+ }
144
+ if (fulfilledCallback.body.type === "BlockStatement") {
145
+ parser.detectMode(fulfilledCallback.body.body);
146
+ const prev = parser.prevStatement;
147
+ parser.preWalkStatement(fulfilledCallback.body);
148
+ parser.prevStatement = prev;
149
+ parser.walkStatement(fulfilledCallback.body);
150
+ } else {
151
+ parser.walkExpression(fulfilledCallback.body);
152
+ }
153
+ });
154
+ parser.scope.topLevelScope = wasTopLevel;
155
+ }
156
+
157
+ /**
158
+ * @template T
159
+ * @param {Iterable<T>} enumerable enumerable
160
+ * @returns {T[][]} array of array
161
+ */
162
+ const exportsFromEnumerable = (enumerable) =>
163
+ Array.from(enumerable, (e) => [e]);
26
164
 
27
165
  const PLUGIN_NAME = "ImportParserPlugin";
28
166
 
@@ -40,26 +178,94 @@ class ImportParserPlugin {
40
178
  */
41
179
  apply(parser) {
42
180
  /**
43
- * @template T
44
- * @param {Iterable<T>} enumerable enumerable
45
- * @returns {T[][]} array of array
181
+ * @param {Members} members members
182
+ * @param {MembersOptionals} membersOptionals members Optionals
183
+ * @returns {string[]} a non optional part
46
184
  */
47
- const exportsFromEnumerable = (enumerable) =>
48
- Array.from(enumerable, (e) => [e]);
185
+ function getNonOptionalPart(members, membersOptionals) {
186
+ let i = 0;
187
+ while (i < members.length && membersOptionals[i] === false) i++;
188
+ return i !== members.length ? members.slice(0, i) : members;
189
+ }
190
+
49
191
  parser.hooks.collectDestructuringAssignmentProperties.tap(
50
192
  PLUGIN_NAME,
51
193
  (expr) => {
52
194
  if (expr.type === "ImportExpression") return true;
195
+ const nameInfo = parser.getNameForExpression(expr);
196
+ if (
197
+ nameInfo &&
198
+ nameInfo.rootInfo instanceof VariableInfo &&
199
+ nameInfo.rootInfo.name &&
200
+ parser.getTagData(nameInfo.rootInfo.name, dynamicImportTag)
201
+ ) {
202
+ return true;
203
+ }
53
204
  }
54
205
  );
55
- parser.hooks.importCall.tap(PLUGIN_NAME, (expr) => {
206
+ parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl) => {
207
+ if (
208
+ decl.init &&
209
+ decl.init.type === "AwaitExpression" &&
210
+ decl.init.argument.type === "ImportExpression" &&
211
+ decl.id.type === "Identifier"
212
+ ) {
213
+ parser.defineVariable(decl.id.name);
214
+ tagDynamicImportReferenced(parser, decl.init.argument, decl.id.name);
215
+ }
216
+ });
217
+ parser.hooks.expression.for(dynamicImportTag).tap(PLUGIN_NAME, (expr) => {
218
+ const settings = /** @type {ImportSettings} */ (parser.currentTagData);
219
+ const referencedPropertiesInDestructuring =
220
+ parser.destructuringAssignmentPropertiesFor(expr);
221
+ if (referencedPropertiesInDestructuring) {
222
+ /** @type {RawReferencedExports} */
223
+ const refsInDestructuring = [];
224
+ traverseDestructuringAssignmentProperties(
225
+ referencedPropertiesInDestructuring,
226
+ (stack) => refsInDestructuring.push(stack.map((p) => p.id))
227
+ );
228
+ for (const ids of refsInDestructuring) {
229
+ settings.references.push(ids);
230
+ }
231
+ } else {
232
+ settings.references.push([]);
233
+ }
234
+ return true;
235
+ });
236
+ parser.hooks.expressionMemberChain
237
+ .for(dynamicImportTag)
238
+ .tap(PLUGIN_NAME, (_expression, members, membersOptionals) => {
239
+ const settings = /** @type {ImportSettings} */ (parser.currentTagData);
240
+ const ids = getNonOptionalPart(members, membersOptionals);
241
+ settings.references.push(ids);
242
+ return true;
243
+ });
244
+ parser.hooks.callMemberChain
245
+ .for(dynamicImportTag)
246
+ .tap(PLUGIN_NAME, (expression, members, membersOptionals) => {
247
+ const { arguments: args } = expression;
248
+ const settings = /** @type {ImportSettings} */ (parser.currentTagData);
249
+ let ids = getNonOptionalPart(members, membersOptionals);
250
+ const directImport = members.length === 0;
251
+ if (
252
+ !directImport &&
253
+ (this.options.strictThisContextOnImports || ids.length > 1)
254
+ ) {
255
+ ids = ids.slice(0, -1);
256
+ }
257
+ settings.references.push(ids);
258
+ if (args) parser.walkExpressions(args);
259
+ return true;
260
+ });
261
+ parser.hooks.importCall.tap(PLUGIN_NAME, (expr, importThen) => {
56
262
  const param = parser.evaluateExpression(expr.source);
57
263
 
58
264
  let chunkName = null;
59
265
  let mode = /** @type {ContextMode} */ (this.options.dynamicImportMode);
60
266
  let include = null;
61
267
  let exclude = null;
62
- /** @type {string[][] | null} */
268
+ /** @type {RawReferencedExports | null} */
63
269
  let exports = null;
64
270
  /** @type {RawChunkGroupOptions} */
65
271
  const groupOptions = {};
@@ -245,7 +451,7 @@ class ImportParserPlugin {
245
451
  !(
246
452
  typeof importOptions.webpackExports === "string" ||
247
453
  (Array.isArray(importOptions.webpackExports) &&
248
- /** @type {string[]} */ (importOptions.webpackExports).every(
454
+ importOptions.webpackExports.every(
249
455
  (item) => typeof item === "string"
250
456
  ))
251
457
  )
@@ -281,19 +487,42 @@ class ImportParserPlugin {
281
487
 
282
488
  const referencedPropertiesInDestructuring =
283
489
  parser.destructuringAssignmentPropertiesFor(expr);
284
- if (referencedPropertiesInDestructuring) {
490
+ const state = getState(parser);
491
+ const referencedPropertiesInMember = state.get(expr);
492
+ const fulfilledNamespaceObj =
493
+ importThen && getFulfilledCallbackNamespaceObj(importThen);
494
+ if (
495
+ referencedPropertiesInDestructuring ||
496
+ referencedPropertiesInMember ||
497
+ fulfilledNamespaceObj
498
+ ) {
285
499
  if (exports) {
286
500
  parser.state.module.addWarning(
287
501
  new UnsupportedFeatureWarning(
288
- "`webpackExports` could not be used with destructuring assignment.",
502
+ "You don't need `webpackExports` if the usage of dynamic import is statically analyse-able. You can safely remove the `webpackExports` magic comment.",
289
503
  /** @type {DependencyLocation} */ (expr.loc)
290
504
  )
291
505
  );
292
506
  }
293
507
 
294
- exports = exportsFromEnumerable(
295
- [...referencedPropertiesInDestructuring].map(({ id }) => id)
296
- );
508
+ if (referencedPropertiesInDestructuring) {
509
+ /** @type {RawReferencedExports} */
510
+ const refsInDestructuring = [];
511
+ traverseDestructuringAssignmentProperties(
512
+ referencedPropertiesInDestructuring,
513
+ (stack) => refsInDestructuring.push(stack.map((p) => p.id))
514
+ );
515
+
516
+ exports = refsInDestructuring;
517
+ } else if (referencedPropertiesInMember) {
518
+ exports = referencedPropertiesInMember;
519
+ } else {
520
+ /** @type {RawReferencedExports} */
521
+ const references = [];
522
+ state.set(expr, references);
523
+
524
+ exports = references;
525
+ }
297
526
  }
298
527
 
299
528
  if (param.isString()) {
@@ -335,39 +564,53 @@ class ImportParserPlugin {
335
564
  depBlock.addDependency(dep);
336
565
  parser.state.current.addBlock(depBlock);
337
566
  }
338
- return true;
567
+ } else {
568
+ if (mode === "weak") {
569
+ mode = "async-weak";
570
+ }
571
+ const dep = ContextDependencyHelpers.create(
572
+ ImportContextDependency,
573
+ /** @type {Range} */ (expr.range),
574
+ param,
575
+ expr,
576
+ this.options,
577
+ {
578
+ chunkName,
579
+ groupOptions,
580
+ include,
581
+ exclude,
582
+ mode,
583
+ namespaceObject:
584
+ /** @type {BuildMeta} */
585
+ (parser.state.module.buildMeta).strictHarmonyModule
586
+ ? "strict"
587
+ : true,
588
+ typePrefix: "import()",
589
+ category: "esm",
590
+ referencedExports: exports,
591
+ attributes: getImportAttributes(expr)
592
+ },
593
+ parser
594
+ );
595
+ if (!dep) return;
596
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
597
+ dep.optional = Boolean(parser.scope.inTry);
598
+ parser.state.current.addDependency(dep);
339
599
  }
340
- if (mode === "weak") {
341
- mode = "async-weak";
600
+
601
+ if (fulfilledNamespaceObj) {
602
+ walkImportThenFulfilledCallback(
603
+ parser,
604
+ expr,
605
+ /** @type {ArrowFunctionExpression | FunctionExpression} */
606
+ (importThen.arguments[0]),
607
+ fulfilledNamespaceObj
608
+ );
609
+ parser.walkExpressions(importThen.arguments.slice(1));
610
+ } else if (importThen) {
611
+ parser.walkExpressions(importThen.arguments);
342
612
  }
343
- const dep = ContextDependencyHelpers.create(
344
- ImportContextDependency,
345
- /** @type {Range} */ (expr.range),
346
- param,
347
- expr,
348
- this.options,
349
- {
350
- chunkName,
351
- groupOptions,
352
- include,
353
- exclude,
354
- mode,
355
- namespaceObject:
356
- /** @type {BuildMeta} */
357
- (parser.state.module.buildMeta).strictHarmonyModule
358
- ? "strict"
359
- : true,
360
- typePrefix: "import()",
361
- category: "esm",
362
- referencedExports: exports,
363
- attributes: getImportAttributes(expr)
364
- },
365
- parser
366
- );
367
- if (!dep) return;
368
- dep.loc = /** @type {DependencyLocation} */ (expr.loc);
369
- dep.optional = Boolean(parser.scope.inTry);
370
- parser.state.current.addDependency(dep);
613
+
371
614
  return true;
372
615
  });
373
616
  }
@@ -10,19 +10,18 @@ const ImportDependency = require("./ImportDependency");
10
10
 
11
11
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12
12
  /** @typedef {import("../Dependency")} Dependency */
13
- /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
14
13
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
15
14
  /** @typedef {import("../Module")} Module */
16
15
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
17
- /** @typedef {import("../ModuleGraph")} ModuleGraph */
18
16
  /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
19
17
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
18
+ /** @typedef {ImportDependency.RawReferencedExports} RawReferencedExports */
20
19
 
21
20
  class ImportWeakDependency extends ImportDependency {
22
21
  /**
23
22
  * @param {string} request the request
24
23
  * @param {Range} range expression range
25
- * @param {(string[][] | null)=} referencedExports list of referenced exports
24
+ * @param {RawReferencedExports | null=} referencedExports list of referenced exports
26
25
  * @param {ImportAttributes=} attributes import attributes
27
26
  */
28
27
  constructor(request, range, referencedExports, attributes) {
@@ -8,7 +8,6 @@
8
8
  const makeSerializable = require("../util/makeSerializable");
9
9
  const NullDependency = require("./NullDependency");
10
10
 
11
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
12
11
  /** @typedef {import("../Dependency").ExportSpec} ExportSpec */
13
12
  /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
14
13
  /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
@@ -9,9 +9,6 @@ const ModuleDependency = require("./ModuleDependency");
9
9
 
10
10
  /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
11
11
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
12
- /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
13
- /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
14
- /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
15
12
 
16
13
  class LoaderDependency extends ModuleDependency {
17
14
  /**
@@ -9,9 +9,6 @@ const ModuleDependency = require("./ModuleDependency");
9
9
 
10
10
  /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
11
11
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
12
- /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
13
- /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
14
- /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
15
12
 
16
13
  class LoaderImportDependency extends ModuleDependency {
17
14
  /**
@@ -10,18 +10,18 @@ const LazySet = require("../util/LazySet");
10
10
  const LoaderDependency = require("./LoaderDependency");
11
11
  const LoaderImportDependency = require("./LoaderImportDependency");
12
12
 
13
- /** @typedef {import("../../declarations/LoaderContext").LoaderPluginLoaderContext} LoaderPluginLoaderContext */
14
- /** @typedef {import("../Compilation").DepConstructor} DepConstructor */
13
+ /** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
15
14
  /** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */
16
15
  /** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */
17
16
  /** @typedef {import("../Compiler")} Compiler */
18
- /** @typedef {import("../Module")} Module */
19
17
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
18
+ /** @typedef {import("../Module").FileSystemDependencies} FileSystemDependencies */
20
19
 
21
20
  /**
22
21
  * @callback ImportModuleCallback
23
22
  * @param {(Error | null)=} err error object
24
23
  * @param {ExecuteModuleExports=} exports exports of the evaluated module
24
+ * @returns {void}
25
25
  */
26
26
 
27
27
  /**
@@ -65,7 +65,8 @@ class LoaderPlugin {
65
65
  name: request
66
66
  };
67
67
  const factory = compilation.dependencyFactories.get(
68
- /** @type {DepConstructor} */ (dep.constructor)
68
+ /** @type {DependencyConstructor} */
69
+ (dep.constructor)
69
70
  );
70
71
  if (factory === undefined) {
71
72
  return callback(
@@ -125,9 +126,13 @@ class LoaderPlugin {
125
126
  map = moduleSource.map();
126
127
  source = moduleSource.source();
127
128
  }
129
+ /** @type {FileSystemDependencies} */
128
130
  const fileDependencies = new LazySet();
131
+ /** @type {FileSystemDependencies} */
129
132
  const contextDependencies = new LazySet();
133
+ /** @type {FileSystemDependencies} */
130
134
  const missingDependencies = new LazySet();
135
+ /** @type {FileSystemDependencies} */
131
136
  const buildDependencies = new LazySet();
132
137
  referencedModule.addCacheDependencies(
133
138
  fileDependencies,
@@ -165,7 +170,8 @@ class LoaderPlugin {
165
170
  name: request
166
171
  };
167
172
  const factory = compilation.dependencyFactories.get(
168
- /** @type {DepConstructor} */ (dep.constructor)
173
+ /** @type {DependencyConstructor} */
174
+ (dep.constructor)
169
175
  );
170
176
  if (factory === undefined) {
171
177
  return callback(
@@ -12,11 +12,9 @@ const makeSerializable = require("../util/makeSerializable");
12
12
  const NullDependency = require("./NullDependency");
13
13
 
14
14
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
15
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
16
- /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
15
+ /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
17
16
  /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
18
17
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
19
- /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
20
18
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
21
19
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
22
20
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
@@ -57,7 +55,7 @@ class ModuleDecoratorDependency extends NullDependency {
57
55
  * Returns list of exports referenced by this dependency
58
56
  * @param {ModuleGraph} moduleGraph module graph
59
57
  * @param {RuntimeSpec} runtime the runtime for which the module is analysed
60
- * @returns {(string[] | ReferencedExport)[]} referenced exports
58
+ * @returns {ReferencedExports} referenced exports
61
59
  */
62
60
  getReferencedExports(moduleGraph, runtime) {
63
61
  return this.allowExportsAccess
@@ -11,6 +11,7 @@ const DependencyTemplate = require("../DependencyTemplate");
11
11
  /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
12
12
  /** @typedef {import("../Module")} Module */
13
13
  /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
14
+ /** @typedef {import("../javascript/JavascriptParser").Range} Range */
14
15
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
15
16
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
16
17
 
@@ -22,11 +23,8 @@ class ModuleDependency extends Dependency {
22
23
  super();
23
24
  this.request = request;
24
25
  this.userRequest = request;
26
+ /** @type {Range | undefined} */
25
27
  this.range = undefined;
26
- // TODO move it to subclasses and rename
27
- // assertions must be serialized by subclasses that use it
28
- /** @type {ImportAttributes | undefined} */
29
- this.assertions = undefined;
30
28
  this._context = undefined;
31
29
  }
32
30
 
@@ -41,11 +39,7 @@ class ModuleDependency extends Dependency {
41
39
  * @returns {string | null} an identifier to merge equal requests
42
40
  */
43
41
  getResourceIdentifier() {
44
- let str = `context${this._context || ""}|module${this.request}`;
45
- if (this.assertions !== undefined) {
46
- str += JSON.stringify(this.assertions);
47
- }
48
- return str;
42
+ return `context${this._context || ""}|module${this.request}`;
49
43
  }
50
44
 
51
45
  /**
@@ -12,6 +12,8 @@ const DependencyTemplate = require("../DependencyTemplate");
12
12
  /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
13
13
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
14
14
 
15
+ /** @typedef {string[]} RawRuntimeRequirements */
16
+
15
17
  class NullDependency extends Dependency {
16
18
  get type() {
17
19
  return "null";
@@ -11,14 +11,12 @@ const makeSerializable = require("../util/makeSerializable");
11
11
  const ModuleDependency = require("./ModuleDependency");
12
12
 
13
13
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
14
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
15
- /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
14
+ /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
16
15
  /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
17
16
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
18
- /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
19
17
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
20
18
  /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
21
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
19
+ /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
22
20
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
23
21
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
24
22
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
@@ -26,7 +24,7 @@ const ModuleDependency = require("./ModuleDependency");
26
24
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
27
25
 
28
26
  /**
29
- * @param {string[]|null} path the property path array
27
+ * @param {string[] | null} path the property path array
30
28
  * @returns {string} the converted path
31
29
  */
32
30
  const pathToString = (path) =>
@@ -38,7 +36,7 @@ class ProvidedDependency extends ModuleDependency {
38
36
  /**
39
37
  * @param {string} request request
40
38
  * @param {string} identifier identifier
41
- * @param {string[]} ids ids
39
+ * @param {ExportInfoName[]} ids ids
42
40
  * @param {Range} range range
43
41
  */
44
42
  constructor(request, identifier, ids, range) {
@@ -61,7 +59,7 @@ class ProvidedDependency extends ModuleDependency {
61
59
  * Returns list of exports referenced by this dependency
62
60
  * @param {ModuleGraph} moduleGraph module graph
63
61
  * @param {RuntimeSpec} runtime the runtime for which the module is analysed
64
- * @returns {(string[] | ReferencedExport)[]} referenced exports
62
+ * @returns {ReferencedExports} referenced exports
65
63
  */
66
64
  getReferencedExports(moduleGraph, runtime) {
67
65
  const ids = this.ids;
@@ -142,7 +140,7 @@ class ProvidedDependencyTemplate extends ModuleDependency.Template {
142
140
  chunkGraph,
143
141
  request: dep.request,
144
142
  runtimeRequirements
145
- })}${pathToString(/** @type {string[]} */ (usedName))};\n`,
143
+ })}${pathToString(/** @type {string[] | null} */ (usedName))};\n`,
146
144
  InitFragment.STAGE_PROVIDES,
147
145
  1,
148
146
  `provided ${dep.identifier}`
@@ -11,7 +11,6 @@ const { filterRuntime, runtimeToString } = require("../util/runtime");
11
11
  const NullDependency = require("./NullDependency");
12
12
 
13
13
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
14
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
15
14
  /** @typedef {import("../Dependency")} Dependency */
16
15
  /** @typedef {import("../Dependency").RuntimeSpec} RuntimeSpec */
17
16
  /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
@@ -9,7 +9,6 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
9
9
  const makeSerializable = require("../util/makeSerializable");
10
10
 
11
11
  /** @typedef {import("../AsyncDependenciesBlock").GroupOptions} GroupOptions */
12
- /** @typedef {import("../ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
13
12
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
14
13
 
15
14
  class RequireEnsureDependenciesBlock extends AsyncDependenciesBlock {
@@ -11,7 +11,6 @@ const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
11
11
  const getFunctionExpression = require("./getFunctionExpression");
12
12
 
13
13
  /** @typedef {import("../AsyncDependenciesBlock").GroupOptions} GroupOptions */
14
- /** @typedef {import("../ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
15
14
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
16
15
  /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
17
16
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
@@ -86,7 +85,7 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
86
85
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
87
86
  depBlock.addDependency(dep);
88
87
  const old = parser.state.current;
89
- parser.state.current = /** @type {TODO} */ (depBlock);
88
+ parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock);
90
89
  try {
91
90
  let failed = false;
92
91
  parser.inScope([], () => {