webpack 5.104.1 → 5.105.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 (279) hide show
  1. package/bin/webpack.js +6 -3
  2. package/lib/APIPlugin.js +85 -15
  3. package/lib/AbstractMethodError.js +1 -0
  4. package/lib/AsyncDependenciesBlock.js +13 -1
  5. package/lib/AsyncDependencyToInitialChunkError.js +1 -0
  6. package/lib/AutomaticPrefetchPlugin.js +1 -1
  7. package/lib/BannerPlugin.js +2 -0
  8. package/lib/CacheFacade.js +2 -2
  9. package/lib/CaseSensitiveModulesWarning.js +1 -0
  10. package/lib/Chunk.js +8 -4
  11. package/lib/ChunkGraph.js +30 -9
  12. package/lib/ChunkGroup.js +6 -3
  13. package/lib/ChunkRenderError.js +2 -0
  14. package/lib/CleanPlugin.js +4 -1
  15. package/lib/CodeGenerationError.js +7 -1
  16. package/lib/CodeGenerationResults.js +10 -3
  17. package/lib/CommentCompilationWarning.js +2 -1
  18. package/lib/Compilation.js +280 -236
  19. package/lib/Compiler.js +3 -2
  20. package/lib/ConcatenationScope.js +2 -1
  21. package/lib/ConcurrentCompilationError.js +3 -3
  22. package/lib/ContextModule.js +248 -111
  23. package/lib/ContextModuleFactory.js +14 -2
  24. package/lib/DefinePlugin.js +3 -1
  25. package/lib/DelegatedModule.js +6 -0
  26. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  27. package/lib/Dependency.js +6 -1
  28. package/lib/DependencyTemplates.js +3 -2
  29. package/lib/DllModule.js +2 -0
  30. package/lib/DllReferencePlugin.js +1 -0
  31. package/lib/DotenvPlugin.js +11 -5
  32. package/lib/DynamicEntryPlugin.js +1 -0
  33. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  34. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  35. package/lib/ExportsInfo.js +8 -4
  36. package/lib/ExternalModule.js +16 -0
  37. package/lib/FalseIIFEUmdWarning.js +1 -0
  38. package/lib/FileSystemInfo.js +49 -25
  39. package/lib/FlagDependencyExportsPlugin.js +8 -1
  40. package/lib/FlagDependencyUsagePlugin.js +9 -7
  41. package/lib/HarmonyLinkingError.js +1 -0
  42. package/lib/HookWebpackError.js +2 -0
  43. package/lib/HotModuleReplacementPlugin.js +16 -2
  44. package/lib/InitFragment.js +1 -0
  45. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  46. package/lib/LibManifestPlugin.js +1 -0
  47. package/lib/ManifestPlugin.js +4 -1
  48. package/lib/Module.js +7 -4
  49. package/lib/ModuleBuildError.js +3 -1
  50. package/lib/ModuleDependencyError.js +1 -0
  51. package/lib/ModuleDependencyWarning.js +1 -0
  52. package/lib/ModuleError.js +2 -1
  53. package/lib/ModuleFilenameHelpers.js +2 -1
  54. package/lib/ModuleGraph.js +3 -0
  55. package/lib/ModuleGraphConnection.js +10 -1
  56. package/lib/ModuleHashingError.js +2 -0
  57. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  58. package/lib/ModuleNotFoundError.js +1 -0
  59. package/lib/ModuleParseError.js +5 -1
  60. package/lib/ModuleProfile.js +1 -1
  61. package/lib/ModuleRestoreError.js +2 -0
  62. package/lib/ModuleSourceTypeConstants.js +1 -11
  63. package/lib/ModuleStoreError.js +2 -0
  64. package/lib/ModuleWarning.js +3 -1
  65. package/lib/MultiCompiler.js +11 -7
  66. package/lib/MultiWatching.js +2 -2
  67. package/lib/NoModeWarning.js +1 -0
  68. package/lib/NodeStuffInWebError.js +1 -0
  69. package/lib/NormalModule.js +26 -5
  70. package/lib/NormalModuleFactory.js +20 -4
  71. package/lib/OptionsApply.js +3 -1
  72. package/lib/ProgressPlugin.js +4 -0
  73. package/lib/RawModule.js +2 -0
  74. package/lib/RuntimeModule.js +10 -0
  75. package/lib/RuntimePlugin.js +7 -9
  76. package/lib/RuntimeTemplate.js +14 -7
  77. package/lib/SourceMapDevToolPlugin.js +30 -23
  78. package/lib/Template.js +10 -5
  79. package/lib/TemplatedPathPlugin.js +4 -2
  80. package/lib/UnhandledSchemeError.js +1 -0
  81. package/lib/UnsupportedFeatureWarning.js +1 -0
  82. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  83. package/lib/WatchIgnorePlugin.js +1 -1
  84. package/lib/Watching.js +5 -0
  85. package/lib/WebpackError.js +4 -0
  86. package/lib/WebpackOptionsApply.js +60 -40
  87. package/lib/asset/AssetBytesGenerator.js +1 -0
  88. package/lib/asset/AssetGenerator.js +9 -3
  89. package/lib/asset/AssetModulesPlugin.js +33 -2
  90. package/lib/asset/AssetSourceGenerator.js +1 -0
  91. package/lib/asset/RawDataUrlModule.js +4 -0
  92. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  93. package/lib/buildChunkGraph.js +31 -2
  94. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  95. package/lib/cache/PackFileCacheStrategy.js +41 -8
  96. package/lib/cache/getLazyHashedEtag.js +13 -4
  97. package/lib/cache/mergeEtags.js +3 -1
  98. package/lib/cli.js +3 -1
  99. package/lib/config/defaults.js +65 -44
  100. package/lib/config/normalization.js +96 -0
  101. package/lib/container/ContainerEntryModule.js +4 -0
  102. package/lib/container/FallbackModule.js +2 -0
  103. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  104. package/lib/container/RemoteModule.js +19 -0
  105. package/lib/css/CssGenerator.js +31 -4
  106. package/lib/css/CssModulesPlugin.js +26 -30
  107. package/lib/css/CssParser.js +12 -9
  108. package/lib/debug/ProfilingPlugin.js +1 -0
  109. package/lib/dependencies/AMDDefineDependency.js +3 -1
  110. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  111. package/lib/dependencies/AMDPlugin.js +1 -1
  112. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  113. package/lib/dependencies/CachedConstDependency.js +1 -0
  114. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  115. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  116. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  117. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  118. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  119. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  120. package/lib/dependencies/ConstDependency.js +1 -0
  121. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  122. package/lib/dependencies/ContextElementDependency.js +1 -0
  123. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  124. package/lib/dependencies/CssIcssExportDependency.js +5 -4
  125. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  126. package/lib/dependencies/CssUrlDependency.js +2 -3
  127. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  128. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  129. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  130. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
  131. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  132. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  133. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  134. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  135. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
  136. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  137. package/lib/dependencies/ImportDependency.js +1 -0
  138. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  139. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  140. package/lib/dependencies/ImportParserPlugin.js +7 -12
  141. package/lib/dependencies/LoaderPlugin.js +3 -0
  142. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  143. package/lib/dependencies/ModuleDependency.js +1 -0
  144. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  145. package/lib/dependencies/ProvidedDependency.js +1 -0
  146. package/lib/dependencies/RequireContextPlugin.js +1 -0
  147. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  148. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  149. package/lib/dependencies/WorkerDependency.js +9 -3
  150. package/lib/dependencies/WorkerPlugin.js +1 -0
  151. package/lib/dependencies/getFunctionExpression.js +3 -1
  152. package/lib/errors/BuildCycleError.js +4 -1
  153. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  154. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  155. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  156. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  157. package/lib/hmr/lazyCompilationBackend.js +3 -2
  158. package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
  159. package/lib/ids/IdHelpers.js +10 -8
  160. package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
  161. package/lib/ids/SyncModuleIdsPlugin.js +5 -1
  162. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  163. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  164. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  165. package/lib/javascript/JavascriptParser.js +47 -14
  166. package/lib/json/JsonParser.js +6 -0
  167. package/lib/library/AbstractLibraryPlugin.js +4 -1
  168. package/lib/library/AmdLibraryPlugin.js +2 -1
  169. package/lib/library/AssignLibraryPlugin.js +6 -2
  170. package/lib/library/EnableLibraryPlugin.js +1 -0
  171. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  172. package/lib/library/JsonpLibraryPlugin.js +1 -1
  173. package/lib/library/ModuleLibraryPlugin.js +130 -13
  174. package/lib/library/SystemLibraryPlugin.js +4 -1
  175. package/lib/library/UmdLibraryPlugin.js +4 -3
  176. package/lib/logging/createConsoleLogger.js +3 -0
  177. package/lib/logging/truncateArgs.js +1 -1
  178. package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
  179. package/lib/node/NodeTargetPlugin.js +1 -0
  180. package/lib/node/NodeWatchFileSystem.js +3 -0
  181. package/lib/node/nodeConsole.js +18 -1
  182. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  183. package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
  184. package/lib/optimize/ConcatenatedModule.js +33 -19
  185. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  186. package/lib/optimize/InnerGraph.js +5 -3
  187. package/lib/optimize/InnerGraphPlugin.js +25 -25
  188. package/lib/optimize/MangleExportsPlugin.js +14 -2
  189. package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
  190. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  191. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  192. package/lib/optimize/RealContentHashPlugin.js +35 -27
  193. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  194. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  195. package/lib/optimize/SplitChunksPlugin.js +14 -3
  196. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  197. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  198. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  199. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  200. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  201. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  202. package/lib/rules/RuleSetCompiler.js +2 -0
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  204. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  205. package/lib/runtime/CompatRuntimeModule.js +1 -0
  206. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  207. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
  208. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  209. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  210. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  211. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
  212. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  213. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  214. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  215. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  216. package/lib/schemes/HttpUriPlugin.js +27 -7
  217. package/lib/schemes/VirtualUrlPlugin.js +7 -2
  218. package/lib/serialization/BinaryMiddleware.js +4 -0
  219. package/lib/serialization/FileMiddleware.js +9 -4
  220. package/lib/serialization/ObjectMiddleware.js +34 -11
  221. package/lib/serialization/PlainObjectSerializer.js +2 -0
  222. package/lib/sharing/ConsumeSharedModule.js +60 -0
  223. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  224. package/lib/sharing/ProvideSharedModule.js +4 -0
  225. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  226. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  227. package/lib/sharing/utils.js +8 -6
  228. package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
  229. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  230. package/lib/stats/StatsFactory.js +2 -2
  231. package/lib/url/URLParserPlugin.js +4 -3
  232. package/lib/util/AppendOnlyStackedSet.js +57 -0
  233. package/lib/util/Hash.js +1 -0
  234. package/lib/util/IterableHelpers.js +1 -0
  235. package/lib/util/LazyBucketSortedSet.js +1 -0
  236. package/lib/util/LazySet.js +1 -0
  237. package/lib/util/ParallelismFactorCalculator.js +1 -0
  238. package/lib/util/SortableSet.js +1 -0
  239. package/lib/util/StringXor.js +1 -0
  240. package/lib/util/binarySearchBounds.js +15 -8
  241. package/lib/util/chainedImports.js +1 -1
  242. package/lib/util/cleverMerge.js +6 -1
  243. package/lib/util/comparators.js +21 -1
  244. package/lib/util/compileBooleanMatcher.js +3 -3
  245. package/lib/util/concatenate.js +3 -2
  246. package/lib/util/conventions.js +3 -2
  247. package/lib/util/deterministicGrouping.js +13 -1
  248. package/lib/util/extractSourceMap.js +12 -13
  249. package/lib/util/fs.js +15 -19
  250. package/lib/util/hash/BatchedHash.js +3 -0
  251. package/lib/util/hash/BulkUpdateHash.js +7 -1
  252. package/lib/util/hash/hash-digest.js +1 -0
  253. package/lib/util/hash/wasm-hash.js +16 -1
  254. package/lib/util/identifier.js +7 -2
  255. package/lib/util/magicComment.js +1 -1
  256. package/lib/util/propertyName.js +1 -1
  257. package/lib/util/registerExternalSerializer.js +1 -0
  258. package/lib/util/runtime.js +15 -1
  259. package/lib/util/semver.js +1 -0
  260. package/lib/util/serialization.js +2 -2
  261. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
  262. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  263. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  264. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  265. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  266. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  267. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  268. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  269. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  270. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  271. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  272. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  273. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  274. package/lib/webpack.js +13 -3
  275. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  276. package/package.json +20 -28
  277. package/schemas/WebpackOptions.check.js +1 -1
  278. package/schemas/WebpackOptions.json +71 -5
  279. package/types.d.ts +339 -93
@@ -54,10 +54,14 @@ class OccurrenceModuleIdsPlugin {
54
54
  const [usedIds, modulesInOccurrenceOrder] =
55
55
  getUsedModuleIdsAndModules(compilation);
56
56
 
57
+ /** @type {Map<Module, number>} */
57
58
  const occursInInitialChunksMap = new Map();
59
+ /** @type {Map<Module, number>} */
58
60
  const occursInAllChunksMap = new Map();
59
61
 
62
+ /** @type {Map<Module, number>} */
60
63
  const initialChunkChunkMap = new Map();
64
+ /** @type {Map<Module, number>} */
61
65
  const entryCountMap = new Map();
62
66
  for (const m of modulesInOccurrenceOrder) {
63
67
  let initial = 0;
@@ -115,8 +119,8 @@ class OccurrenceModuleIdsPlugin {
115
119
  for (const m of modulesInOccurrenceOrder) {
116
120
  const result =
117
121
  countOccursInEntry(m) +
118
- initialChunkChunkMap.get(m) +
119
- entryCountMap.get(m);
122
+ /** @type {number} */ (initialChunkChunkMap.get(m)) +
123
+ /** @type {number} */ (entryCountMap.get(m));
120
124
  occursInInitialChunksMap.set(m, result);
121
125
  }
122
126
  }
@@ -125,7 +129,7 @@ class OccurrenceModuleIdsPlugin {
125
129
  const result =
126
130
  countOccurs(m) +
127
131
  chunkGraph.getNumberOfModuleChunks(m) +
128
- entryCountMap.get(m);
132
+ /** @type {number} */ (entryCountMap.get(m));
129
133
  occursInAllChunksMap.set(m, result);
130
134
  }
131
135
 
@@ -135,13 +139,17 @@ class OccurrenceModuleIdsPlugin {
135
139
 
136
140
  modulesInOccurrenceOrder.sort((a, b) => {
137
141
  if (prioritiseInitial) {
138
- const aEntryOccurs = occursInInitialChunksMap.get(a);
139
- const bEntryOccurs = occursInInitialChunksMap.get(b);
142
+ const aEntryOccurs =
143
+ /** @type {number} */
144
+ (occursInInitialChunksMap.get(a));
145
+ const bEntryOccurs =
146
+ /** @type {number} */
147
+ (occursInInitialChunksMap.get(b));
140
148
  if (aEntryOccurs > bEntryOccurs) return -1;
141
149
  if (aEntryOccurs < bEntryOccurs) return 1;
142
150
  }
143
- const aOccurs = occursInAllChunksMap.get(a);
144
- const bOccurs = occursInAllChunksMap.get(b);
151
+ const aOccurs = /** @type {number} */ (occursInAllChunksMap.get(a));
152
+ const bOccurs = /** @type {number} */ (occursInAllChunksMap.get(b));
145
153
  if (aOccurs > bOccurs) return -1;
146
154
  if (aOccurs < bOccurs) return 1;
147
155
  return naturalCompare(a, b);
@@ -13,6 +13,8 @@ const { getUsedModuleIdsAndModules } = require("./IdHelpers");
13
13
  /** @typedef {import("../Module").ModuleId} ModuleId */
14
14
  /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
15
15
 
16
+ /** @typedef {{ [key: string]: ModuleId }} JSONContent */
17
+
16
18
  const plugin = "SyncModuleIdsPlugin";
17
19
 
18
20
  /**
@@ -58,7 +60,9 @@ class SyncModuleIdsPlugin {
58
60
  }
59
61
  return callback();
60
62
  }
63
+ /** @type {JSONContent} */
61
64
  const json = JSON.parse(/** @type {Buffer} */ (buffer).toString());
65
+ /** @type {Map<string, string | number | null>} */
62
66
  data = new Map();
63
67
  for (const key of Object.keys(json)) {
64
68
  data.set(key, json[key]);
@@ -71,7 +75,7 @@ class SyncModuleIdsPlugin {
71
75
  if (this._write) {
72
76
  compiler.hooks.emitRecords.tapAsync(plugin, (callback) => {
73
77
  if (!data || !dataChanged) return callback();
74
- /** @type {{[key: string]: ModuleId}} */
78
+ /** @type {JSONContent} */
75
79
  const json = {};
76
80
  const sorted = [...data].sort(([a], [b]) => (a < b ? -1 : 1));
77
81
  for (const [key, value] of sorted) {
@@ -296,6 +296,7 @@ class BasicEvaluatedExpression {
296
296
  if (this.isBigInt()) return `${this.bigint}`;
297
297
  if (this.isRegExp()) return `${this.regExp}`;
298
298
  if (this.isArray()) {
299
+ /** @type {string[]} */
299
300
  const array = [];
300
301
  for (const item of /** @type {BasicEvaluatedExpression[]} */ (
301
302
  this.items
@@ -8,16 +8,19 @@
8
8
  /** @typedef {import("../../declarations/WebpackOptions").ChunkLoadingType} ChunkLoadingType */
9
9
  /** @typedef {import("../Compiler")} Compiler */
10
10
 
11
- /** @type {WeakMap<Compiler, Set<ChunkLoadingType>>} */
11
+ /** @typedef {Set<ChunkLoadingType>} ChunkLoadingTypes */
12
+
13
+ /** @type {WeakMap<Compiler, ChunkLoadingTypes>} */
12
14
  const enabledTypes = new WeakMap();
13
15
 
14
16
  /**
15
17
  * @param {Compiler} compiler compiler
16
- * @returns {Set<ChunkLoadingType>} enabled types
18
+ * @returns {ChunkLoadingTypes} enabled types
17
19
  */
18
20
  const getEnabledTypes = (compiler) => {
19
21
  let set = enabledTypes.get(compiler);
20
22
  if (set === undefined) {
23
+ /** @type {ChunkLoadingTypes} */
21
24
  set = new Set();
22
25
  enabledTypes.set(compiler, set);
23
26
  }
@@ -32,7 +32,7 @@ const RuntimeGlobals = require("../RuntimeGlobals");
32
32
  const Template = require("../Template");
33
33
  const { last, someInIterable } = require("../util/IterableHelpers");
34
34
  const StringXor = require("../util/StringXor");
35
- const { compareModulesByIdOrIdentifier } = require("../util/comparators");
35
+ const { compareModulesByFullName } = require("../util/comparators");
36
36
  const {
37
37
  RESERVED_NAMES,
38
38
  addScopeSymbols,
@@ -59,17 +59,21 @@ const JavascriptParser = require("./JavascriptParser");
59
59
  /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
60
60
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
61
61
  /** @typedef {import("../Compilation").ExecuteModuleObject} ExecuteModuleObject */
62
+ /** @typedef {import("../Compilation").WebpackRequire} WebpackRequire */
62
63
  /** @typedef {import("../Compiler")} Compiler */
63
64
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
64
65
  /** @typedef {import("../Entrypoint")} Entrypoint */
65
66
  /** @typedef {import("../Module")} Module */
66
67
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
68
+ /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
67
69
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
68
70
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
69
71
  /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
70
72
  /** @typedef {import("../WebpackError")} WebpackError */
71
73
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
72
74
  /** @typedef {import("../util/Hash")} Hash */
75
+ /** @typedef {import("../util/concatenate").ScopeSet} ScopeSet */
76
+ /** @typedef {import("../util/concatenate").UsedNamesInScopeInfo} UsedNamesInScopeInfo */
73
77
 
74
78
  /**
75
79
  * @param {Chunk} chunk a chunk
@@ -278,7 +282,7 @@ class JavascriptModulesPlugin {
278
282
 
279
283
  constructor(options = {}) {
280
284
  this.options = options;
281
- /** @type {WeakMap<Source, { source: Source, needModule:boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
285
+ /** @type {WeakMap<Source, { source: Source, needModule: boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
282
286
  this._moduleFactoryCache = new WeakMap();
283
287
  }
284
288
 
@@ -354,6 +358,7 @@ class JavascriptModulesPlugin {
354
358
  outputOptions
355
359
  );
356
360
 
361
+ /** @type {() => Source} */
357
362
  let render;
358
363
 
359
364
  if (hotUpdateChunk) {
@@ -535,6 +540,7 @@ class JavascriptModulesPlugin {
535
540
  const { module } = options;
536
541
  const code = source.source();
537
542
 
543
+ /** @type {(this: ExecuteModuleObject["exports"], exports: ExecuteModuleObject["exports"], moduleObject: ExecuteModuleObject, webpackRequire: WebpackRequire) => void} */
538
544
  const fn = vm.runInThisContext(
539
545
  `(function(${module.moduleArgument}, ${module.exportsArgument}, ${RuntimeGlobals.require}) {\n${code}\n/**/})`,
540
546
  {
@@ -552,7 +558,8 @@ class JavascriptModulesPlugin {
552
558
  moduleObject.exports,
553
559
  moduleObject,
554
560
  moduleObject.exports,
555
- context.__webpack_require__
561
+ /** @type {WebpackRequire} */
562
+ (context.__webpack_require__)
556
563
  );
557
564
  } catch (err) {
558
565
  /** @type {Error} */
@@ -569,6 +576,7 @@ class JavascriptModulesPlugin {
569
576
  let code = source.source();
570
577
  if (typeof code !== "string") code = code.toString();
571
578
 
579
+ /** @type {(this: null, webpackRequire: WebpackRequire) => void} */
572
580
  const fn = vm.runInThisContext(
573
581
  `(function(${RuntimeGlobals.require}) {\n${code}\n/**/})`,
574
582
  {
@@ -578,7 +586,11 @@ class JavascriptModulesPlugin {
578
586
  );
579
587
  try {
580
588
  // eslint-disable-next-line no-useless-call
581
- fn.call(null, context.__webpack_require__);
589
+ fn.call(
590
+ null,
591
+ /** @type {WebpackRequire} */
592
+ (context.__webpack_require__)
593
+ );
582
594
  } catch (err) {
583
595
  /** @type {Error} */
584
596
  (err).stack += printGeneratedCodeForStack(options.module, code);
@@ -638,6 +650,7 @@ class JavascriptModulesPlugin {
638
650
  hooks.renderModuleContent.call(moduleSource, module, renderContext),
639
651
  "JavascriptModulesPlugin.getCompilationHooks().renderModuleContent"
640
652
  );
653
+ /** @type {Source} */
641
654
  let moduleSourcePostContainer;
642
655
  if (factory) {
643
656
  const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements(
@@ -660,6 +673,7 @@ class JavascriptModulesPlugin {
660
673
  );
661
674
  const renderShorthand =
662
675
  renderInObject === true && runtimeTemplate.supportsMethodShorthand();
676
+ /** @type {Source} */
663
677
  let source;
664
678
  if (
665
679
  cacheEntry &&
@@ -673,6 +687,7 @@ class JavascriptModulesPlugin {
673
687
  source = cacheEntry.source;
674
688
  } else {
675
689
  const factorySource = new ConcatSource();
690
+ /** @type {string[]} */
676
691
  const args = [];
677
692
  if (needExports || needRequire || needModule) {
678
693
  args.push(
@@ -747,13 +762,14 @@ class JavascriptModulesPlugin {
747
762
  * @returns {Source} the rendered source
748
763
  */
749
764
  renderChunk(renderContext, hooks) {
750
- const { chunk, chunkGraph } = renderContext;
765
+ const { chunk, chunkGraph, runtimeTemplate } = renderContext;
751
766
  const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
752
767
  chunk,
753
768
  JAVASCRIPT_TYPE,
754
- compareModulesByIdOrIdentifier(chunkGraph)
769
+ compareModulesByFullName(runtimeTemplate.compilation.compiler)
755
770
  );
756
771
  const allModules = modules ? [...modules] : [];
772
+ /** @type {undefined | string} */
757
773
  let strictHeader;
758
774
  let allStrict = renderContext.strictMode;
759
775
  if (
@@ -838,7 +854,7 @@ class JavascriptModulesPlugin {
838
854
  ...(chunkGraph.getOrderedChunkModulesIterableBySourceType(
839
855
  chunk,
840
856
  JAVASCRIPT_TYPE,
841
- compareModulesByIdOrIdentifier(chunkGraph)
857
+ compareModulesByFullName(runtimeTemplate.compilation.compiler)
842
858
  ) || [])
843
859
  ];
844
860
 
@@ -850,6 +866,7 @@ class JavascriptModulesPlugin {
850
866
  }
851
867
 
852
868
  const source = new ConcatSource();
869
+ /** @type {string} */
853
870
  let prefix;
854
871
  if (iife) {
855
872
  if (runtimeTemplate.supportsArrowFunction()) {
@@ -1026,6 +1043,7 @@ class JavascriptModulesPlugin {
1026
1043
  );
1027
1044
 
1028
1045
  if (renderedModule) {
1046
+ /** @type {string} */
1029
1047
  let footer;
1030
1048
  if (iife !== undefined) {
1031
1049
  startupSource.add(
@@ -1209,7 +1227,7 @@ class JavascriptModulesPlugin {
1209
1227
  requireFunction || interceptModuleExecution || moduleUsed;
1210
1228
 
1211
1229
  /**
1212
- * @type {{startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean}}
1230
+ * @type {{ startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean }}
1213
1231
  */
1214
1232
  const result = {
1215
1233
  header: [],
@@ -1334,6 +1352,7 @@ class JavascriptModulesPlugin {
1334
1352
  result.allowInlineStartup = false;
1335
1353
  }
1336
1354
 
1355
+ /** @type {undefined | CodeGenerationResultData} */
1337
1356
  let data;
1338
1357
  if (codeGenerationResults.has(entryModule, chunk.runtime)) {
1339
1358
  const result = codeGenerationResults.get(
@@ -1766,7 +1785,9 @@ class JavascriptModulesPlugin {
1766
1785
  }
1767
1786
 
1768
1787
  for (const variable of info.variables) {
1788
+ /** @type {UsedNamesInScopeInfo} */
1769
1789
  const usedNamesInScopeInfo = new Map();
1790
+ /** @type {ScopeSet} */
1770
1791
  const ignoredScopes = new Set();
1771
1792
 
1772
1793
  const name = variable.name;
@@ -318,7 +318,7 @@ class VariableInfo {
318
318
  /** @typedef {Literal | string | null | undefined} ImportSource */
319
319
 
320
320
  /**
321
- * @typedef {Omit<ParseOptions, "sourceType"> & {sourceType: "module" | "script" | "auto"}} InternalParseOptions
321
+ * @typedef {Omit<ParseOptions, "sourceType"> & { sourceType: "module" | "script" | "auto" }} InternalParseOptions
322
322
  */
323
323
 
324
324
  /**
@@ -347,12 +347,13 @@ class VariableInfo {
347
347
  /** @typedef {symbol} Tag */
348
348
 
349
349
  /** @typedef {import("../dependencies/HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
350
+ /** @typedef {import("../dependencies/HarmonyImportDependencyParserPlugin").HarmonySpecifierGuards} HarmonySpecifierGuards */
350
351
  /** @typedef {import("../dependencies/ImportParserPlugin").ImportSettings} ImportSettings */
351
352
  /** @typedef {import("../dependencies/CommonJsImportsParserPlugin").CommonJsImportSettings} CommonJsImportSettings */
352
353
  /** @typedef {import("../CompatibilityPlugin").CompatibilitySettings} CompatibilitySettings */
353
354
  /** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
354
355
 
355
- /** @typedef {HarmonySettings | ImportSettings | CommonJsImportSettings | TopLevelSymbol | CompatibilitySettings} KnownTagData */
356
+ /** @typedef {HarmonySettings | ImportSettings | CommonJsImportSettings | TopLevelSymbol | CompatibilitySettings | HarmonySpecifierGuards} KnownTagData */
356
357
  /** @typedef {KnownTagData | Record<string, EXPECTED_ANY>} TagData */
357
358
 
358
359
  /**
@@ -519,6 +520,8 @@ class JavascriptParser extends Parser {
519
520
  statement: new SyncBailHook(["statement"]),
520
521
  /** @type {SyncBailHook<[IfStatement], boolean | void>} */
521
522
  statementIf: new SyncBailHook(["statement"]),
523
+ /** @type {SyncBailHook<[Expression], ((walk: () => void) => void) | void>} */
524
+ collectGuards: new SyncBailHook(["expression"]),
522
525
  /** @type {SyncBailHook<[Expression, ClassExpression | ClassDeclaration | MaybeNamedClassDeclaration], boolean | void>} */
523
526
  classExtendsExpression: new SyncBailHook([
524
527
  "expression",
@@ -747,6 +750,7 @@ class JavascriptParser extends Parser {
747
750
  return;
748
751
  }
749
752
 
753
+ /** @type {undefined | string} */
750
754
  let regExp;
751
755
  const arg1 = expr.arguments[0];
752
756
 
@@ -769,6 +773,7 @@ class JavascriptParser extends Parser {
769
773
  );
770
774
  }
771
775
 
776
+ /** @type {undefined | string} */
772
777
  let flags;
773
778
  const arg2 = expr.arguments[1];
774
779
 
@@ -1597,7 +1602,7 @@ class JavascriptParser extends Parser {
1597
1602
  const arg1Eval = this.evaluateExpression(arg1);
1598
1603
  if (!arg1Eval.isString()) return;
1599
1604
  const arg1Value = /** @type {string} */ (arg1Eval.string);
1600
-
1605
+ /** @type {number} */
1601
1606
  let result;
1602
1607
  if (arg2) {
1603
1608
  if (arg2.type === "SpreadElement") return;
@@ -1642,7 +1647,9 @@ class JavascriptParser extends Parser {
1642
1647
  .for(fn)
1643
1648
  .tap(CLASS_NAME, (expr, param) => {
1644
1649
  if (!param.isString()) return;
1650
+ /** @type {BasicEvaluatedExpression} */
1645
1651
  let arg1;
1652
+ /** @type {string} */
1646
1653
  let result;
1647
1654
  const str = /** @type {string} */ (param.string);
1648
1655
  switch (expr.arguments.length) {
@@ -1682,7 +1689,7 @@ class JavascriptParser extends Parser {
1682
1689
  /**
1683
1690
  * @param {"cooked" | "raw"} kind kind of values to get
1684
1691
  * @param {TemplateLiteral} templateLiteralExpr TemplateLiteral expr
1685
- * @returns {{quasis: BasicEvaluatedExpression[], parts: BasicEvaluatedExpression[]}} Simplified template
1692
+ * @returns {{ quasis: BasicEvaluatedExpression[], parts: BasicEvaluatedExpression[] }} Simplified template
1686
1693
  */
1687
1694
  const getSimplifiedTemplateResult = (kind, templateLiteralExpr) => {
1688
1695
  /** @type {BasicEvaluatedExpression[]} */
@@ -1764,7 +1771,8 @@ class JavascriptParser extends Parser {
1764
1771
  .for("concat")
1765
1772
  .tap(CLASS_NAME, (expr, param) => {
1766
1773
  if (!param.isString() && !param.isWrapped()) return;
1767
- let stringSuffix = null;
1774
+ /** @type {undefined | BasicEvaluatedExpression} */
1775
+ let stringSuffix;
1768
1776
  let hasUnknownParams = false;
1769
1777
  /** @type {BasicEvaluatedExpression[]} */
1770
1778
  const innerExpressions = [];
@@ -1840,6 +1848,7 @@ class JavascriptParser extends Parser {
1840
1848
  if (!param.isString()) return;
1841
1849
  if (expr.arguments.length !== 1) return;
1842
1850
  if (expr.arguments[0].type === "SpreadElement") return;
1851
+ /** @type {string[]} */
1843
1852
  let result;
1844
1853
  const arg = this.evaluateExpression(expr.arguments[0]);
1845
1854
  if (arg.isString()) {
@@ -1865,6 +1874,7 @@ class JavascriptParser extends Parser {
1865
1874
 
1866
1875
  const condition = this.evaluateExpression(expr.test);
1867
1876
  const conditionValue = condition.asBool();
1877
+ /** @type {BasicEvaluatedExpression} */
1868
1878
  let res;
1869
1879
  if (conditionValue === undefined) {
1870
1880
  const consequent = this.evaluateExpression(expr.consequent);
@@ -1983,6 +1993,7 @@ class JavascriptParser extends Parser {
1983
1993
  this.walkExpression(classy.superClass);
1984
1994
  }
1985
1995
  if (classy.body && classy.body.type === "ClassBody") {
1996
+ /** @type {Identifier[]} */
1986
1997
  const scopeParams = [];
1987
1998
  // Add class name in scope for recursive calls
1988
1999
  if (classy.id) {
@@ -2318,8 +2329,16 @@ class JavascriptParser extends Parser {
2318
2329
  walkIfStatement(statement) {
2319
2330
  const result = this.hooks.statementIf.call(statement);
2320
2331
  if (result === undefined) {
2321
- this.walkExpression(statement.test);
2322
- this.walkNestedStatement(statement.consequent);
2332
+ const inGuard = this.hooks.collectGuards.call(statement.test);
2333
+ if (inGuard) {
2334
+ inGuard(() => {
2335
+ this.walkExpression(statement.test);
2336
+ this.walkNestedStatement(statement.consequent);
2337
+ });
2338
+ } else {
2339
+ this.walkExpression(statement.test);
2340
+ this.walkNestedStatement(statement.consequent);
2341
+ }
2323
2342
 
2324
2343
  const consequentTerminated = this.scope.terminated;
2325
2344
  this.scope.terminated = undefined;
@@ -3704,8 +3723,16 @@ class JavascriptParser extends Parser {
3704
3723
  walkConditionalExpression(expression) {
3705
3724
  const result = this.hooks.expressionConditionalOperator.call(expression);
3706
3725
  if (result === undefined) {
3707
- this.walkExpression(expression.test);
3708
- this.walkExpression(expression.consequent);
3726
+ const inGuard = this.hooks.collectGuards.call(expression.test);
3727
+ if (inGuard) {
3728
+ inGuard(() => {
3729
+ this.walkExpression(expression.test);
3730
+ this.walkExpression(expression.consequent);
3731
+ });
3732
+ } else {
3733
+ this.walkExpression(expression.test);
3734
+ this.walkExpression(expression.consequent);
3735
+ }
3709
3736
 
3710
3737
  if (expression.alternate) {
3711
3738
  this.walkExpression(expression.alternate);
@@ -4220,6 +4247,7 @@ class JavascriptParser extends Parser {
4220
4247
  * @returns {R | undefined} result of hook
4221
4248
  */
4222
4249
  callHooksForInfoWithFallback(hookMap, info, fallback, defined, ...args) {
4250
+ /** @type {string} */
4223
4251
  let name;
4224
4252
  if (typeof info === "string") {
4225
4253
  name = info;
@@ -4247,7 +4275,7 @@ class JavascriptParser extends Parser {
4247
4275
  }
4248
4276
  return;
4249
4277
  }
4250
- name = info.name;
4278
+ name = /** @type {string} */ (info.name);
4251
4279
  }
4252
4280
  const hook = hookMap.get(name);
4253
4281
  if (hook !== undefined) {
@@ -4255,7 +4283,7 @@ class JavascriptParser extends Parser {
4255
4283
  if (result !== undefined) return result;
4256
4284
  }
4257
4285
  if (fallback !== undefined) {
4258
- return fallback(/** @type {string} */ (name));
4286
+ return fallback(name);
4259
4287
  }
4260
4288
  }
4261
4289
 
@@ -4891,7 +4919,7 @@ class JavascriptParser extends Parser {
4891
4919
  ]).some(
4892
4920
  (comment) =>
4893
4921
  comment.type === "Block" &&
4894
- /^\s*(#|@)__PURE__\s*$/.test(comment.value)
4922
+ /^\s*(?:#|@)__PURE__\s*$/.test(comment.value)
4895
4923
  );
4896
4924
  if (!pureFlag) return false;
4897
4925
  commentsStartPos = /** @type {Range} */ (expr.callee.range)[1];
@@ -5187,8 +5215,11 @@ class JavascriptParser extends Parser {
5187
5215
  extractMemberExpressionChain(expression) {
5188
5216
  /** @type {Node} */
5189
5217
  let expr = expression;
5218
+ /** @type {Members} */
5190
5219
  const members = [];
5220
+ /** @type {MembersOptionals} */
5191
5221
  const membersOptionals = [];
5222
+ /** @type {MemberRanges} */
5192
5223
  const memberRanges = [];
5193
5224
  while (expr.type === "MemberExpression") {
5194
5225
  if (expr.computed) {
@@ -5214,10 +5245,11 @@ class JavascriptParser extends Parser {
5214
5245
 
5215
5246
  /**
5216
5247
  * @param {string} varName variable name
5217
- * @returns {{name: string, info: VariableInfo | string} | undefined} name of the free variable and variable info for that
5248
+ * @returns {{ name: string, info: VariableInfo | string } | undefined} name of the free variable and variable info for that
5218
5249
  */
5219
5250
  getFreeInfoFromVariable(varName) {
5220
5251
  const info = this.getVariableInfo(varName);
5252
+ /** @type {string} */
5221
5253
  let name;
5222
5254
  if (info instanceof VariableInfo && info.name) {
5223
5255
  if (!info.isFree()) return;
@@ -5232,10 +5264,11 @@ class JavascriptParser extends Parser {
5232
5264
 
5233
5265
  /**
5234
5266
  * @param {string} varName variable name
5235
- * @returns {{name: string, info: VariableInfo | string} | undefined} name of the free variable and variable info for that
5267
+ * @returns {{ name: string, info: VariableInfo | string } | undefined} name of the free variable and variable info for that
5236
5268
  */
5237
5269
  getNameInfoFromVariable(varName) {
5238
5270
  const info = this.getVariableInfo(varName);
5271
+ /** @type {string} */
5239
5272
  let name;
5240
5273
  if (info instanceof VariableInfo && info.name) {
5241
5274
  if (!info.isFree() && !info.isTagged()) return;
@@ -17,8 +17,14 @@ const JsonData = require("./JsonData");
17
17
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
18
18
  /** @typedef {import("../util/fs").JsonValue} JsonValue */
19
19
 
20
+ /**
21
+ * @template T
22
+ * @typedef {import("../util/memoize").FunctionReturning<T>} FunctionReturning
23
+ */
24
+
20
25
  /** @typedef {(input: string) => Buffer | JsonValue} ParseFn */
21
26
 
27
+ /** @type {FunctionReturning<ParseFn>} */
22
28
  const getParseJson = memoize(() => require("json-parse-even-better-errors"));
23
29
 
24
30
  class JsonParser extends Parser {
@@ -48,8 +48,11 @@ class AbstractLibraryPlugin {
48
48
  * @param {AbstractLibraryPluginOptions} options options
49
49
  */
50
50
  constructor({ pluginName, type }) {
51
+ /** @type {AbstractLibraryPluginOptions["pluginName"]} */
51
52
  this._pluginName = pluginName;
53
+ /** @type {AbstractLibraryPluginOptions["type"]} */
52
54
  this._type = type;
55
+ /** @type {WeakMap<LibraryOptions, T>} */
53
56
  this._parseCache = new WeakMap();
54
57
  }
55
58
 
@@ -236,7 +239,7 @@ class AbstractLibraryPlugin {
236
239
  /**
237
240
  * @abstract
238
241
  * @param {LibraryOptions} library normalized library option
239
- * @returns {T | false} preprocess as needed by overriding
242
+ * @returns {T} preprocess as needed by overriding
240
243
  */
241
244
  parseOptions(library) {
242
245
  const AbstractMethodError = require("../AbstractMethodError");
@@ -47,12 +47,13 @@ class AmdLibraryPlugin extends AbstractLibraryPlugin {
47
47
  pluginName: "AmdLibraryPlugin",
48
48
  type: options.type
49
49
  });
50
+ /** @type {AmdLibraryPluginOptions["requireAsWrapper"]} */
50
51
  this.requireAsWrapper = options.requireAsWrapper;
51
52
  }
52
53
 
53
54
  /**
54
55
  * @param {LibraryOptions} library normalized library option
55
- * @returns {T | false} preprocess as needed by overriding
56
+ * @returns {T} preprocess as needed by overriding
56
57
  */
57
58
  parseOptions(library) {
58
59
  const { name, amdContainer } = library;
@@ -33,7 +33,7 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
33
33
  */
34
34
 
35
35
  const KEYWORD_REGEX =
36
- /^(await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/;
36
+ /^(?:await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/;
37
37
  const IDENTIFIER_REGEX =
38
38
  /^[\p{L}\p{Nl}$_][\p{L}\p{Nl}$\p{Mn}\p{Mc}\p{Nd}\p{Pc}]*$/iu;
39
39
 
@@ -128,15 +128,19 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
128
128
  pluginName: "AssignLibraryPlugin",
129
129
  type: options.type
130
130
  });
131
+ /** @type {AssignLibraryPluginOptions["prefix"]} */
131
132
  this.prefix = options.prefix;
133
+ /** @type {AssignLibraryPluginOptions["declare"]} */
132
134
  this.declare = options.declare;
135
+ /** @type {AssignLibraryPluginOptions["unnamed"]} */
133
136
  this.unnamed = options.unnamed;
137
+ /** @type {AssignLibraryPluginOptions["named"]} */
134
138
  this.named = options.named || "assign";
135
139
  }
136
140
 
137
141
  /**
138
142
  * @param {LibraryOptions} library normalized library option
139
- * @returns {T | false} preprocess as needed by overriding
143
+ * @returns {T} preprocess as needed by overriding
140
144
  */
141
145
  parseOptions(library) {
142
146
  const { name } = library;
@@ -25,6 +25,7 @@ const enabledTypes = new WeakMap();
25
25
  const getEnabledTypes = (compiler) => {
26
26
  let set = enabledTypes.get(compiler);
27
27
  if (set === undefined) {
28
+ /** @type {LibraryTypes} */
28
29
  set = new Set();
29
30
  enabledTypes.set(compiler, set);
30
31
  }
@@ -51,7 +51,7 @@ class ExportPropertyLibraryPlugin extends AbstractLibraryPlugin {
51
51
 
52
52
  /**
53
53
  * @param {LibraryOptions} library normalized library option
54
- * @returns {T | false} preprocess as needed by overriding
54
+ * @returns {T} preprocess as needed by overriding
55
55
  */
56
56
  parseOptions(library) {
57
57
  return {
@@ -48,7 +48,7 @@ class JsonpLibraryPlugin extends AbstractLibraryPlugin {
48
48
 
49
49
  /**
50
50
  * @param {LibraryOptions} library normalized library option
51
- * @returns {T | false} preprocess as needed by overriding
51
+ * @returns {T} preprocess as needed by overriding
52
52
  */
53
53
  parseOptions(library) {
54
54
  const { name } = library;