webpack 5.93.0 → 5.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/README.md +8 -5
  2. package/bin/webpack.js +6 -7
  3. package/hot/log.js +1 -2
  4. package/hot/only-dev-server.js +1 -1
  5. package/hot/poll.js +1 -1
  6. package/hot/signal.js +1 -1
  7. package/lib/APIPlugin.js +4 -3
  8. package/lib/AbstractMethodError.js +10 -5
  9. package/lib/AutomaticPrefetchPlugin.js +1 -1
  10. package/lib/BannerPlugin.js +12 -6
  11. package/lib/Cache.js +8 -10
  12. package/lib/CacheFacade.js +3 -3
  13. package/lib/CaseSensitiveModulesWarning.js +5 -7
  14. package/lib/Chunk.js +14 -11
  15. package/lib/ChunkGraph.js +58 -36
  16. package/lib/ChunkGroup.js +2 -3
  17. package/lib/ChunkTemplate.js +43 -0
  18. package/lib/CleanPlugin.js +10 -11
  19. package/lib/CodeGenerationResults.js +6 -5
  20. package/lib/CommentCompilationWarning.js +0 -1
  21. package/lib/Compilation.js +223 -191
  22. package/lib/Compiler.js +81 -82
  23. package/lib/ConcatenationScope.js +3 -6
  24. package/lib/ConditionalInitFragment.js +6 -7
  25. package/lib/ConstPlugin.js +7 -15
  26. package/lib/ContextExclusionPlugin.js +3 -3
  27. package/lib/ContextModule.js +33 -20
  28. package/lib/ContextModuleFactory.js +89 -44
  29. package/lib/ContextReplacementPlugin.js +10 -9
  30. package/lib/DefinePlugin.js +75 -68
  31. package/lib/DelegatedModule.js +7 -3
  32. package/lib/DelegatedModuleFactoryPlugin.js +36 -22
  33. package/lib/DelegatedPlugin.js +4 -0
  34. package/lib/DependenciesBlock.js +0 -1
  35. package/lib/Dependency.js +10 -14
  36. package/lib/DllEntryPlugin.js +4 -2
  37. package/lib/DllModuleFactory.js +1 -0
  38. package/lib/DllPlugin.js +9 -7
  39. package/lib/DllReferencePlugin.js +30 -15
  40. package/lib/EntryPlugin.js +1 -3
  41. package/lib/EnvironmentPlugin.js +6 -2
  42. package/lib/ErrorHelpers.js +11 -12
  43. package/lib/EvalDevToolModulePlugin.js +10 -12
  44. package/lib/EvalSourceMapDevToolPlugin.js +15 -13
  45. package/lib/ExportsInfo.js +185 -120
  46. package/lib/ExternalModule.js +41 -15
  47. package/lib/ExternalModuleFactoryPlugin.js +23 -10
  48. package/lib/FileSystemInfo.js +791 -422
  49. package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
  50. package/lib/FlagDependencyExportsPlugin.js +12 -11
  51. package/lib/FlagDependencyUsagePlugin.js +1 -1
  52. package/lib/Generator.js +2 -5
  53. package/lib/GraphHelpers.js +3 -2
  54. package/lib/HookWebpackError.js +8 -10
  55. package/lib/HotModuleReplacementPlugin.js +78 -64
  56. package/lib/IgnoreErrorModuleFactory.js +3 -3
  57. package/lib/IgnorePlugin.js +1 -3
  58. package/lib/IgnoreWarningsPlugin.js +6 -9
  59. package/lib/InitFragment.js +2 -3
  60. package/lib/LibManifestPlugin.js +4 -3
  61. package/lib/MainTemplate.js +72 -19
  62. package/lib/Module.js +25 -9
  63. package/lib/ModuleBuildError.js +4 -11
  64. package/lib/ModuleDependencyError.js +5 -5
  65. package/lib/ModuleDependencyWarning.js +5 -5
  66. package/lib/ModuleError.js +1 -5
  67. package/lib/ModuleFilenameHelpers.js +29 -46
  68. package/lib/ModuleGraph.js +7 -6
  69. package/lib/ModuleGraphConnection.js +6 -6
  70. package/lib/ModuleInfoHeaderPlugin.js +82 -30
  71. package/lib/ModuleParseError.js +8 -9
  72. package/lib/ModuleRestoreError.js +1 -1
  73. package/lib/ModuleStoreError.js +1 -1
  74. package/lib/ModuleTemplate.js +33 -1
  75. package/lib/ModuleTypeConstants.js +21 -22
  76. package/lib/ModuleWarning.js +1 -5
  77. package/lib/MultiCompiler.js +24 -26
  78. package/lib/MultiStats.js +73 -31
  79. package/lib/MultiWatching.js +1 -1
  80. package/lib/NormalModule.js +130 -69
  81. package/lib/NormalModuleFactory.js +53 -49
  82. package/lib/OptimizationStages.js +3 -3
  83. package/lib/ProgressPlugin.js +9 -9
  84. package/lib/ProvidePlugin.js +4 -4
  85. package/lib/RuntimeGlobals.js +71 -70
  86. package/lib/RuntimeModule.js +1 -1
  87. package/lib/RuntimePlugin.js +24 -12
  88. package/lib/RuntimeTemplate.js +40 -44
  89. package/lib/SizeFormatHelpers.js +2 -4
  90. package/lib/SourceMapDevToolPlugin.js +42 -34
  91. package/lib/Stats.js +5 -11
  92. package/lib/Template.js +18 -24
  93. package/lib/TemplatedPathPlugin.js +21 -13
  94. package/lib/WarnDeprecatedOptionPlugin.js +0 -1
  95. package/lib/WatchIgnorePlugin.js +26 -9
  96. package/lib/Watching.js +10 -5
  97. package/lib/WebpackOptionsApply.js +84 -62
  98. package/lib/asset/AssetGenerator.js +107 -42
  99. package/lib/asset/AssetModulesPlugin.js +29 -23
  100. package/lib/asset/AssetSourceGenerator.js +2 -7
  101. package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
  102. package/lib/buildChunkGraph.js +93 -81
  103. package/lib/cache/IdleFileCachePlugin.js +4 -4
  104. package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
  105. package/lib/cache/PackFileCacheStrategy.js +51 -50
  106. package/lib/cache/ResolverCachePlugin.js +6 -6
  107. package/lib/cache/mergeEtags.js +16 -21
  108. package/lib/cli.js +148 -104
  109. package/lib/config/browserslistTargetHandler.js +16 -13
  110. package/lib/config/defaults.js +32 -28
  111. package/lib/config/normalization.js +335 -344
  112. package/lib/config/target.js +42 -52
  113. package/lib/container/ContainerEntryModule.js +2 -2
  114. package/lib/container/ContainerPlugin.js +1 -1
  115. package/lib/container/RemoteRuntimeModule.js +11 -8
  116. package/lib/container/options.js +18 -4
  117. package/lib/css/CssExportsGenerator.js +26 -24
  118. package/lib/css/CssGenerator.js +9 -4
  119. package/lib/css/CssLoadingRuntimeModule.js +10 -10
  120. package/lib/css/CssModulesPlugin.js +127 -47
  121. package/lib/css/CssParser.js +20 -18
  122. package/lib/css/walkCssTokens.js +80 -95
  123. package/lib/debug/ProfilingPlugin.js +19 -20
  124. package/lib/dependencies/AMDDefineDependency.js +1 -1
  125. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
  126. package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
  127. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
  128. package/lib/dependencies/AMDRuntimeModules.js +2 -2
  129. package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
  130. package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
  131. package/lib/dependencies/CommonJsExportsDependency.js +0 -1
  132. package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
  133. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
  134. package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
  135. package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
  136. package/lib/dependencies/ConstDependency.js +1 -1
  137. package/lib/dependencies/ContextDependency.js +7 -2
  138. package/lib/dependencies/ContextDependencyHelpers.js +31 -34
  139. package/lib/dependencies/ContextElementDependency.js +35 -8
  140. package/lib/dependencies/CriticalDependencyWarning.js +1 -1
  141. package/lib/dependencies/CssExportDependency.js +7 -7
  142. package/lib/dependencies/CssImportDependency.js +0 -2
  143. package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
  144. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  145. package/lib/dependencies/CssUrlDependency.js +4 -5
  146. package/lib/dependencies/DynamicExports.js +5 -5
  147. package/lib/dependencies/ExportsInfoDependency.js +1 -2
  148. package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
  149. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
  150. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
  151. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  152. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
  153. package/lib/dependencies/HarmonyExports.js +2 -2
  154. package/lib/dependencies/HarmonyImportDependency.js +2 -4
  155. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
  156. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
  157. package/lib/dependencies/ImportDependency.js +1 -1
  158. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
  159. package/lib/dependencies/ImportMetaPlugin.js +11 -13
  160. package/lib/dependencies/ImportParserPlugin.js +39 -44
  161. package/lib/dependencies/JsonExportsDependency.js +22 -18
  162. package/lib/dependencies/LoaderPlugin.js +47 -36
  163. package/lib/dependencies/LocalModule.js +1 -1
  164. package/lib/dependencies/LocalModulesHelpers.js +4 -4
  165. package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
  166. package/lib/dependencies/ProvidedDependency.js +1 -1
  167. package/lib/dependencies/PureExpressionDependency.js +6 -6
  168. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  169. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  170. package/lib/dependencies/SystemPlugin.js +1 -1
  171. package/lib/dependencies/URLDependency.js +3 -3
  172. package/lib/dependencies/URLPlugin.js +66 -12
  173. package/lib/dependencies/WorkerPlugin.js +25 -24
  174. package/lib/dependencies/processExportInfo.js +3 -1
  175. package/lib/electron/ElectronTargetPlugin.js +1 -0
  176. package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
  177. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
  178. package/lib/formatLocation.js +1 -2
  179. package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
  180. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
  181. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
  182. package/lib/hmr/LazyCompilationPlugin.js +27 -12
  183. package/lib/hmr/lazyCompilationBackend.js +64 -40
  184. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
  185. package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
  186. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  187. package/lib/ids/HashedModuleIdsPlugin.js +5 -1
  188. package/lib/ids/IdHelpers.js +29 -39
  189. package/lib/ids/SyncModuleIdsPlugin.js +7 -2
  190. package/lib/index.js +1 -5
  191. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
  192. package/lib/javascript/BasicEvaluatedExpression.js +4 -19
  193. package/lib/javascript/ChunkHelpers.js +1 -1
  194. package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
  195. package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
  196. package/lib/javascript/JavascriptGenerator.js +23 -7
  197. package/lib/javascript/JavascriptModulesPlugin.js +133 -86
  198. package/lib/javascript/JavascriptParser.js +179 -200
  199. package/lib/javascript/JavascriptParserHelpers.js +20 -21
  200. package/lib/javascript/StartupHelpers.js +41 -13
  201. package/lib/json/JsonGenerator.js +7 -13
  202. package/lib/json/JsonModulesPlugin.js +1 -4
  203. package/lib/json/JsonParser.js +5 -3
  204. package/lib/library/AmdLibraryPlugin.js +12 -16
  205. package/lib/library/AssignLibraryPlugin.js +8 -10
  206. package/lib/library/EnableLibraryPlugin.js +15 -14
  207. package/lib/library/JsonpLibraryPlugin.js +2 -1
  208. package/lib/library/ModernModuleLibraryPlugin.js +8 -6
  209. package/lib/library/ModuleLibraryPlugin.js +2 -1
  210. package/lib/library/SystemLibraryPlugin.js +2 -1
  211. package/lib/library/UmdLibraryPlugin.js +66 -92
  212. package/lib/logging/Logger.js +32 -4
  213. package/lib/logging/createConsoleLogger.js +12 -13
  214. package/lib/logging/runtime.js +7 -8
  215. package/lib/logging/truncateArgs.js +5 -8
  216. package/lib/node/NodeWatchFileSystem.js +3 -18
  217. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  218. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  219. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
  220. package/lib/node/nodeConsole.js +22 -22
  221. package/lib/optimize/AggressiveMergingPlugin.js +2 -4
  222. package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
  223. package/lib/optimize/ConcatenatedModule.js +81 -51
  224. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  225. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
  226. package/lib/optimize/InnerGraph.js +17 -17
  227. package/lib/optimize/InnerGraphPlugin.js +8 -7
  228. package/lib/optimize/LimitChunkCountPlugin.js +2 -3
  229. package/lib/optimize/MangleExportsPlugin.js +1 -0
  230. package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
  231. package/lib/optimize/MinMaxSizeWarning.js +1 -1
  232. package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
  233. package/lib/optimize/RealContentHashPlugin.js +7 -10
  234. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  235. package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
  236. package/lib/optimize/SplitChunksPlugin.js +34 -30
  237. package/lib/performance/SizeLimitsPlugin.js +2 -2
  238. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
  239. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
  240. package/lib/rules/BasicEffectRulePlugin.js +3 -1
  241. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  242. package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
  243. package/lib/rules/RuleSetCompiler.js +41 -22
  244. package/lib/rules/UseEffectRulePlugin.js +36 -32
  245. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
  246. package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
  247. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
  248. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
  249. package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
  250. package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
  251. package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
  252. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
  253. package/lib/schemes/DataUriPlugin.js +1 -1
  254. package/lib/schemes/HttpUriPlugin.js +241 -126
  255. package/lib/serialization/BinaryMiddleware.js +44 -28
  256. package/lib/serialization/DateObjectSerializer.js +1 -0
  257. package/lib/serialization/ErrorObjectSerializer.js +2 -0
  258. package/lib/serialization/FileMiddleware.js +154 -106
  259. package/lib/serialization/MapObjectSerializer.js +2 -1
  260. package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
  261. package/lib/serialization/ObjectMiddleware.js +52 -56
  262. package/lib/serialization/PlainObjectSerializer.js +32 -6
  263. package/lib/serialization/RegExpObjectSerializer.js +1 -0
  264. package/lib/serialization/Serializer.js +4 -5
  265. package/lib/serialization/SerializerMiddleware.js +6 -6
  266. package/lib/serialization/SetObjectSerializer.js +2 -1
  267. package/lib/sharing/ConsumeSharedPlugin.js +116 -97
  268. package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
  269. package/lib/sharing/ProvideForSharedDependency.js +0 -1
  270. package/lib/sharing/ProvideSharedPlugin.js +2 -2
  271. package/lib/sharing/resolveMatchedConfigs.js +2 -1
  272. package/lib/sharing/utils.js +15 -27
  273. package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
  274. package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
  275. package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
  276. package/lib/stats/StatsFactory.js +127 -56
  277. package/lib/stats/StatsPrinter.js +75 -44
  278. package/lib/util/ArrayHelpers.js +8 -4
  279. package/lib/util/ArrayQueue.js +1 -1
  280. package/lib/util/AsyncQueue.js +31 -12
  281. package/lib/util/IterableHelpers.js +3 -4
  282. package/lib/util/LazyBucketSortedSet.js +60 -44
  283. package/lib/util/LazySet.js +13 -0
  284. package/lib/util/MapHelpers.js +1 -3
  285. package/lib/util/ParallelismFactorCalculator.js +1 -1
  286. package/lib/util/Queue.js +1 -1
  287. package/lib/util/Semaphore.js +4 -7
  288. package/lib/util/SetHelpers.js +5 -5
  289. package/lib/util/SortableSet.js +4 -3
  290. package/lib/util/StackedCacheMap.js +4 -6
  291. package/lib/util/StackedMap.js +1 -3
  292. package/lib/util/StringXor.js +0 -5
  293. package/lib/util/TupleQueue.js +1 -1
  294. package/lib/util/TupleSet.js +15 -5
  295. package/lib/util/URLAbsoluteSpecifier.js +7 -7
  296. package/lib/util/WeakTupleMap.js +19 -21
  297. package/lib/util/binarySearchBounds.js +5 -12
  298. package/lib/util/chainedImports.js +1 -1
  299. package/lib/util/cleverMerge.js +21 -19
  300. package/lib/util/comparators.js +57 -52
  301. package/lib/util/compileBooleanMatcher.js +3 -6
  302. package/lib/util/conventions.js +8 -11
  303. package/lib/util/createHash.js +9 -6
  304. package/lib/util/deprecation.js +22 -12
  305. package/lib/util/deterministicGrouping.js +19 -26
  306. package/lib/util/findGraphRoots.js +2 -2
  307. package/lib/util/fs.js +32 -32
  308. package/lib/util/hash/md4.js +2 -2
  309. package/lib/util/hash/wasm-hash.js +7 -7
  310. package/lib/util/hash/xxhash64.js +2 -2
  311. package/lib/util/identifier.js +81 -59
  312. package/lib/util/memoize.js +8 -10
  313. package/lib/util/mergeScope.js +6 -9
  314. package/lib/util/nonNumericOnlyHash.js +2 -2
  315. package/lib/util/numberHash.js +1 -6
  316. package/lib/util/objectToMap.js +0 -1
  317. package/lib/util/propertyAccess.js +2 -5
  318. package/lib/util/propertyName.js +1 -3
  319. package/lib/util/registerExternalSerializer.js +1 -1
  320. package/lib/util/runtime.js +109 -113
  321. package/lib/util/semver.js +29 -27
  322. package/lib/util/serialization.js +16 -1
  323. package/lib/util/smartGrouping.js +5 -5
  324. package/lib/util/source.js +1 -1
  325. package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
  326. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  327. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
  328. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  329. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
  330. package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
  331. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
  332. package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
  333. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
  334. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
  335. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  336. package/package.json +18 -17
  337. package/schemas/WebpackOptions.check.js +1 -1
  338. package/schemas/WebpackOptions.json +5 -0
  339. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  340. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  341. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  342. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  343. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  344. package/types.d.ts +681 -355
@@ -22,6 +22,7 @@ const {
22
22
  const createHash = require("./util/createHash");
23
23
 
24
24
  /** @typedef {import("estree").Expression} Expression */
25
+ /** @typedef {import("./Compilation").ValueCacheVersion} ValueCacheVersion */
25
26
  /** @typedef {import("./Compiler")} Compiler */
26
27
  /** @typedef {import("./Module").BuildInfo} BuildInfo */
27
28
  /** @typedef {import("./NormalModule")} NormalModule */
@@ -30,6 +31,7 @@ const createHash = require("./util/createHash");
30
31
  /** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
31
32
  /** @typedef {import("./javascript/JavascriptParser").Range} Range */
32
33
  /** @typedef {import("./logging/Logger").Logger} Logger */
34
+ /** @typedef {import("./util/createHash").Algorithm} Algorithm */
33
35
 
34
36
  /** @typedef {null|undefined|RegExp|Function|string|number|boolean|bigint|undefined} CodeValuePrimitive */
35
37
  /** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive|RuntimeValue>} CodeValue */
@@ -43,9 +45,11 @@ const createHash = require("./util/createHash");
43
45
  * @property {string|function(): string=} version
44
46
  */
45
47
 
48
+ /** @typedef {function({ module: NormalModule, key: string, readonly version: ValueCacheVersion }): CodeValuePrimitive} GeneratorFn */
49
+
46
50
  class RuntimeValue {
47
51
  /**
48
- * @param {function({ module: NormalModule, key: string, readonly version: string | undefined }): CodeValuePrimitive} fn generator function
52
+ * @param {GeneratorFn} fn generator function
49
53
  * @param {true | string[] | RuntimeValueOptions=} options options
50
54
  */
51
55
  constructor(fn, options) {
@@ -64,7 +68,7 @@ class RuntimeValue {
64
68
 
65
69
  /**
66
70
  * @param {JavascriptParser} parser the parser
67
- * @param {Map<string, string | Set<string>>} valueCacheVersions valueCacheVersions
71
+ * @param {Map<string, ValueCacheVersion>} valueCacheVersions valueCacheVersions
68
72
  * @param {string} key the defined key
69
73
  * @returns {CodeValuePrimitive} code
70
74
  */
@@ -75,22 +79,26 @@ class RuntimeValue {
75
79
  } else {
76
80
  if (this.options.fileDependencies) {
77
81
  for (const dep of this.options.fileDependencies) {
78
- buildInfo.fileDependencies.add(dep);
82
+ /** @type {NonNullable<BuildInfo["fileDependencies"]>} */
83
+ (buildInfo.fileDependencies).add(dep);
79
84
  }
80
85
  }
81
86
  if (this.options.contextDependencies) {
82
87
  for (const dep of this.options.contextDependencies) {
83
- buildInfo.contextDependencies.add(dep);
88
+ /** @type {NonNullable<BuildInfo["contextDependencies"]>} */
89
+ (buildInfo.contextDependencies).add(dep);
84
90
  }
85
91
  }
86
92
  if (this.options.missingDependencies) {
87
93
  for (const dep of this.options.missingDependencies) {
88
- buildInfo.missingDependencies.add(dep);
94
+ /** @type {NonNullable<BuildInfo["missingDependencies"]>} */
95
+ (buildInfo.missingDependencies).add(dep);
89
96
  }
90
97
  }
91
98
  if (this.options.buildDependencies) {
92
99
  for (const dep of this.options.buildDependencies) {
93
- buildInfo.buildDependencies.add(dep);
100
+ /** @type {NonNullable<BuildInfo["buildDependencies"]>} */
101
+ (buildInfo.buildDependencies).add(dep);
94
102
  }
95
103
  }
96
104
  }
@@ -99,9 +107,7 @@ class RuntimeValue {
99
107
  module: parser.state.module,
100
108
  key,
101
109
  get version() {
102
- return /** @type {string} */ (
103
- valueCacheVersions.get(VALUE_DEP_PREFIX + key)
104
- );
110
+ return valueCacheVersions.get(VALUE_DEP_PREFIX + key);
105
111
  }
106
112
  });
107
113
  }
@@ -120,19 +126,22 @@ class RuntimeValue {
120
126
  * @returns {Set<string> | undefined} used keys
121
127
  */
122
128
  function getObjKeys(properties) {
123
- if (!properties) return undefined;
129
+ if (!properties) return;
124
130
  return new Set([...properties].map(p => p.id));
125
131
  }
126
132
 
133
+ /** @typedef {Set<string> | null} ObjKeys */
134
+ /** @typedef {boolean | undefined | null} AsiSafe */
135
+
127
136
  /**
128
137
  * @param {any[]|{[k: string]: any}} obj obj
129
138
  * @param {JavascriptParser} parser Parser
130
- * @param {Map<string, string | Set<string>>} valueCacheVersions valueCacheVersions
139
+ * @param {Map<string, ValueCacheVersion>} valueCacheVersions valueCacheVersions
131
140
  * @param {string} key the defined key
132
141
  * @param {RuntimeTemplate} runtimeTemplate the runtime template
133
142
  * @param {Logger} logger the logger object
134
- * @param {boolean|undefined|null=} asiSafe asi safe (undefined: unknown, null: unneeded)
135
- * @param {Set<string>|undefined=} objKeys used keys
143
+ * @param {AsiSafe=} asiSafe asi safe (undefined: unknown, null: unneeded)
144
+ * @param {ObjKeys=} objKeys used keys
136
145
  * @returns {string} code converted to string that evaluates
137
146
  */
138
147
  const stringifyObj = (
@@ -146,7 +155,7 @@ const stringifyObj = (
146
155
  objKeys
147
156
  ) => {
148
157
  let code;
149
- let arr = Array.isArray(obj);
158
+ const arr = Array.isArray(obj);
150
159
  if (arr) {
151
160
  code = `[${
152
161
  /** @type {any[]} */ (obj)
@@ -166,25 +175,20 @@ const stringifyObj = (
166
175
  } else {
167
176
  let keys = Object.keys(obj);
168
177
  if (objKeys) {
169
- if (objKeys.size === 0) keys = [];
170
- else keys = keys.filter(k => objKeys.has(k));
178
+ keys = objKeys.size === 0 ? [] : keys.filter(k => objKeys.has(k));
171
179
  }
172
180
  code = `{${keys
173
181
  .map(key => {
174
182
  const code = /** @type {{[k: string]: any}} */ (obj)[key];
175
- return (
176
- JSON.stringify(key) +
177
- ":" +
178
- toCode(
179
- code,
180
- parser,
181
- valueCacheVersions,
182
- key,
183
- runtimeTemplate,
184
- logger,
185
- null
186
- )
187
- );
183
+ return `${JSON.stringify(key)}:${toCode(
184
+ code,
185
+ parser,
186
+ valueCacheVersions,
187
+ key,
188
+ runtimeTemplate,
189
+ logger,
190
+ null
191
+ )}`;
188
192
  })
189
193
  .join(",")}}`;
190
194
  }
@@ -205,12 +209,12 @@ const stringifyObj = (
205
209
  * Convert code to a string that evaluates
206
210
  * @param {CodeValue} code Code to evaluate
207
211
  * @param {JavascriptParser} parser Parser
208
- * @param {Map<string, string | Set<string>>} valueCacheVersions valueCacheVersions
212
+ * @param {Map<string, ValueCacheVersion>} valueCacheVersions valueCacheVersions
209
213
  * @param {string} key the defined key
210
214
  * @param {RuntimeTemplate} runtimeTemplate the runtime template
211
215
  * @param {Logger} logger the logger object
212
- * @param {boolean|undefined|null=} asiSafe asi safe (undefined: unknown, null: unneeded)
213
- * @param {Set<string>|undefined=} objKeys used keys
216
+ * @param {boolean | undefined | null=} asiSafe asi safe (undefined: unknown, null: unneeded)
217
+ * @param {ObjKeys=} objKeys used keys
214
218
  * @returns {string} code converted to string that evaluates
215
219
  */
216
220
  const toCode = (
@@ -248,7 +252,7 @@ const toCode = (
248
252
  return code.toString();
249
253
  }
250
254
  if (typeof code === "function" && code.toString) {
251
- return "(" + code.toString() + ")";
255
+ return `(${code.toString()})`;
252
256
  }
253
257
  if (typeof code === "object") {
254
258
  return stringifyObj(
@@ -267,7 +271,7 @@ const toCode = (
267
271
  ? `${code}n`
268
272
  : `BigInt("${code}")`;
269
273
  }
270
- return code + "";
274
+ return `${code}`;
271
275
  };
272
276
 
273
277
  const strCode = transformToCode();
@@ -298,20 +302,20 @@ const toCacheVersion = code => {
298
302
  return code.toString();
299
303
  }
300
304
  if (typeof code === "function" && code.toString) {
301
- return "(" + code.toString() + ")";
305
+ return `(${code.toString()})`;
302
306
  }
303
307
  if (typeof code === "object") {
304
308
  const items = Object.keys(code).map(key => ({
305
309
  key,
306
310
  value: toCacheVersion(/** @type {Record<string, any>} */ (code)[key])
307
311
  }));
308
- if (items.some(({ value }) => value === undefined)) return undefined;
312
+ if (items.some(({ value }) => value === undefined)) return;
309
313
  return `{${items.map(({ key, value }) => `${key}: ${value}`).join(", ")}}`;
310
314
  }
311
315
  if (typeof code === "bigint") {
312
316
  return `${code}n`;
313
317
  }
314
- return code + "";
318
+ return `${code}`;
315
319
  };
316
320
 
317
321
  const PLUGIN_NAME = "DefinePlugin";
@@ -333,7 +337,7 @@ class DefinePlugin {
333
337
  }
334
338
 
335
339
  /**
336
- * @param {function({ module: NormalModule, key: string, readonly version: string | undefined }): CodeValuePrimitive} fn generator function
340
+ * @param {GeneratorFn} fn generator function
337
341
  * @param {true | string[] | RuntimeValueOptions=} options options
338
342
  * @returns {RuntimeValue} runtime value
339
343
  */
@@ -358,11 +362,13 @@ class DefinePlugin {
358
362
  );
359
363
  const { runtimeTemplate } = compilation;
360
364
 
361
- const mainHash = createHash(compilation.outputOptions.hashFunction);
365
+ const mainHash = createHash(
366
+ /** @type {Algorithm} */
367
+ (compilation.outputOptions.hashFunction)
368
+ );
362
369
  mainHash.update(
363
- /** @type {string} */ (
364
- compilation.valueCacheVersions.get(VALUE_DEP_MAIN)
365
- ) || ""
370
+ /** @type {string} */
371
+ (compilation.valueCacheVersions.get(VALUE_DEP_MAIN)) || ""
366
372
  );
367
373
 
368
374
  /**
@@ -385,15 +391,22 @@ class DefinePlugin {
385
391
  * @param {string} key key
386
392
  */
387
393
  const addValueDependency = key => {
388
- const buildInfo = /** @type {BuildInfo} */ (
389
- parser.state.module.buildInfo
390
- );
391
- buildInfo.valueDependencies.set(
394
+ const buildInfo =
395
+ /** @type {BuildInfo} */
396
+ (parser.state.module.buildInfo);
397
+ /** @type {NonNullable<BuildInfo["valueDependencies"]>} */
398
+ (buildInfo.valueDependencies).set(
392
399
  VALUE_DEP_PREFIX + key,
393
400
  compilation.valueCacheVersions.get(VALUE_DEP_PREFIX + key)
394
401
  );
395
402
  };
396
403
 
404
+ /**
405
+ * @template {Function} T
406
+ * @param {string} key key
407
+ * @param {T} fn fn
408
+ * @returns {function(TODO): TODO} result
409
+ */
397
410
  const withValueDependency =
398
411
  (key, fn) =>
399
412
  (...args) => {
@@ -408,7 +421,7 @@ class DefinePlugin {
408
421
  * @returns {void}
409
422
  */
410
423
  const walkDefinitions = (definitions, prefix) => {
411
- Object.keys(definitions).forEach(key => {
424
+ for (const key of Object.keys(definitions)) {
412
425
  const code = definitions[key];
413
426
  if (
414
427
  code &&
@@ -418,14 +431,14 @@ class DefinePlugin {
418
431
  ) {
419
432
  walkDefinitions(
420
433
  /** @type {Record<string, CodeValue>} */ (code),
421
- prefix + key + "."
434
+ `${prefix + key}.`
422
435
  );
423
436
  applyObjectDefine(prefix + key, code);
424
- return;
437
+ continue;
425
438
  }
426
439
  applyDefineKey(prefix, key);
427
440
  applyDefine(prefix + key, code);
428
- });
441
+ }
429
442
  };
430
443
 
431
444
  /**
@@ -436,13 +449,13 @@ class DefinePlugin {
436
449
  */
437
450
  const applyDefineKey = (prefix, key) => {
438
451
  const splittedKey = key.split(".");
439
- splittedKey.slice(1).forEach((_, i) => {
452
+ for (const [i, _] of splittedKey.slice(1).entries()) {
440
453
  const fullKey = prefix + splittedKey.slice(0, i + 1).join(".");
441
454
  parser.hooks.canRename.for(fullKey).tap(PLUGIN_NAME, () => {
442
455
  addValueDependency(key);
443
456
  return true;
444
457
  });
445
- });
458
+ }
446
459
  };
447
460
 
448
461
  /**
@@ -505,7 +518,7 @@ class DefinePlugin {
505
518
  );
506
519
 
507
520
  if (parser.scope.inShorthand) {
508
- strCode = parser.scope.inShorthand + ":" + strCode;
521
+ strCode = `${parser.scope.inShorthand}:${strCode}`;
509
522
  }
510
523
 
511
524
  if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
@@ -516,9 +529,8 @@ class DefinePlugin {
516
529
  return toConstantDependency(parser, strCode, [
517
530
  RuntimeGlobals.requireScope
518
531
  ])(expr);
519
- } else {
520
- return toConstantDependency(parser, strCode)(expr);
521
532
  }
533
+ return toConstantDependency(parser, strCode)(expr);
522
534
  });
523
535
  }
524
536
  parser.hooks.evaluateTypeof.for(key).tap(PLUGIN_NAME, expr => {
@@ -542,9 +554,7 @@ class DefinePlugin {
542
554
  logger,
543
555
  null
544
556
  );
545
- const typeofCode = isTypeof
546
- ? codeCode
547
- : "typeof (" + codeCode + ")";
557
+ const typeofCode = isTypeof ? codeCode : `typeof (${codeCode})`;
548
558
  const res = parser.evaluate(typeofCode);
549
559
  recurseTypeof = false;
550
560
  res.setRange(/** @type {Range} */ (expr.range));
@@ -561,9 +571,7 @@ class DefinePlugin {
561
571
  logger,
562
572
  null
563
573
  );
564
- const typeofCode = isTypeof
565
- ? codeCode
566
- : "typeof (" + codeCode + ")";
574
+ const typeofCode = isTypeof ? codeCode : `typeof (${codeCode})`;
567
575
  const res = parser.evaluate(typeofCode);
568
576
  if (!res.isString()) return;
569
577
  return toConstantDependency(
@@ -611,7 +619,7 @@ class DefinePlugin {
611
619
  );
612
620
 
613
621
  if (parser.scope.inShorthand) {
614
- strCode = parser.scope.inShorthand + ":" + strCode;
622
+ strCode = `${parser.scope.inShorthand}:${strCode}`;
615
623
  }
616
624
 
617
625
  if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
@@ -622,9 +630,8 @@ class DefinePlugin {
622
630
  return toConstantDependency(parser, strCode, [
623
631
  RuntimeGlobals.requireScope
624
632
  ])(expr);
625
- } else {
626
- return toConstantDependency(parser, strCode)(expr);
627
633
  }
634
+ return toConstantDependency(parser, strCode)(expr);
628
635
  });
629
636
  parser.hooks.typeof
630
637
  .for(key)
@@ -657,11 +664,11 @@ class DefinePlugin {
657
664
  * @returns {void}
658
665
  */
659
666
  const walkDefinitionsForValues = (definitions, prefix) => {
660
- Object.keys(definitions).forEach(key => {
667
+ for (const key of Object.keys(definitions)) {
661
668
  const code = definitions[key];
662
669
  const version = toCacheVersion(code);
663
670
  const name = VALUE_DEP_PREFIX + prefix + key;
664
- mainHash.update("|" + prefix + key);
671
+ mainHash.update(`|${prefix}${key}`);
665
672
  const oldVersion = compilation.valueCacheVersions.get(name);
666
673
  if (oldVersion === undefined) {
667
674
  compilation.valueCacheVersions.set(name, version);
@@ -681,10 +688,10 @@ class DefinePlugin {
681
688
  ) {
682
689
  walkDefinitionsForValues(
683
690
  /** @type {Record<string, CodeValue>} */ (code),
684
- prefix + key + "."
691
+ `${prefix + key}.`
685
692
  );
686
693
  }
687
- });
694
+ }
688
695
  };
689
696
 
690
697
  walkDefinitionsForValues(definitions, "");
@@ -36,6 +36,10 @@ const makeSerializable = require("./util/makeSerializable");
36
36
  /** @typedef {import("./util/Hash")} Hash */
37
37
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
38
38
 
39
+ /** @typedef {string} SourceRequest */
40
+ /** @typedef {"require" | "object"} Type */
41
+ /** @typedef {TODO} Data */
42
+
39
43
  const TYPES = new Set(["javascript"]);
40
44
  const RUNTIME_REQUIREMENTS = new Set([
41
45
  RuntimeGlobals.module,
@@ -44,9 +48,9 @@ const RUNTIME_REQUIREMENTS = new Set([
44
48
 
45
49
  class DelegatedModule extends Module {
46
50
  /**
47
- * @param {string} sourceRequest source request
48
- * @param {TODO} data data
49
- * @param {"require" | "object"} type type
51
+ * @param {SourceRequest} sourceRequest source request
52
+ * @param {Data} data data
53
+ * @param {Type} type type
50
54
  * @param {string} userRequest user request
51
55
  * @param {string | Module} originalRequest original request
52
56
  */
@@ -7,15 +7,28 @@
7
7
 
8
8
  const DelegatedModule = require("./DelegatedModule");
9
9
 
10
+ /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
11
+ /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
12
+ /** @typedef {import("./DelegatedModule").Data} Data */
13
+ /** @typedef {import("./DelegatedModule").SourceRequest} SourceRequest */
14
+ /** @typedef {import("./DelegatedModule").Type} Type */
10
15
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
11
16
 
12
- // options.source
13
- // options.type
14
- // options.context
15
- // options.scope
16
- // options.content
17
- // options.associatedObjectForCache
17
+ /**
18
+ * @typedef {object} Options
19
+ * @property {SourceRequest} source source
20
+ * @property {NonNullable<DllReferencePluginOptions["context"]>} context absolute context path to which lib ident is relative to
21
+ * @property {DllReferencePluginOptionsContent} content content
22
+ * @property {DllReferencePluginOptions["type"]} type type
23
+ * @property {DllReferencePluginOptions["extensions"]} extensions extensions
24
+ * @property {DllReferencePluginOptions["scope"]} scope scope
25
+ * @property {object=} associatedObjectForCache object for caching
26
+ */
27
+
18
28
  class DelegatedModuleFactoryPlugin {
29
+ /**
30
+ * @param {Options} options options
31
+ */
19
32
  constructor(options) {
20
33
  this.options = options;
21
34
  options.type = options.type || "require";
@@ -35,7 +48,7 @@ class DelegatedModuleFactoryPlugin {
35
48
  const [dependency] = data.dependencies;
36
49
  const { request } = dependency;
37
50
  if (request && request.startsWith(`${scope}/`)) {
38
- const innerRequest = "." + request.slice(scope.length);
51
+ const innerRequest = `.${request.slice(scope.length)}`;
39
52
  let resolved;
40
53
  if (innerRequest in this.options.content) {
41
54
  resolved = this.options.content[innerRequest];
@@ -44,14 +57,17 @@ class DelegatedModuleFactoryPlugin {
44
57
  new DelegatedModule(
45
58
  this.options.source,
46
59
  resolved,
47
- this.options.type,
60
+ /** @type {Type} */ (this.options.type),
48
61
  innerRequest,
49
62
  request
50
63
  )
51
64
  );
52
65
  }
53
- for (let i = 0; i < this.options.extensions.length; i++) {
54
- const extension = this.options.extensions[i];
66
+ const extensions =
67
+ /** @type {string[]} */
68
+ (this.options.extensions);
69
+ for (let i = 0; i < extensions.length; i++) {
70
+ const extension = extensions[i];
55
71
  const requestPlusExt = innerRequest + extension;
56
72
  if (requestPlusExt in this.options.content) {
57
73
  resolved = this.options.content[requestPlusExt];
@@ -60,7 +76,7 @@ class DelegatedModuleFactoryPlugin {
60
76
  new DelegatedModule(
61
77
  this.options.source,
62
78
  resolved,
63
- this.options.type,
79
+ /** @type {Type} */ (this.options.type),
64
80
  requestPlusExt,
65
81
  request + extension
66
82
  )
@@ -76,17 +92,15 @@ class DelegatedModuleFactoryPlugin {
76
92
  "DelegatedModuleFactoryPlugin",
77
93
  module => {
78
94
  const request = module.libIdent(this.options);
79
- if (request) {
80
- if (request in this.options.content) {
81
- const resolved = this.options.content[request];
82
- return new DelegatedModule(
83
- this.options.source,
84
- resolved,
85
- this.options.type,
86
- request,
87
- module
88
- );
89
- }
95
+ if (request && request in this.options.content) {
96
+ const resolved = this.options.content[request];
97
+ return new DelegatedModule(
98
+ this.options.source,
99
+ resolved,
100
+ /** @type {Type} */ (this.options.type),
101
+ request,
102
+ module
103
+ );
90
104
  }
91
105
  return module;
92
106
  }
@@ -9,8 +9,12 @@ const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
9
9
  const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
10
10
 
11
11
  /** @typedef {import("./Compiler")} Compiler */
12
+ /** @typedef {import("./DelegatedModuleFactoryPlugin").Options} Options */
12
13
 
13
14
  class DelegatedPlugin {
15
+ /**
16
+ * @param {Options} options options
17
+ */
14
18
  constructor(options) {
15
19
  this.options = options;
16
20
  }
@@ -46,7 +46,6 @@ class DependenciesBlock {
46
46
  /**
47
47
  * Adds a DependencyBlock to DependencyBlock relationship.
48
48
  * This is used for when a Module has a AsyncDependencyBlock tie (for code-splitting)
49
- *
50
49
  * @param {AsyncDependenciesBlock} block block being added
51
50
  * @returns {void}
52
51
  */
package/lib/Dependency.js CHANGED
@@ -67,7 +67,7 @@ const memoize = require("./util/memoize");
67
67
  * @typedef {object} ExportsSpec
68
68
  * @property {(string | ExportSpec)[] | true | null} exports exported names, true for unknown exports or null for no exports
69
69
  * @property {Set<string>=} excludeExports when exports = true, list of unaffected exports
70
- * @property {Set<string>=} hideExports list of maybe prior exposed, but now hidden exports
70
+ * @property {(Set<string> | null)=} hideExports list of maybe prior exposed, but now hidden exports
71
71
  * @property {ModuleGraphConnection=} from when reexported: from which module
72
72
  * @property {number=} priority when reexported: with which priority
73
73
  * @property {boolean=} canMangle can the export be renamed (defaults to true)
@@ -85,9 +85,9 @@ const memoize = require("./util/memoize");
85
85
 
86
86
  const TRANSITIVE = Symbol("transitive");
87
87
 
88
- const getIgnoredModule = memoize(() => {
89
- return new RawModule("/* (ignored) */", `ignored`, `(ignored)`);
90
- });
88
+ const getIgnoredModule = memoize(
89
+ () => new RawModule("/* (ignored) */", "ignored", "(ignored)")
90
+ );
91
91
 
92
92
  class Dependency {
93
93
  constructor() {
@@ -163,16 +163,8 @@ class Dependency {
163
163
  this._locEL = 0;
164
164
  this._locEC = 0;
165
165
  }
166
- if ("index" in loc) {
167
- this._locI = loc.index;
168
- } else {
169
- this._locI = undefined;
170
- }
171
- if ("name" in loc) {
172
- this._locN = loc.name;
173
- } else {
174
- this._locN = undefined;
175
- }
166
+ this._locI = "index" in loc ? loc.index : undefined;
167
+ this._locN = "name" in loc ? loc.name : undefined;
176
168
  this._loc = loc;
177
169
  }
178
170
 
@@ -336,6 +328,8 @@ Dependency.NO_EXPORTS_REFERENCED = [];
336
328
  /** @type {string[][]} */
337
329
  Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
338
330
 
331
+ // eslint-disable-next-line no-warning-comments
332
+ // @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
339
333
  Object.defineProperty(Dependency.prototype, "module", {
340
334
  /**
341
335
  * @deprecated
@@ -358,6 +352,8 @@ Object.defineProperty(Dependency.prototype, "module", {
358
352
  }
359
353
  });
360
354
 
355
+ // eslint-disable-next-line no-warning-comments
356
+ // @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
361
357
  Object.defineProperty(Dependency.prototype, "disconnect", {
362
358
  get() {
363
359
  throw new Error(
@@ -10,12 +10,14 @@ const DllEntryDependency = require("./dependencies/DllEntryDependency");
10
10
  const EntryDependency = require("./dependencies/EntryDependency");
11
11
 
12
12
  /** @typedef {import("./Compiler")} Compiler */
13
+ /** @typedef {string[]} Entries */
14
+ /** @typedef {{ name: string, filename: TODO }} Options */
13
15
 
14
16
  class DllEntryPlugin {
15
17
  /**
16
18
  * @param {string} context context
17
- * @param {string[]} entries entry names
18
- * @param {TODO} options options
19
+ * @param {Entries} entries entry names
20
+ * @param {Options} options options
19
21
  */
20
22
  constructor(context, entries, options) {
21
23
  this.context = context;
@@ -17,6 +17,7 @@ class DllModuleFactory extends ModuleFactory {
17
17
  super();
18
18
  this.hooks = Object.freeze({});
19
19
  }
20
+
20
21
  /**
21
22
  * @param {ModuleFactoryCreateData} data data object
22
23
  * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
package/lib/DllPlugin.js CHANGED
@@ -12,6 +12,8 @@ const createSchemaValidation = require("./util/create-schema-validation");
12
12
 
13
13
  /** @typedef {import("../declarations/plugins/DllPlugin").DllPluginOptions} DllPluginOptions */
14
14
  /** @typedef {import("./Compiler")} Compiler */
15
+ /** @typedef {import("./DllEntryPlugin").Entries} Entries */
16
+ /** @typedef {import("./DllEntryPlugin").Options} Options */
15
17
 
16
18
  const validate = createSchemaValidation(
17
19
  require("../schemas/plugins/DllPlugin.check.js"),
@@ -43,13 +45,13 @@ class DllPlugin {
43
45
  compiler.hooks.entryOption.tap("DllPlugin", (context, entry) => {
44
46
  if (typeof entry !== "function") {
45
47
  for (const name of Object.keys(entry)) {
46
- const options = {
47
- name,
48
- filename: entry.filename
49
- };
50
- new DllEntryPlugin(context, entry[name].import, options).apply(
51
- compiler
52
- );
48
+ /** @type {Options} */
49
+ const options = { name, filename: entry.filename };
50
+ new DllEntryPlugin(
51
+ context,
52
+ /** @type {Entries} */ (entry[name].import),
53
+ options
54
+ ).apply(compiler);
53
55
  }
54
56
  } else {
55
57
  throw new Error(