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
@@ -48,8 +48,7 @@ const CssGenerator = require("./CssGenerator");
48
48
  const CssParser = require("./CssParser");
49
49
 
50
50
  /** @typedef {import("webpack-sources").Source} Source */
51
- /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
52
- /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
51
+ /** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
53
52
  /** @typedef {import("../Chunk")} Chunk */
54
53
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
55
54
  /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
@@ -59,10 +58,10 @@ const CssParser = require("./CssParser");
59
58
  /** @typedef {import("../CssModule").CSSModuleCreateData} CSSModuleCreateData */
60
59
  /** @typedef {import("../Module")} Module */
61
60
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
61
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
62
62
  /** @typedef {import("../Template").RuntimeTemplate} RuntimeTemplate */
63
63
  /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
64
64
  /** @typedef {import("../util/Hash")} Hash */
65
- /** @typedef {import("../util/memoize")} Memoize */
66
65
 
67
66
  /**
68
67
  * @typedef {object} RenderContext
@@ -445,7 +444,6 @@ class CssModulesPlugin {
445
444
  compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
446
445
  const {
447
446
  chunkGraph,
448
- codeGenerationResults,
449
447
  moduleGraph,
450
448
  runtimeTemplate,
451
449
  outputOptions: {
@@ -455,8 +453,11 @@ class CssModulesPlugin {
455
453
  hashFunction
456
454
  }
457
455
  } = compilation;
458
- const hash = createHash(/** @type {HashFunction} */ (hashFunction));
456
+ const hash = createHash(hashFunction);
459
457
  if (hashSalt) hash.update(hashSalt);
458
+ const codeGenerationResults =
459
+ /** @type {CodeGenerationResults} */
460
+ (compilation.codeGenerationResults);
460
461
  hooks.chunkHash.call(chunk, hash, {
461
462
  chunkGraph,
462
463
  codeGenerationResults,
@@ -469,12 +470,8 @@ class CssModulesPlugin {
469
470
  hash.update(chunkGraph.getModuleHash(module, chunk.runtime));
470
471
  }
471
472
  }
472
- const digest = /** @type {string} */ (hash.digest(hashDigest));
473
- chunk.contentHash.css = nonNumericOnlyHash(
474
- digest,
475
- /** @type {number} */
476
- (hashDigestLength)
477
- );
473
+ const digest = hash.digest(hashDigest);
474
+ chunk.contentHash.css = nonNumericOnlyHash(digest, hashDigestLength);
478
475
  });
479
476
  compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
480
477
  const { chunkGraph } = compilation;
@@ -500,8 +497,7 @@ class CssModulesPlugin {
500
497
  );
501
498
  const undoPath = getUndoPath(
502
499
  filename,
503
- /** @type {string} */
504
- (compilation.outputOptions.path),
500
+ compilation.outputOptions.path,
505
501
  false
506
502
  );
507
503
  result.push({
@@ -511,9 +507,7 @@ class CssModulesPlugin {
511
507
  chunk,
512
508
  chunkGraph,
513
509
  codeGenerationResults,
514
- uniqueName:
515
- /** @type {string} */
516
- (compilation.outputOptions.uniqueName),
510
+ uniqueName: compilation.outputOptions.uniqueName,
517
511
  undoPath,
518
512
  modules,
519
513
  runtimeTemplate
@@ -544,7 +538,7 @@ class CssModulesPlugin {
544
538
  const onceForChunkSet = new WeakSet();
545
539
  /**
546
540
  * @param {Chunk} chunk chunk to check
547
- * @param {Set<string>} set runtime requirements
541
+ * @param {RuntimeRequirements} set runtime requirements
548
542
  */
549
543
  const handler = (chunk, set) => {
550
544
  if (onceForChunkSet.has(chunk)) return;
@@ -914,9 +908,9 @@ class CssModulesPlugin {
914
908
  if (chunk.cssFilenameTemplate) {
915
909
  return chunk.cssFilenameTemplate;
916
910
  } else if (chunk.canBeInitial()) {
917
- return /** @type {TemplatePath} */ (outputOptions.cssFilename);
911
+ return outputOptions.cssFilename;
918
912
  }
919
- return /** @type {TemplatePath} */ (outputOptions.cssChunkFilename);
913
+ return outputOptions.cssChunkFilename;
920
914
  }
921
915
 
922
916
  /**
@@ -355,7 +355,7 @@ class CssParser extends Parser {
355
355
  mode === "auto" &&
356
356
  module.type === CSS_MODULE_TYPE_AUTO &&
357
357
  IS_MODULES.test(
358
- parseResource(module.matchResource || module.resource).path
358
+ parseResource(/** @type {string} */ (module.getResource())).path
359
359
  )
360
360
  ) {
361
361
  mode = "local";
@@ -372,7 +372,7 @@ class CssParser extends Parser {
372
372
  let scope = CSS_MODE_TOP_LEVEL;
373
373
  /** @type {boolean} */
374
374
  let allowImportAtRule = true;
375
- /** @type [string, number, number][] */
375
+ /** @type {[string, number, number][]} */
376
376
  const balanced = [];
377
377
  let lastTokenEndForComments = 0;
378
378
 
@@ -1611,7 +1611,7 @@ class CssParser extends Parser {
1611
1611
  const newErr = new Error(String(/** @type {Error} */ (err).message));
1612
1612
  newErr.stack = String(/** @type {Error} */ (err).stack);
1613
1613
  Object.assign(newErr, { comment });
1614
- errors.push(/** @type (Error & { comment: Comment }) */ (newErr));
1614
+ errors.push(/** @type {(Error & { comment: Comment })} */ (newErr));
1615
1615
  }
1616
1616
  }
1617
1617
  }
@@ -66,7 +66,7 @@ const CC_LOWER_Z = "z".charCodeAt(0);
66
66
  const CC_UPPER_A = "A".charCodeAt(0);
67
67
  const CC_UPPER_F = "F".charCodeAt(0);
68
68
  const CC_UPPER_E = "E".charCodeAt(0);
69
- const CC_UPPER_U = "E".charCodeAt(0);
69
+ const CC_UPPER_U = "U".charCodeAt(0);
70
70
  const CC_UPPER_Z = "Z".charCodeAt(0);
71
71
  const CC_0 = "0".charCodeAt(0);
72
72
  const CC_9 = "9".charCodeAt(0);
@@ -1589,7 +1589,7 @@ const eatUntil = (chars) => {
1589
1589
  chars.charCodeAt(i)
1590
1590
  );
1591
1591
  const arr = Array.from(
1592
- { length: charCodes.reduce((a, b) => Math.max(a, b), 0) + 1 },
1592
+ { length: Math.max(...charCodes, 0) + 1 },
1593
1593
  () => false
1594
1594
  );
1595
1595
  for (const cc of charCodes) {
@@ -19,13 +19,30 @@ const { dirname, mkdirpSync } = require("../util/fs");
19
19
  /** @typedef {import("../../declarations/plugins/debug/ProfilingPlugin").ProfilingPluginOptions} ProfilingPluginOptions */
20
20
  /** @typedef {import("../Compilation")} Compilation */
21
21
  /** @typedef {import("../Compiler")} Compiler */
22
- /** @typedef {import("../ContextModuleFactory")} ContextModuleFactory */
23
- /** @typedef {import("../ModuleFactory")} ModuleFactory */
24
22
  /** @typedef {import("../NormalModuleFactory")} NormalModuleFactory */
25
- /** @typedef {import("../Parser")} Parser */
26
23
  /** @typedef {import("../ResolverFactory")} ResolverFactory */
27
24
  /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
28
25
 
26
+ /**
27
+ * @template T, R
28
+ * @typedef {import("tapable").Hook<T, R>} Hook
29
+ */
30
+
31
+ /**
32
+ * @template T
33
+ * @typedef {import("../util/deprecation").FakeHook<T>} FakeHook
34
+ */
35
+
36
+ /**
37
+ * @template T
38
+ * @typedef {import("tapable").HookMap<T>} HookMap
39
+ */
40
+
41
+ /**
42
+ * @template T, R
43
+ * @typedef {import("tapable").HookInterceptor<T, R>} HookInterceptor
44
+ */
45
+
29
46
  const validate = createSchemaValidation(
30
47
  require("../../schemas/plugins/debug/ProfilingPlugin.check"),
31
48
  () => require("../../schemas/plugins/debug/ProfilingPlugin.json"),
@@ -119,6 +136,9 @@ class Profiler {
119
136
  return Promise.resolve();
120
137
  }
121
138
 
139
+ /**
140
+ * @returns {Promise<{ profile: { startTime: number, endTime: number } }>} profile result
141
+ */
122
142
  stopProfiling() {
123
143
  return this.sendCommand("Profiler.stop").then(({ profile }) => {
124
144
  const hrtime = process.hrtime();
@@ -255,7 +275,10 @@ class ProfilingPlugin {
255
275
  (hookName)
256
276
  ];
257
277
  if (hook) {
258
- hook.intercept(makeInterceptorFor("Resolver", tracer)(hookName));
278
+ hook.intercept(
279
+ /** @type {EXPECTED_ANY} */
280
+ (makeInterceptorFor("Resolver", tracer)(hookName))
281
+ );
259
282
  }
260
283
  }
261
284
 
@@ -347,15 +370,18 @@ class ProfilingPlugin {
347
370
  }
348
371
  }
349
372
 
373
+ /** @typedef {Record<string, Hook<EXPECTED_ANY, EXPECTED_ANY> | FakeHook<EXPECTED_ANY> | HookMap<EXPECTED_ANY>>} Hooks */
374
+
350
375
  /**
351
- * @param {EXPECTED_ANY & { hooks: TODO }} instance instance
376
+ * @param {EXPECTED_OBJECT & { hooks?: Hooks }} instance instance
352
377
  * @param {Trace} tracer tracer
353
378
  * @param {string} logLabel log label
354
379
  */
355
380
  const interceptAllHooksFor = (instance, tracer, logLabel) => {
356
381
  if (Reflect.has(instance, "hooks")) {
357
- for (const hookName of Object.keys(instance.hooks)) {
358
- const hook = instance.hooks[hookName];
382
+ const hooks = /** @type {Hooks} */ (instance.hooks);
383
+ for (const hookName of Object.keys(hooks)) {
384
+ const hook = hooks[hookName];
359
385
  if (hook && !hook._fakeHook) {
360
386
  hook.intercept(makeInterceptorFor(logLabel, tracer)(hookName));
361
387
  }
@@ -439,9 +465,10 @@ const interceptAllCssModulesPluginHooks = (compilation, tracer) => {
439
465
  /** @typedef {(...args: EXPECTED_ANY[]) => EXPECTED_ANY | Promise<(...args: EXPECTED_ANY[]) => EXPECTED_ANY>} PluginFunction */
440
466
 
441
467
  /**
468
+ * @template T
442
469
  * @param {string} instance instance
443
470
  * @param {Trace} tracer tracer
444
- * @returns {(hookName: string) => TODO} interceptor
471
+ * @returns {(hookName: string) => HookInterceptor<EXPECTED_ANY, EXPECTED_ANY>} interceptor
445
472
  */
446
473
  const makeInterceptorFor = (instance, tracer) => (hookName) => ({
447
474
  /**
@@ -24,12 +24,12 @@ const { addLocalModule, getLocalModule } = require("./LocalModulesHelpers");
24
24
  /** @typedef {import("estree").Literal} Literal */
25
25
  /** @typedef {import("estree").MemberExpression} MemberExpression */
26
26
  /** @typedef {import("estree").ObjectExpression} ObjectExpression */
27
- /** @typedef {import("estree").SimpleCallExpression} SimpleCallExpression */
28
27
  /** @typedef {import("estree").SpreadElement} SpreadElement */
29
28
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
30
29
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
31
30
  /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
32
31
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
32
+ /** @typedef {import("../javascript/JavascriptParser").ExportedVariableInfo} ExportedVariableInfo */
33
33
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
34
34
 
35
35
  /**
@@ -68,6 +68,8 @@ const isCallable = (expr) => {
68
68
  return false;
69
69
  };
70
70
 
71
+ /** @typedef {Record<number, string>} Identifiers */
72
+
71
73
  const PLUGIN_NAME = "AMDDefineDependencyParserPlugin";
72
74
 
73
75
  class AMDDefineDependencyParserPlugin {
@@ -92,7 +94,7 @@ class AMDDefineDependencyParserPlugin {
92
94
  * @param {JavascriptParser} parser the parser
93
95
  * @param {CallExpression} expr call expression
94
96
  * @param {BasicEvaluatedExpression} param param
95
- * @param {Record<number, string>} identifiers identifiers
97
+ * @param {Identifiers} identifiers identifiers
96
98
  * @param {string=} namedModule named module
97
99
  * @returns {boolean | undefined} result
98
100
  */
@@ -106,7 +108,7 @@ class AMDDefineDependencyParserPlugin {
106
108
  /** @type {string} */ (item.string)
107
109
  )
108
110
  ) {
109
- identifiers[/** @type {number} */ (idx)] =
111
+ identifiers[idx] =
110
112
  /** @type {string} */
111
113
  (item.string);
112
114
  }
@@ -347,9 +349,10 @@ class AMDDefineDependencyParserPlugin {
347
349
  }
348
350
  }
349
351
  }
352
+ /** @type {Map<string, ExportedVariableInfo>} */
350
353
  const fnRenames = new Map();
351
354
  if (array) {
352
- /** @type {Record<number, string>} */
355
+ /** @type {Identifiers} */
353
356
  const identifiers = {};
354
357
  const param = parser.evaluateExpression(array);
355
358
  const result = this.processArray(
@@ -417,19 +420,11 @@ class AMDDefineDependencyParserPlugin {
417
420
  parser.setVariable(name, varInfo);
418
421
  }
419
422
  parser.scope.inTry = /** @type {boolean} */ (inTry);
420
-
421
- if (object.body.type === "BlockStatement") {
422
- parser.detectMode(object.body.body);
423
- const prev = parser.prevStatement;
424
- parser.preWalkStatement(object.body);
425
- parser.prevStatement = prev;
426
- parser.walkStatement(object.body);
427
- } else {
428
- parser.walkExpression(
429
- /** @type {TODO} */
430
- (object.body)
431
- );
432
- }
423
+ parser.detectMode(object.body.body);
424
+ const prev = parser.prevStatement;
425
+ parser.preWalkStatement(object.body);
426
+ parser.prevStatement = prev;
427
+ parser.walkStatement(object.body);
433
428
  }
434
429
  );
435
430
  if (fn.arguments) {
@@ -34,11 +34,11 @@ const UnsupportedDependency = require("./UnsupportedDependency");
34
34
 
35
35
  /** @typedef {import("../../declarations/WebpackOptions").Amd} Amd */
36
36
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
37
- /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
38
37
  /** @typedef {import("../Compiler")} Compiler */
39
38
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
40
39
  /** @typedef {import("../javascript/JavascriptParser")} Parser */
41
40
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
41
+ /** @typedef {import("../javascript/BasicEvaluatedExpression").GetMembers} GetMembers */
42
42
 
43
43
  const PLUGIN_NAME = "AMDPlugin";
44
44
 
@@ -143,7 +143,7 @@ class AMDPlugin {
143
143
  /**
144
144
  * @param {string} optionExpr option expression
145
145
  * @param {string} rootName root name
146
- * @param {() => string[]} getMembers callback
146
+ * @param {GetMembers} getMembers callback
147
147
  */
148
148
  const tapOptionsHooks = (optionExpr, rootName, getMembers) => {
149
149
  parser.hooks.expression
@@ -26,7 +26,6 @@ const getFunctionExpression = require("./getFunctionExpression");
26
26
  /** @typedef {import("estree").SpreadElement} SpreadElement */
27
27
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
28
28
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
29
- /** @typedef {import("../Module").BuildInfo} BuildInfo */
30
29
  /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
31
30
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
32
31
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
@@ -296,7 +295,7 @@ class AMDRequireDependenciesBlockParserPlugin {
296
295
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
297
296
  depBlock.addDependency(dep);
298
297
 
299
- parser.state.current = /** @type {TODO} */ (depBlock);
298
+ parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock);
300
299
  }
301
300
 
302
301
  if (expr.arguments.length === 1) {
@@ -11,13 +11,9 @@ const makeSerializable = require("../util/makeSerializable");
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").UpdateHashContext} UpdateHashContext */
17
16
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
18
- /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
19
- /** @typedef {import("../ModuleGraph")} ModuleGraph */
20
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
21
17
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
22
18
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
23
19
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
@@ -17,11 +17,13 @@ const processExportInfo = require("./processExportInfo");
17
17
 
18
18
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
19
19
  /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
20
- /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
20
+ /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */
21
+ /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
21
22
  /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
22
23
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
23
24
  /** @typedef {import("../ExportsInfo")} ExportsInfo */
24
25
  /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
26
+ /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
25
27
  /** @typedef {import("../Module")} Module */
26
28
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
27
29
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
@@ -34,14 +36,17 @@ const idsSymbol = Symbol("CommonJsExportRequireDependency.ids");
34
36
 
35
37
  const EMPTY_OBJECT = {};
36
38
 
39
+ /** @typedef {Set<string>} Exports */
40
+ /** @typedef {Set<string>} Checked */
41
+
37
42
  class CommonJsExportRequireDependency extends ModuleDependency {
38
43
  /**
39
44
  * @param {Range} range range
40
45
  * @param {Range | null} valueRange value range
41
46
  * @param {CommonJSDependencyBaseKeywords} base base
42
- * @param {string[]} names names
47
+ * @param {ExportInfoName[]} names names
43
48
  * @param {string} request request
44
- * @param {string[]} ids ids
49
+ * @param {ExportInfoName[]} ids ids
45
50
  * @param {boolean} resultUsed true, when the result is used
46
51
  */
47
52
  constructor(range, valueRange, base, names, request, ids, resultUsed) {
@@ -68,7 +73,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
68
73
 
69
74
  /**
70
75
  * @param {ModuleGraph} moduleGraph the module graph
71
- * @returns {string[]} the imported id
76
+ * @returns {ExportInfoName[]} the imported id
72
77
  */
73
78
  getIds(moduleGraph) {
74
79
  return moduleGraph.getMeta(this)[idsSymbol] || this.ids;
@@ -76,7 +81,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
76
81
 
77
82
  /**
78
83
  * @param {ModuleGraph} moduleGraph the module graph
79
- * @param {string[]} ids the imported ids
84
+ * @param {ExportInfoName[]} ids the imported ids
80
85
  * @returns {void}
81
86
  */
82
87
  setIds(moduleGraph, ids) {
@@ -87,7 +92,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
87
92
  * Returns list of exports referenced by this dependency
88
93
  * @param {ModuleGraph} moduleGraph module graph
89
94
  * @param {RuntimeSpec} runtime the runtime for which the module is analysed
90
- * @returns {(string[] | ReferencedExport)[]} referenced exports
95
+ * @returns {ReferencedExports} referenced exports
91
96
  */
92
97
  getReferencedExports(moduleGraph, runtime) {
93
98
  const ids = this.getIds(moduleGraph);
@@ -108,9 +113,9 @@ class CommonJsExportRequireDependency extends ModuleDependency {
108
113
  /** @type {Module} */ (moduleGraph.getParentModule(this))
109
114
  );
110
115
  for (const name of this.names) {
111
- const exportInfo = /** @type {ExportInfo} */ (
112
- exportsInfo.getReadOnlyExportInfo(name)
113
- );
116
+ const exportInfo =
117
+ /** @type {ExportInfo} */
118
+ (exportsInfo.getReadOnlyExportInfo(name));
114
119
  const used = exportInfo.getUsed(runtime);
115
120
  if (used === UsageState.Unused) return Dependency.NO_EXPORTS_REFERENCED;
116
121
  if (used !== UsageState.OnlyPropertiesUsed) return getFullResult();
@@ -120,7 +125,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
120
125
  if (exportsInfo.otherExportsInfo.getUsed(runtime) !== UsageState.Unused) {
121
126
  return getFullResult();
122
127
  }
123
- /** @type {string[][]} */
128
+ /** @type {RawReferencedExports} */
124
129
  const referencedExports = [];
125
130
  for (const exportInfo of exportsInfo.orderedExports) {
126
131
  processExportInfo(
@@ -188,7 +193,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
188
193
  if (reexportInfo) {
189
194
  return {
190
195
  exports: Array.from(
191
- /** @type {Set<string>} */
196
+ /** @type {Exports} */
192
197
  (reexportInfo.exports),
193
198
  (name) => ({
194
199
  name,
@@ -213,7 +218,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
213
218
  * @param {ModuleGraph} moduleGraph the module graph
214
219
  * @param {RuntimeSpec} runtime the runtime
215
220
  * @param {Module} importedModule the imported module (optional)
216
- * @returns {{exports?: Set<string>, checked?: Set<string>} | undefined} information
221
+ * @returns {{ exports?: Exports, checked?: Checked } | undefined} information
217
222
  */
218
223
  getStarReexports(
219
224
  moduleGraph,
@@ -248,9 +253,9 @@ class CommonJsExportRequireDependency extends ModuleDependency {
248
253
  const isNamespaceImport =
249
254
  importedModule.getExportsType(moduleGraph, false) === "namespace";
250
255
 
251
- /** @type {Set<string>} */
256
+ /** @type {Exports} */
252
257
  const exports = new Set();
253
- /** @type {Set<string>} */
258
+ /** @type {Checked} */
254
259
  const checked = new Set();
255
260
 
256
261
  if (noExtraImports) {
@@ -403,3 +408,4 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
403
408
  };
404
409
 
405
410
  module.exports = CommonJsExportRequireDependency;
411
+ module.exports.idsSymbol = idsSymbol;
@@ -16,6 +16,7 @@ const NullDependency = require("./NullDependency");
16
16
  /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
17
17
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
18
18
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
19
+ /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
19
20
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
20
21
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
21
22
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
@@ -28,7 +29,7 @@ class CommonJsExportsDependency extends NullDependency {
28
29
  * @param {Range} range range
29
30
  * @param {Range | null} valueRange value range
30
31
  * @param {CommonJSDependencyBaseKeywords} base base
31
- * @param {string[]} names names
32
+ * @param {ExportInfoName[]} names names
32
33
  */
33
34
  constructor(range, valueRange, base, names) {
34
35
  super();
@@ -22,12 +22,14 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
22
22
  /** @typedef {import("estree").Super} Super */
23
23
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
24
24
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
25
- /** @typedef {import("../NormalModule")} NormalModule */
25
+ /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
26
26
  /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
27
27
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
28
28
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
29
+ /** @typedef {import("../javascript/JavascriptParser").Members} Members */
29
30
  /** @typedef {import("../javascript/JavascriptParser").StatementPath} StatementPath */
30
31
  /** @typedef {import("./CommonJsDependencyHelpers").CommonJSDependencyBaseKeywords} CommonJSDependencyBaseKeywords */
32
+ /** @typedef {import("../Module").BuildMeta} BuildMeta */
31
33
 
32
34
  /**
33
35
  * This function takes a generic expression and detects whether it is an ObjectExpression.
@@ -94,9 +96,10 @@ const isFalsyLiteral = (expr) => {
94
96
  /**
95
97
  * @param {JavascriptParser} parser the parser
96
98
  * @param {Expression} expr expression
97
- * @returns {{ argument: BasicEvaluatedExpression, ids: string[] } | undefined} parsed call
99
+ * @returns {{ argument: BasicEvaluatedExpression, ids: ExportInfoName[] } | undefined} parsed call
98
100
  */
99
101
  const parseRequireCall = (parser, expr) => {
102
+ /** @type {ExportInfoName[]} */
100
103
  const ids = [];
101
104
  while (expr.type === "MemberExpression") {
102
105
  if (expr.object.type === "Super") return;
@@ -146,7 +149,7 @@ class CommonJsExportsParserPlugin {
146
149
 
147
150
  /**
148
151
  * @param {boolean} topLevel true, when the export is on top level
149
- * @param {string[]} members members of the export
152
+ * @param {Members} members members of the export
150
153
  * @param {Expression | undefined} valueExpr expression for the value
151
154
  * @returns {void}
152
155
  */
@@ -189,7 +192,7 @@ class CommonJsExportsParserPlugin {
189
192
  /**
190
193
  * @param {AssignmentExpression} expr expression
191
194
  * @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
192
- * @param {string[]} members members of the export
195
+ * @param {Members} members members of the export
193
196
  * @returns {boolean | undefined} true, when the expression was handled
194
197
  */
195
198
  const handleAssignExport = (expr, base, members) => {
@@ -216,6 +219,10 @@ class CommonJsExportsParserPlugin {
216
219
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
217
220
  dep.optional = Boolean(parser.scope.inTry);
218
221
  parser.state.module.addDependency(dep);
222
+ /** @type {BuildMeta} */ (
223
+ parser.state.module.buildMeta
224
+ ).treatAsCommonJs = true;
225
+
219
226
  return true;
220
227
  }
221
228
  if (members.length === 0) return;
@@ -236,6 +243,8 @@ class CommonJsExportsParserPlugin {
236
243
  );
237
244
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
238
245
  parser.state.module.addDependency(dep);
246
+ /** @type {BuildMeta} */ (parser.state.module.buildMeta).treatAsCommonJs =
247
+ true;
239
248
  parser.walkExpression(expr.right);
240
249
  return true;
241
250
  };
@@ -293,6 +302,9 @@ class CommonJsExportsParserPlugin {
293
302
  );
294
303
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
295
304
  parser.state.module.addDependency(dep);
305
+ /** @type {BuildMeta} */ (
306
+ parser.state.module.buildMeta
307
+ ).treatAsCommonJs = true;
296
308
 
297
309
  parser.walkExpression(expr.arguments[2]);
298
310
  return true;
@@ -303,7 +315,7 @@ class CommonJsExportsParserPlugin {
303
315
  /**
304
316
  * @param {Expression | Super} expr expression
305
317
  * @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
306
- * @param {string[]} members members of the export
318
+ * @param {Members} members members of the export
307
319
  * @param {CallExpression=} call call expression
308
320
  * @returns {boolean | void} true, when the expression was handled
309
321
  */
@@ -333,6 +345,9 @@ class CommonJsExportsParserPlugin {
333
345
  );
334
346
  dep.loc = /** @type {DependencyLocation} */ (expr.loc);
335
347
  parser.state.module.addDependency(dep);
348
+ /** @type {BuildMeta} */ (parser.state.module.buildMeta).treatAsCommonJs =
349
+ true;
350
+
336
351
  if (call) {
337
352
  parser.walkExpressions(call.arguments);
338
353
  }
@@ -14,20 +14,22 @@ const ModuleDependency = require("./ModuleDependency");
14
14
 
15
15
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
16
16
  /** @typedef {import("../Dependency")} Dependency */
17
- /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
17
+ /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
18
18
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
19
19
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
20
20
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
21
+ /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
21
22
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
22
23
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
23
24
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
25
+ /** @typedef {import("../util/chainedImports").IdRanges} IdRanges */
24
26
 
25
27
  class CommonJsFullRequireDependency extends ModuleDependency {
26
28
  /**
27
29
  * @param {string} request the request string
28
30
  * @param {Range} range location in source code
29
- * @param {string[]} names accessed properties on module
30
- * @param {Range[]=} idRanges ranges for members of ids; the two arrays are right-aligned
31
+ * @param {ExportInfoName[]} names accessed properties on module
32
+ * @param {IdRanges=} idRanges ranges for members of ids; the two arrays are right-aligned
31
33
  */
32
34
  constructor(
33
35
  request,
@@ -47,7 +49,7 @@ class CommonJsFullRequireDependency extends ModuleDependency {
47
49
  * Returns list of exports referenced by this dependency
48
50
  * @param {ModuleGraph} moduleGraph module graph
49
51
  * @param {RuntimeSpec} runtime the runtime for which the module is analysed
50
- * @returns {(string[] | ReferencedExport)[]} referenced exports
52
+ * @returns {ReferencedExports} referenced exports
51
53
  */
52
54
  getReferencedExports(moduleGraph, runtime) {
53
55
  if (this.call) {