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
@@ -24,7 +24,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
24
24
  /** @typedef {import("estree").BlockStatement} BlockStatement */
25
25
  /** @typedef {import("estree").SequenceExpression} SequenceExpression */
26
26
  /** @typedef {import("estree").CallExpression} CallExpression */
27
- /** @typedef {import("estree").BaseCallExpression} BaseCallExpression */
28
27
  /** @typedef {import("estree").StaticBlock} StaticBlock */
29
28
  /** @typedef {import("estree").ClassDeclaration} ClassDeclaration */
30
29
  /** @typedef {import("estree").ForStatement} ForStatement */
@@ -36,6 +35,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
36
35
  /** @typedef {import("estree").PrivateIdentifier} PrivateIdentifier */
37
36
  /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
38
37
  /** @typedef {import("estree").Expression} Expression */
38
+ /** @typedef {import("estree").ImportAttribute} ImportAttribute */
39
+ /** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
39
40
  /** @typedef {import("estree").Identifier} Identifier */
40
41
  /** @typedef {import("estree").VariableDeclaration} VariableDeclaration */
41
42
  /** @typedef {import("estree").IfStatement} IfStatement */
@@ -48,7 +49,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
48
49
  /** @typedef {import("estree").MetaProperty} MetaProperty */
49
50
  /** @typedef {import("estree").Property} Property */
50
51
  /** @typedef {import("estree").AssignmentPattern} AssignmentPattern */
51
- /** @typedef {import("estree").ChainElement} ChainElement */
52
52
  /** @typedef {import("estree").Pattern} Pattern */
53
53
  /** @typedef {import("estree").UpdateExpression} UpdateExpression */
54
54
  /** @typedef {import("estree").ObjectExpression} ObjectExpression */
@@ -74,6 +74,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
74
74
  /** @typedef {import("estree").WhileStatement} WhileStatement */
75
75
  /** @typedef {import("estree").ArrowFunctionExpression} ArrowFunctionExpression */
76
76
  /** @typedef {import("estree").ExpressionStatement} ExpressionStatement */
77
+ /** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
78
+ /** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
77
79
  /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
78
80
  /** @typedef {import("estree").DoWhileStatement} DoWhileStatement */
79
81
  /** @typedef {import("estree").TryStatement} TryStatement */
@@ -83,10 +85,9 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
83
85
  /** @typedef {import("estree").Statement} Statement */
84
86
  /** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
85
87
  /** @typedef {import("estree").Super} Super */
86
- /** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
87
88
  /** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpression */
88
89
  /** @typedef {import("estree").TemplateLiteral} TemplateLiteral */
89
- /** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
90
+ /** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
90
91
  /** @typedef {import("estree").MaybeNamedFunctionDeclaration} MaybeNamedFunctionDeclaration */
91
92
  /** @typedef {import("estree").MaybeNamedClassDeclaration} MaybeNamedClassDeclaration */
92
93
  /**
@@ -95,19 +96,17 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
95
96
  */
96
97
  /** @typedef {import("../Parser").ParserState} ParserState */
97
98
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
98
- /** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[] }} GetInfoResult */
99
+
100
+ /** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges }} GetInfoResult */
99
101
  /** @typedef {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} StatementPathItem */
100
102
  /** @typedef {(ident: string) => void} OnIdentString */
101
103
  /** @typedef {(ident: string, identifier: Identifier) => void} OnIdent */
102
104
  /** @typedef {StatementPathItem[]} StatementPath */
103
105
 
106
+ /** @typedef {Set<DestructuringAssignmentProperty>} DestructuringAssignmentProperties */
107
+
104
108
  // TODO remove cast when @types/estree has been updated to import assertions
105
- /** @typedef {import("estree").BaseNode & { type: "ImportAttribute", key: Identifier | Literal, value: Literal }} ImportAttribute */
106
- /** @typedef {import("estree").ImportDeclaration & { attributes?: Array<ImportAttribute>, phase?: "defer" }} ImportDeclaration */
107
- /** @typedef {import("estree").ExportNamedDeclaration & { attributes?: Array<ImportAttribute> }} ExportNamedDeclaration */
108
- /** @typedef {import("estree").ExportAllDeclaration & { attributes?: Array<ImportAttribute> }} ExportAllDeclaration */
109
- /** @typedef {import("estree").ImportExpression & { options?: Expression | null, phase?: "defer" }} ImportExpression */
110
- /** @typedef {ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration} ModuleDeclaration */
109
+ /** @typedef {import("estree").ImportExpression & { phase?: "defer" }} ImportExpression */
111
110
 
112
111
  /** @type {string[]} */
113
112
  const EMPTY_ARRAY = [];
@@ -301,7 +300,15 @@ class VariableInfo {
301
300
  /** @typedef {Omit<AcornOptions, "sourceType" | "ecmaVersion"> & { sourceType: "module" | "script" | "auto", ecmaVersion?: AcornOptions["ecmaVersion"] }} ParseOptions */
302
301
 
303
302
  /** @typedef {symbol} Tag */
304
- /** @typedef {Record<string, TODO>} TagData */
303
+
304
+ /** @typedef {import("../dependencies/HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
305
+ /** @typedef {import("../dependencies/ImportParserPlugin").ImportSettings} ImportSettings */
306
+ /** @typedef {import("../dependencies/CommonJsImportsParserPlugin").CommonJsImportSettings} CommonJsImportSettings */
307
+ /** @typedef {import("../CompatibilityPlugin").CompatibilitySettings} CompatibilitySettings */
308
+ /** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
309
+
310
+ /** @typedef {HarmonySettings | ImportSettings | CommonJsImportSettings | TopLevelSymbol | CompatibilitySettings} KnownTagData */
311
+ /** @typedef {KnownTagData | Record<string, EXPECTED_ANY>} TagData */
305
312
 
306
313
  /**
307
314
  * @typedef {object} TagInfo
@@ -310,6 +317,11 @@ class VariableInfo {
310
317
  * @property {TagInfo | undefined} next
311
318
  */
312
319
 
320
+ /** @typedef {string[]} CalleeMembers */
321
+ /** @typedef {string[]} Members */
322
+ /** @typedef {boolean[]} MembersOptionals */
323
+ /** @typedef {Range[]} MemberRanges */
324
+
313
325
  const SCOPE_INFO_TERMINATED_RETURN = 1;
314
326
  const SCOPE_INFO_TERMINATED_THROW = 2;
315
327
 
@@ -330,7 +342,8 @@ const SCOPE_INFO_TERMINATED_THROW = 2;
330
342
  /**
331
343
  * @typedef {object} DestructuringAssignmentProperty
332
344
  * @property {string} id
333
- * @property {Range | undefined=} range
345
+ * @property {Range} range
346
+ * @property {Set<DestructuringAssignmentProperty> | undefined=} pattern
334
347
  * @property {boolean | string} shorthand
335
348
  */
336
349
 
@@ -359,7 +372,7 @@ const joinRanges = (startRange, endRange) => {
359
372
  * Helper function used to generate a string representation of a
360
373
  * [member expression](https://github.com/estree/estree/blob/master/es5.md#memberexpression).
361
374
  * @param {string} object object to name
362
- * @param {string[]} membersReversed reversed list of members
375
+ * @param {Members} membersReversed reversed list of members
363
376
  * @returns {string} member expression as a string
364
377
  * @example
365
378
  * ```js
@@ -532,20 +545,20 @@ class JavascriptParser extends Parser {
532
545
  rename: new HookMap(() => new SyncBailHook(["initExpression"])),
533
546
  /** @type {HookMap<SyncBailHook<[AssignmentExpression], boolean | void>>} */
534
547
  assign: new HookMap(() => new SyncBailHook(["expression"])),
535
- /** @type {HookMap<SyncBailHook<[AssignmentExpression, string[]], boolean | void>>} */
548
+ /** @type {HookMap<SyncBailHook<[AssignmentExpression, Members], boolean | void>>} */
536
549
  assignMemberChain: new HookMap(
537
550
  () => new SyncBailHook(["expression", "members"])
538
551
  ),
539
552
  /** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
540
553
  typeof: new HookMap(() => new SyncBailHook(["expression"])),
541
- /** @type {SyncBailHook<[ImportExpression], boolean | void>} */
542
- importCall: new SyncBailHook(["expression"]),
554
+ /** @type {SyncBailHook<[ImportExpression, CallExpression?], boolean | void>} */
555
+ importCall: new SyncBailHook(["expression", "importThen"]),
543
556
  /** @type {SyncBailHook<[Expression | ForOfStatement], boolean | void>} */
544
557
  topLevelAwait: new SyncBailHook(["expression"]),
545
558
  /** @type {HookMap<SyncBailHook<[CallExpression], boolean | void>>} */
546
559
  call: new HookMap(() => new SyncBailHook(["expression"])),
547
560
  /** Something like "a.b()" */
548
- /** @type {HookMap<SyncBailHook<[CallExpression, string[], boolean[], Range[]], boolean | void>>} */
561
+ /** @type {HookMap<SyncBailHook<[CallExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
549
562
  callMemberChain: new HookMap(
550
563
  () =>
551
564
  new SyncBailHook([
@@ -556,7 +569,7 @@ class JavascriptParser extends Parser {
556
569
  ])
557
570
  ),
558
571
  /** Something like "a.b().c.d" */
559
- /** @type {HookMap<SyncBailHook<[Expression, string[], CallExpression, string[], Range[]], boolean | void>>} */
572
+ /** @type {HookMap<SyncBailHook<[Expression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
560
573
  memberChainOfCallMemberChain: new HookMap(
561
574
  () =>
562
575
  new SyncBailHook([
@@ -568,7 +581,7 @@ class JavascriptParser extends Parser {
568
581
  ])
569
582
  ),
570
583
  /** Something like "a.b().c.d()"" */
571
- /** @type {HookMap<SyncBailHook<[CallExpression, string[], CallExpression, string[], Range[]], boolean | void>>} */
584
+ /** @type {HookMap<SyncBailHook<[CallExpression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
572
585
  callMemberChainOfCallMemberChain: new HookMap(
573
586
  () =>
574
587
  new SyncBailHook([
@@ -587,7 +600,7 @@ class JavascriptParser extends Parser {
587
600
  binaryExpression: new SyncBailHook(["binaryExpression"]),
588
601
  /** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
589
602
  expression: new HookMap(() => new SyncBailHook(["expression"])),
590
- /** @type {HookMap<SyncBailHook<[MemberExpression, string[], boolean[], Range[]], boolean | void>>} */
603
+ /** @type {HookMap<SyncBailHook<[MemberExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
591
604
  expressionMemberChain: new HookMap(
592
605
  () =>
593
606
  new SyncBailHook([
@@ -597,7 +610,7 @@ class JavascriptParser extends Parser {
597
610
  "memberRanges"
598
611
  ])
599
612
  ),
600
- /** @type {HookMap<SyncBailHook<[MemberExpression, string[]], boolean | void>>} */
613
+ /** @type {HookMap<SyncBailHook<[MemberExpression, Members], boolean | void>>} */
601
614
  unhandledExpressionMemberChain: new HookMap(
602
615
  () => new SyncBailHook(["expression", "members"])
603
616
  ),
@@ -616,9 +629,9 @@ class JavascriptParser extends Parser {
616
629
  });
617
630
  this.sourceType = sourceType;
618
631
  /** @type {ScopeInfo} */
619
- this.scope = /** @type {TODO} */ (undefined);
632
+ this.scope = /** @type {EXPECTED_ANY} */ (undefined);
620
633
  /** @type {ParserState} */
621
- this.state = /** @type {TODO} */ (undefined);
634
+ this.state = /** @type {EXPECTED_ANY} */ (undefined);
622
635
  /** @type {Comment[] | undefined} */
623
636
  this.comments = undefined;
624
637
  /** @type {Set<number> | undefined} */
@@ -627,7 +640,7 @@ class JavascriptParser extends Parser {
627
640
  this.statementPath = undefined;
628
641
  /** @type {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | undefined} */
629
642
  this.prevStatement = undefined;
630
- /** @type {WeakMap<Expression, Set<DestructuringAssignmentProperty>> | undefined} */
643
+ /** @type {WeakMap<Expression, DestructuringAssignmentProperties> | undefined} */
631
644
  this.destructuringAssignmentProperties = undefined;
632
645
  /** @type {TagData | undefined} */
633
646
  this.currentTagData = undefined;
@@ -1891,7 +1904,7 @@ class JavascriptParser extends Parser {
1891
1904
 
1892
1905
  /**
1893
1906
  * @param {Expression} node node
1894
- * @returns {Set<DestructuringAssignmentProperty> | undefined} destructured identifiers
1907
+ * @returns {DestructuringAssignmentProperties | undefined} destructured identifiers
1895
1908
  */
1896
1909
  destructuringAssignmentPropertiesFor(node) {
1897
1910
  if (!this.destructuringAssignmentProperties) return;
@@ -2644,7 +2657,7 @@ class JavascriptParser extends Parser {
2644
2657
  // check multiple assignments
2645
2658
  if (this.destructuringAssignmentProperties.has(destructuring)) {
2646
2659
  const set =
2647
- /** @type {Set<DestructuringAssignmentProperty>} */
2660
+ /** @type {DestructuringAssignmentProperties} */
2648
2661
  (this.destructuringAssignmentProperties.get(destructuring));
2649
2662
  for (const id of keys) set.add(id);
2650
2663
  } else {
@@ -2829,11 +2842,16 @@ class JavascriptParser extends Parser {
2829
2842
  * @param {ExportDefaultDeclaration} statement statement
2830
2843
  */
2831
2844
  blockPreWalkExportDefaultDeclaration(statement) {
2832
- const prev = this.prevStatement;
2845
+ if (
2846
+ statement.declaration.type === "FunctionDeclaration" ||
2847
+ statement.declaration.type === "ClassDeclaration"
2848
+ ) {
2849
+ const prev = this.prevStatement;
2833
2850
 
2834
- this.preWalkStatement(/** @type {TODO} */ (statement.declaration));
2835
- this.prevStatement = prev;
2836
- this.blockPreWalkStatement(/** @type {TODO} */ (statement.declaration));
2851
+ this.preWalkStatement(statement.declaration);
2852
+ this.prevStatement = prev;
2853
+ this.blockPreWalkStatement(statement.declaration);
2854
+ }
2837
2855
 
2838
2856
  if (
2839
2857
  /** @type {MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} */
@@ -2885,15 +2903,7 @@ class JavascriptParser extends Parser {
2885
2903
  this.walkExpression(statement.declaration);
2886
2904
  }
2887
2905
 
2888
- if (!this.hooks.exportExpression.call(statement, statement.declaration)) {
2889
- this.hooks.exportSpecifier.call(
2890
- statement,
2891
- /** @type {TODO} */
2892
- (statement.declaration),
2893
- "default",
2894
- undefined
2895
- );
2896
- }
2906
+ this.hooks.exportExpression.call(statement, statement.declaration);
2897
2907
  }
2898
2908
  }
2899
2909
 
@@ -2963,10 +2973,10 @@ class JavascriptParser extends Parser {
2963
2973
 
2964
2974
  /**
2965
2975
  * @param {ObjectPattern} objectPattern object pattern
2966
- * @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
2976
+ * @returns {DestructuringAssignmentProperties | undefined} set of names or undefined if not all keys are identifiers
2967
2977
  */
2968
2978
  _preWalkObjectPattern(objectPattern) {
2969
- /** @type {Set<DestructuringAssignmentProperty>} */
2979
+ /** @type {DestructuringAssignmentProperties} */
2970
2980
  const props = new Set();
2971
2981
  const properties = objectPattern.properties;
2972
2982
  for (let i = 0; i < properties.length; i++) {
@@ -2984,18 +2994,32 @@ class JavascriptParser extends Parser {
2984
2994
  }
2985
2995
  const key = property.key;
2986
2996
  if (key.type === "Identifier" && !property.computed) {
2997
+ const pattern =
2998
+ property.value.type === "ObjectPattern"
2999
+ ? this._preWalkObjectPattern(property.value)
3000
+ : property.value.type === "ArrayPattern"
3001
+ ? this._preWalkArrayPattern(property.value)
3002
+ : undefined;
2987
3003
  props.add({
2988
3004
  id: key.name,
2989
- range: key.range,
3005
+ range: /** @type {Range} */ (key.range),
3006
+ pattern,
2990
3007
  shorthand: this.scope.inShorthand
2991
3008
  });
2992
3009
  } else {
2993
3010
  const id = this.evaluateExpression(key);
2994
3011
  const str = id.asString();
2995
3012
  if (str) {
3013
+ const pattern =
3014
+ property.value.type === "ObjectPattern"
3015
+ ? this._preWalkObjectPattern(property.value)
3016
+ : property.value.type === "ArrayPattern"
3017
+ ? this._preWalkArrayPattern(property.value)
3018
+ : undefined;
2996
3019
  props.add({
2997
3020
  id: str,
2998
- range: key.range,
3021
+ range: /** @type {Range} */ (key.range),
3022
+ pattern,
2999
3023
  shorthand: this.scope.inShorthand
3000
3024
  });
3001
3025
  } else {
@@ -3009,6 +3033,35 @@ class JavascriptParser extends Parser {
3009
3033
  return props;
3010
3034
  }
3011
3035
 
3036
+ /**
3037
+ * @param {ArrayPattern} arrayPattern array pattern
3038
+ * @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
3039
+ */
3040
+ _preWalkArrayPattern(arrayPattern) {
3041
+ /** @type {Set<DestructuringAssignmentProperty>} */
3042
+ const props = new Set();
3043
+ const elements = arrayPattern.elements;
3044
+ for (let i = 0; i < elements.length; i++) {
3045
+ const element = elements[i];
3046
+ if (!element) continue;
3047
+ if (element.type === "RestElement") return;
3048
+ const pattern =
3049
+ element.type === "ObjectPattern"
3050
+ ? this._preWalkObjectPattern(element)
3051
+ : element.type === "ArrayPattern"
3052
+ ? this._preWalkArrayPattern(element)
3053
+ : undefined;
3054
+ props.add({
3055
+ id: `${i}`,
3056
+ range: /** @type {Range} */ (element.range),
3057
+ pattern,
3058
+ shorthand: false
3059
+ });
3060
+ }
3061
+
3062
+ return props;
3063
+ }
3064
+
3012
3065
  /**
3013
3066
  * @param {VariableDeclarator} declarator variable declarator
3014
3067
  */
@@ -3833,6 +3886,18 @@ class JavascriptParser extends Parser {
3833
3886
  );
3834
3887
  if (result === true) return;
3835
3888
  }
3889
+ // import("./m").then(m => { ... })
3890
+ if (
3891
+ expression.callee.object.type === "ImportExpression" &&
3892
+ expression.callee.property.type === "Identifier" &&
3893
+ expression.callee.property.name === "then"
3894
+ ) {
3895
+ const result = this.hooks.importCall.call(
3896
+ expression.callee.object,
3897
+ expression
3898
+ );
3899
+ if (result === true) return;
3900
+ }
3836
3901
  }
3837
3902
  const callee = this.evaluateExpression(expression.callee);
3838
3903
  if (callee.isIdentifier()) {
@@ -3945,7 +4010,7 @@ class JavascriptParser extends Parser {
3945
4010
  * @param {MemberExpression} expression member expression
3946
4011
  * @param {string} name name
3947
4012
  * @param {string | VariableInfo} rootInfo root info
3948
- * @param {string[]} members members
4013
+ * @param {Members} members members
3949
4014
  * @param {() => R | undefined} onUnhandled on unhandled callback
3950
4015
  */
3951
4016
  walkMemberExpressionWithExpressionName(
@@ -4027,7 +4092,7 @@ class JavascriptParser extends Parser {
4027
4092
  * @template R
4028
4093
  * @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
4029
4094
  * @param {Expression | Super} expr expression info
4030
- * @param {((name: string, rootInfo: string | ScopeInfo | VariableInfo, getMembers: () => string[]) => R) | undefined} fallback callback when variable in not handled by hooks
4095
+ * @param {((name: string, rootInfo: string | ScopeInfo | VariableInfo, getMembers: () => Members) => R) | undefined} fallback callback when variable in not handled by hooks
4031
4096
  * @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
4032
4097
  * @param {AsArray<T>} args args for the hook
4033
4098
  * @returns {R | undefined} result of hook
@@ -4098,7 +4163,7 @@ class JavascriptParser extends Parser {
4098
4163
  * @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
4099
4164
  * @param {ExportedVariableInfo} info variable info
4100
4165
  * @param {((name: string) => R | undefined) | undefined} fallback callback when variable in not handled by hooks
4101
- * @param {((result?: string) => TODO) | undefined} defined callback when variable is defined
4166
+ * @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
4102
4167
  * @param {AsArray<T>} args args for the hook
4103
4168
  * @returns {R | undefined} result of hook
4104
4169
  */
@@ -4286,7 +4351,7 @@ class JavascriptParser extends Parser {
4286
4351
  }
4287
4352
 
4288
4353
  /**
4289
- * @param {Array<Directive | Statement | ModuleDeclaration>} statements statements
4354
+ * @param {(Directive | Statement | ModuleDeclaration)[]} statements statements
4290
4355
  */
4291
4356
  detectMode(statements) {
4292
4357
  const isLiteral =
@@ -4606,7 +4671,7 @@ class JavascriptParser extends Parser {
4606
4671
  terminated: undefined,
4607
4672
  definitions: new StackedMap()
4608
4673
  };
4609
- this.state = /** @type {ParserState} */ (state);
4674
+ this.state = state;
4610
4675
  this.comments = comments;
4611
4676
  this.semicolons = semicolons;
4612
4677
  this.statementPath = [];
@@ -4960,7 +5025,7 @@ class JavascriptParser extends Parser {
4960
5025
 
4961
5026
  /**
4962
5027
  * @param {string} name variable name
4963
- * @returns {string | ExportedVariableInfo} info for this variable
5028
+ * @returns {ExportedVariableInfo} info for this variable
4964
5029
  */
4965
5030
  getVariableInfo(name) {
4966
5031
  const value = this.scope.definitions.get(name);
@@ -4972,7 +5037,7 @@ class JavascriptParser extends Parser {
4972
5037
 
4973
5038
  /**
4974
5039
  * @param {string} name variable name
4975
- * @param {string | ExportedVariableInfo} variableInfo new info for this variable
5040
+ * @param {ExportedVariableInfo} variableInfo new info for this variable
4976
5041
  * @returns {void}
4977
5042
  */
4978
5043
  setVariable(name, variableInfo) {
@@ -5053,7 +5118,7 @@ class JavascriptParser extends Parser {
5053
5118
 
5054
5119
  /**
5055
5120
  * @param {Expression | Super} expression a member expression
5056
- * @returns {{ members: string[], object: Expression | Super, membersOptionals: boolean[], memberRanges: Range[] }} member names (reverse order) and remaining object
5121
+ * @returns {{ members: Members, object: Expression | Super, membersOptionals: MembersOptionals, memberRanges: MemberRanges }} member names (reverse order) and remaining object
5057
5122
  */
5058
5123
  extractMemberExpressionChain(expression) {
5059
5124
  /** @type {Node} */
@@ -5119,8 +5184,8 @@ class JavascriptParser extends Parser {
5119
5184
  return { info, name };
5120
5185
  }
5121
5186
 
5122
- /** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => string[], name: string, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[]}} CallExpressionInfo */
5123
- /** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[]}} ExpressionExpressionInfo */
5187
+ /** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => CalleeMembers, name: string, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges}} CallExpressionInfo */
5188
+ /** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges}} ExpressionExpressionInfo */
5124
5189
 
5125
5190
  /**
5126
5191
  * @param {Expression | Super} expression a member expression
@@ -5181,7 +5246,7 @@ class JavascriptParser extends Parser {
5181
5246
 
5182
5247
  /**
5183
5248
  * @param {Expression} expression an expression
5184
- * @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => string[]} | undefined} name info
5249
+ * @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => Members} | undefined} name info
5185
5250
  */
5186
5251
  getNameForExpression(expression) {
5187
5252
  return this.getMemberExpressionInfo(
@@ -10,10 +10,10 @@ const ConstDependency = require("../dependencies/ConstDependency");
10
10
  const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
11
11
 
12
12
  /** @typedef {import("estree").Expression} Expression */
13
- /** @typedef {import("estree").Node} Node */
14
13
  /** @typedef {import("estree").SourceLocation} SourceLocation */
15
14
  /** @typedef {import("./JavascriptParser")} JavascriptParser */
16
15
  /** @typedef {import("./JavascriptParser").Range} Range */
16
+ /** @typedef {import("./BasicEvaluatedExpression").GetMembers} GetMembers */
17
17
 
18
18
  module.exports.approve = () => true;
19
19
 
@@ -31,7 +31,7 @@ module.exports.evaluateToBoolean = (value) =>
31
31
  /**
32
32
  * @param {string} identifier identifier
33
33
  * @param {string} rootInfo rootInfo
34
- * @param {() => string[]} getMembers getMembers
34
+ * @param {GetMembers} getMembers getMembers
35
35
  * @param {boolean | null=} truthy is truthy, null if nullish
36
36
  * @returns {(expression: Expression) => BasicEvaluatedExpression} callback
37
37
  */
@@ -13,14 +13,11 @@ const { getAllChunks } = require("./ChunkHelpers");
13
13
  /** @typedef {import("../util/Hash")} Hash */
14
14
  /** @typedef {import("../Chunk")} Chunk */
15
15
  /** @typedef {import("../Chunk").ChunkId} ChunkId */
16
- /** @typedef {import("../Compilation")} Compilation */
17
16
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
18
17
  /** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
19
18
  /** @typedef {import("../Entrypoint")} Entrypoint */
20
19
  /** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
21
- /** @typedef {import("../ChunkGroup")} ChunkGroup */
22
20
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
23
- /** @typedef {(string|number)[]} EntryItem */
24
21
 
25
22
  const EXPORT_PREFIX = `var ${RuntimeGlobals.exports} = `;
26
23
 
@@ -137,9 +134,10 @@ module.exports.generateEntryStartup = (
137
134
  * @param {Chunk} chunk the chunk
138
135
  * @param {ChunkGraph} chunkGraph the chunk graph
139
136
  * @param {(chunk: Chunk, chunkGraph: ChunkGraph) => boolean} filterFn filter function
140
- * @returns {Set<number | string>} initially fulfilled chunk ids
137
+ * @returns {Set<ChunkId>} initially fulfilled chunk ids
141
138
  */
142
139
  module.exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {
140
+ /** @type {Set<ChunkId>} */
143
141
  const initialChunkIds = new Set(chunk.ids);
144
142
  for (const c of chunk.getAllInitialChunks()) {
145
143
  if (c === chunk || filterFn(c, chunkGraph)) continue;
@@ -10,7 +10,7 @@ const { register } = require("../util/serialization");
10
10
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
11
11
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
12
12
  /** @typedef {import("../util/Hash")} Hash */
13
- /** @typedef {import("./JsonModulesPlugin").JsonValue} JsonValue */
13
+ /** @typedef {import("../util/fs").JsonValue} JsonValue */
14
14
 
15
15
  class JsonData {
16
16
  /**
@@ -20,10 +20,9 @@ const RuntimeGlobals = require("../RuntimeGlobals");
20
20
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
21
21
  /** @typedef {import("../NormalModule")} NormalModule */
22
22
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
23
- /** @typedef {import("./JsonData")} JsonData */
24
- /** @typedef {import("./JsonModulesPlugin").JsonArray} JsonArray */
25
- /** @typedef {import("./JsonModulesPlugin").JsonObject} JsonObject */
26
- /** @typedef {import("./JsonModulesPlugin").JsonValue} JsonValue */
23
+ /** @typedef {import("../util/fs").JsonArray} JsonArray */
24
+ /** @typedef {import("../util/fs").JsonObject} JsonObject */
25
+ /** @typedef {import("../util/fs").JsonValue} JsonValue */
27
26
 
28
27
  /**
29
28
  * @param {JsonValue} data Raw JSON data
@@ -206,7 +205,7 @@ class JsonGenerator extends Generator {
206
205
  /** @type {string} */
207
206
  let content;
208
207
  if (concatenationScope) {
209
- content = `${runtimeTemplate.supportsConst() ? "const" : "var"} ${
208
+ content = `${runtimeTemplate.renderConst()} ${
210
209
  ConcatenationScope.NAMESPACE_OBJECT_EXPORT
211
210
  } = ${jsonExpr};`;
212
211
  concatenationScope.registerNamespaceExport(
@@ -11,9 +11,6 @@ const JsonGenerator = require("./JsonGenerator");
11
11
  const JsonParser = require("./JsonParser");
12
12
 
13
13
  /** @typedef {import("../Compiler")} Compiler */
14
- /** @typedef {import("../util/fs").JsonArray} JsonArray */
15
- /** @typedef {import("../util/fs").JsonObject} JsonObject */
16
- /** @typedef {import("../util/fs").JsonValue} JsonValue */
17
14
 
18
15
  const validate = createSchemaValidation(
19
16
  require("../../schemas/plugins/json/JsonModulesPluginParser.check"),
@@ -15,7 +15,9 @@ const JsonData = require("./JsonData");
15
15
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
16
16
  /** @typedef {import("../Parser").ParserState} ParserState */
17
17
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
18
- /** @typedef {import("./JsonModulesPlugin").JsonValue} JsonValue */
18
+ /** @typedef {import("../util/fs").JsonValue} JsonValue */
19
+
20
+ /** @typedef {(input: string) => Buffer | JsonValue} ParseFn */
19
21
 
20
22
  const getParseJson = memoize(() => require("json-parse-even-better-errors"));
21
23
 
@@ -38,7 +40,7 @@ class JsonParser extends Parser {
38
40
  source = source.toString("utf8");
39
41
  }
40
42
 
41
- /** @type {NonNullable<JsonModulesPluginParserOptions["parse"]>} */
43
+ /** @type {ParseFn} */
42
44
  const parseFn =
43
45
  typeof this.options.parse === "function"
44
46
  ? this.options.parse
@@ -17,9 +17,9 @@ const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin")
17
17
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
18
18
  /** @typedef {import("../Compiler")} Compiler */
19
19
  /** @typedef {import("../Module")} Module */
20
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
20
21
  /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
21
22
  /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
22
- /** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
23
23
  /** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */
24
24
  /** @typedef {import("../util/Hash")} Hash */
25
25
 
@@ -273,7 +273,7 @@ class AbstractLibraryPlugin {
273
273
 
274
274
  /**
275
275
  * @param {Chunk} chunk the chunk
276
- * @param {Set<string>} set runtime requirements
276
+ * @param {RuntimeRequirements} set runtime requirements
277
277
  * @param {LibraryContext<T>} libraryContext context
278
278
  * @returns {void}
279
279
  */
@@ -15,7 +15,6 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
15
15
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
16
16
  /** @typedef {import("../Chunk")} Chunk */
17
17
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
18
- /** @typedef {import("../Compiler")} Compiler */
19
18
  /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
20
19
  /** @typedef {import("../util/Hash")} Hash */
21
20
  /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */