webpack 5.101.3 → 5.102.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 (322) 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 +35 -25
  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 +2 -1
  13. package/lib/CompatibilityPlugin.js +29 -12
  14. package/lib/Compilation.js +204 -185
  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 +22 -20
  21. package/lib/ContextModuleFactory.js +30 -11
  22. package/lib/ContextReplacementPlugin.js +38 -15
  23. package/lib/DefinePlugin.js +4 -8
  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 +1 -3
  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 +96 -78
  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 +41 -24
  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 +145 -88
  63. package/lib/NormalModuleFactory.js +59 -40
  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 +12 -11
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
  76. package/lib/SourceMapDevToolPlugin.js +6 -11
  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 +166 -0
  85. package/lib/asset/AssetBytesParser.js +37 -0
  86. package/lib/asset/AssetGenerator.js +20 -34
  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/config/defaults.js +155 -21
  98. package/lib/config/normalization.js +18 -3
  99. package/lib/container/ContainerEntryDependency.js +0 -1
  100. package/lib/container/ContainerEntryModule.js +3 -7
  101. package/lib/container/ContainerPlugin.js +1 -2
  102. package/lib/container/ContainerReferencePlugin.js +0 -1
  103. package/lib/container/FallbackDependency.js +2 -1
  104. package/lib/container/FallbackModule.js +6 -7
  105. package/lib/container/ModuleFederationPlugin.js +0 -1
  106. package/lib/container/RemoteModule.js +8 -8
  107. package/lib/container/RemoteRuntimeModule.js +2 -2
  108. package/lib/css/CssGenerator.js +3 -6
  109. package/lib/css/CssLoadingRuntimeModule.js +6 -9
  110. package/lib/css/CssModulesPlugin.js +11 -13
  111. package/lib/css/CssParser.js +3 -3
  112. package/lib/css/walkCssTokens.js +1 -1
  113. package/lib/debug/ProfilingPlugin.js +35 -8
  114. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
  115. package/lib/dependencies/AMDPlugin.js +2 -2
  116. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
  117. package/lib/dependencies/CachedConstDependency.js +0 -4
  118. package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
  119. package/lib/dependencies/CommonJsExportsDependency.js +2 -1
  120. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
  121. package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
  122. package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
  123. package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
  124. package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
  125. package/lib/dependencies/ConstDependency.js +2 -2
  126. package/lib/dependencies/ContextDependency.js +9 -4
  127. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  128. package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
  129. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
  130. package/lib/dependencies/ContextElementDependency.js +22 -11
  131. package/lib/dependencies/CssIcssImportDependency.js +0 -2
  132. package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
  133. package/lib/dependencies/CssImportDependency.js +0 -8
  134. package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
  135. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
  136. package/lib/dependencies/CssUrlDependency.js +0 -6
  137. package/lib/dependencies/ExportsInfoDependency.js +7 -9
  138. package/lib/dependencies/ExternalModuleDependency.js +0 -3
  139. package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
  140. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  141. package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
  142. package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
  143. package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
  144. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
  145. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
  146. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
  147. package/lib/dependencies/HarmonyImportDependency.js +30 -14
  148. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
  149. package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
  150. package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
  151. package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
  152. package/lib/dependencies/ImportDependency.js +18 -6
  153. package/lib/dependencies/ImportEagerDependency.js +2 -3
  154. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
  155. package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
  156. package/lib/dependencies/ImportMetaPlugin.js +2 -1
  157. package/lib/dependencies/ImportParserPlugin.js +288 -45
  158. package/lib/dependencies/ImportWeakDependency.js +2 -3
  159. package/lib/dependencies/JsonExportsDependency.js +0 -1
  160. package/lib/dependencies/LoaderDependency.js +0 -3
  161. package/lib/dependencies/LoaderImportDependency.js +0 -3
  162. package/lib/dependencies/LoaderPlugin.js +11 -5
  163. package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
  164. package/lib/dependencies/ModuleDependency.js +3 -9
  165. package/lib/dependencies/NullDependency.js +2 -0
  166. package/lib/dependencies/ProvidedDependency.js +6 -8
  167. package/lib/dependencies/PureExpressionDependency.js +0 -1
  168. package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
  169. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
  170. package/lib/dependencies/RequireIncludeDependency.js +2 -2
  171. package/lib/dependencies/RequireResolveDependency.js +2 -2
  172. package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
  173. package/lib/dependencies/StaticExportsDependency.js +3 -5
  174. package/lib/dependencies/URLDependency.js +2 -7
  175. package/lib/dependencies/URLPlugin.js +1 -2
  176. package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
  177. package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
  178. package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
  179. package/lib/dependencies/WorkerDependency.js +2 -3
  180. package/lib/dependencies/WorkerPlugin.js +3 -9
  181. package/lib/dependencies/processExportInfo.js +2 -3
  182. package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
  183. package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
  184. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
  185. package/lib/hmr/LazyCompilationPlugin.js +6 -4
  186. package/lib/hmr/lazyCompilationBackend.js +13 -10
  187. package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
  188. package/lib/ids/NamedChunkIdsPlugin.js +1 -6
  189. package/lib/ids/NamedModuleIdsPlugin.js +1 -5
  190. package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
  191. package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
  192. package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
  193. package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
  194. package/lib/ids/SyncModuleIdsPlugin.js +4 -3
  195. package/lib/index.js +8 -7
  196. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
  197. package/lib/javascript/BasicEvaluatedExpression.js +13 -6
  198. package/lib/javascript/ChunkFormatHelpers.js +1 -1
  199. package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
  200. package/lib/javascript/JavascriptGenerator.js +2 -3
  201. package/lib/javascript/JavascriptModulesPlugin.js +44 -21
  202. package/lib/javascript/JavascriptParser.js +119 -54
  203. package/lib/javascript/JavascriptParserHelpers.js +2 -2
  204. package/lib/javascript/StartupHelpers.js +2 -4
  205. package/lib/json/JsonData.js +1 -1
  206. package/lib/json/JsonGenerator.js +4 -5
  207. package/lib/json/JsonModulesPlugin.js +0 -3
  208. package/lib/json/JsonParser.js +4 -2
  209. package/lib/library/AbstractLibraryPlugin.js +2 -2
  210. package/lib/library/AmdLibraryPlugin.js +0 -1
  211. package/lib/library/AssignLibraryPlugin.js +23 -12
  212. package/lib/library/EnableLibraryPlugin.js +7 -11
  213. package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
  214. package/lib/library/JsonpLibraryPlugin.js +5 -2
  215. package/lib/library/ModuleLibraryPlugin.js +88 -43
  216. package/lib/library/SystemLibraryPlugin.js +0 -1
  217. package/lib/library/UmdLibraryPlugin.js +12 -18
  218. package/lib/logging/Logger.js +12 -10
  219. package/lib/logging/createConsoleLogger.js +15 -14
  220. package/lib/logging/truncateArgs.js +1 -1
  221. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  222. package/lib/node/NodeWatchFileSystem.js +4 -4
  223. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  224. package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
  225. package/lib/node/nodeConsole.js +2 -2
  226. package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
  227. package/lib/optimize/ConcatenatedModule.js +142 -100
  228. package/lib/optimize/InnerGraph.js +17 -11
  229. package/lib/optimize/InnerGraphPlugin.js +0 -3
  230. package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
  231. package/lib/optimize/RuntimeChunkPlugin.js +0 -1
  232. package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
  233. package/lib/optimize/SplitChunksPlugin.js +46 -40
  234. package/lib/performance/SizeLimitsPlugin.js +2 -1
  235. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
  236. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
  237. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
  238. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
  239. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
  240. package/lib/rules/BasicMatcherRulePlugin.js +0 -2
  241. package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
  242. package/lib/rules/RuleSetCompiler.js +8 -6
  243. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  244. package/lib/runtime/CompatRuntimeModule.js +0 -1
  245. package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
  246. package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
  247. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  248. package/lib/runtime/PublicPathRuntimeModule.js +2 -2
  249. package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
  250. package/lib/runtime/SystemContextRuntimeModule.js +0 -2
  251. package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
  252. package/lib/schemes/DataUriPlugin.js +2 -28
  253. package/lib/schemes/FileUriPlugin.js +5 -2
  254. package/lib/schemes/HttpUriPlugin.js +4 -2
  255. package/lib/schemes/VirtualUrlPlugin.js +11 -11
  256. package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
  257. package/lib/serialization/ObjectMiddleware.js +30 -19
  258. package/lib/serialization/SerializerMiddleware.js +1 -3
  259. package/lib/serialization/types.js +1 -1
  260. package/lib/sharing/ConsumeSharedModule.js +3 -5
  261. package/lib/sharing/ConsumeSharedPlugin.js +2 -4
  262. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
  263. package/lib/sharing/ProvideSharedModule.js +3 -7
  264. package/lib/sharing/SharePlugin.js +0 -2
  265. package/lib/sharing/ShareRuntimeModule.js +4 -1
  266. package/lib/sharing/resolveMatchedConfigs.js +14 -6
  267. package/lib/sharing/utils.js +0 -6
  268. package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
  269. package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
  270. package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
  271. package/lib/stats/StatsFactory.js +14 -11
  272. package/lib/url/URLParserPlugin.js +2 -4
  273. package/lib/util/ArrayHelpers.js +4 -4
  274. package/lib/util/AsyncQueue.js +1 -0
  275. package/lib/util/LazySet.js +2 -2
  276. package/lib/util/StackedCacheMap.js +0 -2
  277. package/lib/util/TupleSet.js +9 -4
  278. package/lib/util/URLAbsoluteSpecifier.js +0 -1
  279. package/lib/util/WeakTupleMap.js +1 -1
  280. package/lib/util/chainedImports.js +3 -1
  281. package/lib/util/cleverMerge.js +15 -18
  282. package/lib/util/comparators.js +2 -4
  283. package/lib/util/compileBooleanMatcher.js +11 -9
  284. package/lib/util/concatenate.js +1 -2
  285. package/lib/util/create-schema-validation.js +0 -1
  286. package/lib/util/dataURL.js +39 -0
  287. package/lib/util/deprecation.js +29 -31
  288. package/lib/util/deterministicGrouping.js +34 -30
  289. package/lib/util/extractSourceMap.js +319 -0
  290. package/lib/util/findGraphRoots.js +15 -5
  291. package/lib/util/fs.js +29 -8
  292. package/lib/util/semver.js +9 -8
  293. package/lib/util/smartGrouping.js +41 -26
  294. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  295. package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
  296. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  297. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
  298. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
  299. package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
  300. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
  301. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
  302. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
  303. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
  304. package/lib/wasm-sync/WebAssemblyParser.js +1 -4
  305. package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
  306. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  307. package/lib/web/JsonpTemplatePlugin.js +0 -1
  308. package/lib/webpack.js +21 -8
  309. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
  310. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  311. package/package.json +12 -12
  312. package/schemas/WebpackOptions.check.js +1 -1
  313. package/schemas/WebpackOptions.json +77 -93
  314. package/schemas/plugins/BannerPlugin.check.js +1 -1
  315. package/schemas/plugins/BannerPlugin.json +4 -0
  316. package/schemas/plugins/IgnorePlugin.json +1 -1
  317. package/schemas/plugins/ProgressPlugin.json +1 -1
  318. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  319. package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
  320. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  321. package/types.d.ts +1129 -530
  322. package/SECURITY.md +0 -9
@@ -16,14 +16,21 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
16
16
  /** @typedef {import("webpack-sources").Source} Source */
17
17
  /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
18
18
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
19
+ /** @typedef {import("../../declarations/WebpackOptions").LibraryExport} LibraryExport */
19
20
  /** @typedef {import("../Chunk")} Chunk */
20
21
  /** @typedef {import("../Compilation")} Compilation */
21
22
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
22
23
  /** @typedef {import("../Module")} Module */
24
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
25
+ /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
23
26
  /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
24
27
  /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
25
28
  /** @typedef {import("../util/Hash")} Hash */
26
- /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
29
+
30
+ /**
31
+ * @template T
32
+ * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
33
+ */
27
34
 
28
35
  const KEYWORD_REGEX =
29
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)$/;
@@ -89,19 +96,23 @@ const accessWithInit = (accessor, existingLength, initLast = false) => {
89
96
  return current;
90
97
  };
91
98
 
99
+ /** @typedef {string[] | "global"} LibraryPrefix */
100
+
92
101
  /**
93
102
  * @typedef {object} AssignLibraryPluginOptions
94
103
  * @property {LibraryType} type
95
- * @property {string[] | "global"} prefix name prefix
104
+ * @property {LibraryPrefix} prefix name prefix
96
105
  * @property {string | false} declare declare name as variable
97
- * @property {"error"|"static"|"copy"|"assign"} unnamed behavior for unnamed library name
98
- * @property {"copy"|"assign"=} named behavior for named library name
106
+ * @property {"error" | "static" | "copy" | "assign"} unnamed behavior for unnamed library name
107
+ * @property {"copy" | "assign"=} named behavior for named library name
99
108
  */
100
109
 
110
+ /** @typedef {string | string[]} LibraryName */
111
+
101
112
  /**
102
113
  * @typedef {object} AssignLibraryPluginParsed
103
- * @property {string | string[]} name
104
- * @property {string | string[] | undefined} export
114
+ * @property {LibraryName} name
115
+ * @property {LibraryExport=} export
105
116
  */
106
117
 
107
118
  /**
@@ -140,7 +151,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
140
151
  `Library name must be a string, string array or unset. ${AbstractLibraryPlugin.COMMON_LIBRARY_NAME_MESSAGE}`
141
152
  );
142
153
  }
143
- const _name = /** @type {string | string[]} */ (name);
154
+ const _name = /** @type {LibraryName} */ (name);
144
155
  return {
145
156
  name: _name,
146
157
  export: library.export
@@ -175,7 +186,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
175
186
 
176
187
  /**
177
188
  * @param {Compilation} compilation the compilation
178
- * @returns {string[]} the prefix
189
+ * @returns {LibraryPrefix} the prefix
179
190
  */
180
191
  _getPrefix(compilation) {
181
192
  return this.prefix === "global"
@@ -187,7 +198,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
187
198
  * @param {AssignLibraryPluginParsed} options the library options
188
199
  * @param {Chunk} chunk the chunk
189
200
  * @param {Compilation} compilation the compilation
190
- * @returns {Array<string>} the resolved full name
201
+ * @returns {string[]} the resolved full name
191
202
  */
192
203
  _getResolvedFullName(options, chunk, compilation) {
193
204
  const prefix = this._getPrefix(compilation);
@@ -196,7 +207,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
196
207
  ...prefix,
197
208
  ...(Array.isArray(options.name) ? options.name : [options.name])
198
209
  ]
199
- : prefix;
210
+ : /** @type {string[]} */ (prefix);
200
211
  return fullName.map((n) =>
201
212
  compilation.getPath(n, {
202
213
  chunk
@@ -311,7 +322,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
311
322
  true
312
323
  );
313
324
 
314
- /** @type {string[]} */
325
+ /** @type {ExportInfoName[]} */
315
326
  const provided = [];
316
327
  for (const exportInfo of exportsInfo.orderedExports) {
317
328
  if (!exportInfo.provided) continue;
@@ -392,7 +403,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
392
403
 
393
404
  /**
394
405
  * @param {Chunk} chunk the chunk
395
- * @param {Set<string>} set runtime requirements
406
+ * @param {RuntimeRequirements} set runtime requirements
396
407
  * @param {LibraryContext<T>} libraryContext context
397
408
  * @returns {void}
398
409
  */
@@ -5,11 +5,12 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
9
8
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
10
9
  /** @typedef {import("../Compiler")} Compiler */
11
10
 
12
- /** @type {WeakMap<Compiler, Set<LibraryType>>} */
11
+ /** @typedef {Set<LibraryType>} LibraryTypes */
12
+
13
+ /** @type {WeakMap<Compiler, LibraryTypes>} */
13
14
  const enabledTypes = new WeakMap();
14
15
 
15
16
  /**
@@ -19,7 +20,7 @@ const enabledTypes = new WeakMap();
19
20
 
20
21
  /**
21
22
  * @param {Compiler} compiler the compiler instance
22
- * @returns {Set<LibraryType>} enabled types
23
+ * @returns {LibraryTypes} enabled types
23
24
  */
24
25
  const getEnabledTypes = (compiler) => {
25
26
  let set = enabledTypes.get(compiler);
@@ -87,13 +88,10 @@ class EnableLibraryPlugin {
87
88
 
88
89
  if (typeof type === "string") {
89
90
  const enableExportProperty = () => {
90
- const ExportPropertyTemplatePlugin = require("./ExportPropertyLibraryPlugin");
91
+ const ExportPropertyLibraryPlugin = require("./ExportPropertyLibraryPlugin");
91
92
 
92
- new ExportPropertyTemplatePlugin({
93
- type,
94
- nsObjectUsed: !["module", "modern-module"].includes(type),
95
- runtimeExportsUsed: !["module", "modern-module"].includes(type),
96
- renderStartupUsed: !["module", "modern-module"].includes(type)
93
+ new ExportPropertyLibraryPlugin({
94
+ type
97
95
  }).apply(compiler);
98
96
  };
99
97
  switch (type) {
@@ -286,8 +284,6 @@ class EnableLibraryPlugin {
286
284
  }
287
285
  case "module":
288
286
  case "modern-module": {
289
- enableExportProperty();
290
-
291
287
  const ModuleLibraryPlugin = require("./ModuleLibraryPlugin");
292
288
 
293
289
  new ModuleLibraryPlugin({
@@ -15,23 +15,21 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
15
15
  /** @typedef {import("webpack-sources").Source} Source */
16
16
  /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
17
17
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
18
+ /** @typedef {import("../../declarations/WebpackOptions").LibraryExport} LibraryExport */
18
19
  /** @typedef {import("../Chunk")} Chunk */
19
- /** @typedef {import("../Compiler")} Compiler */
20
20
  /** @typedef {import("../Module")} Module */
21
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
21
22
  /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
22
23
  /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
23
24
 
24
25
  /**
25
26
  * @typedef {object} ExportPropertyLibraryPluginParsed
26
- * @property {string | string[]} export
27
+ * @property {LibraryExport=} export
27
28
  */
28
29
 
29
30
  /**
30
31
  * @typedef {object} ExportPropertyLibraryPluginOptions
31
32
  * @property {LibraryType} type
32
- * @property {boolean} nsObjectUsed the namespace object is used
33
- * @property {boolean} runtimeExportsUsed runtime exports are used
34
- * @property {boolean} renderStartupUsed render startup is used
35
33
  */
36
34
  /**
37
35
  * @typedef {ExportPropertyLibraryPluginParsed} T
@@ -41,14 +39,11 @@ class ExportPropertyLibraryPlugin extends AbstractLibraryPlugin {
41
39
  /**
42
40
  * @param {ExportPropertyLibraryPluginOptions} options options
43
41
  */
44
- constructor({ type, nsObjectUsed, runtimeExportsUsed, renderStartupUsed }) {
42
+ constructor({ type }) {
45
43
  super({
46
44
  pluginName: "ExportPropertyLibraryPlugin",
47
45
  type
48
46
  });
49
- this.nsObjectUsed = nsObjectUsed;
50
- this.runtimeExportsUsed = runtimeExportsUsed;
51
- this.renderStartupUsed = renderStartupUsed;
52
47
  }
53
48
 
54
49
  /**
@@ -57,7 +52,7 @@ class ExportPropertyLibraryPlugin extends AbstractLibraryPlugin {
57
52
  */
58
53
  parseOptions(library) {
59
54
  return {
60
- export: /** @type {string | string[]} */ (library.export)
55
+ export: library.export
61
56
  };
62
57
  }
63
58
 
@@ -82,25 +77,19 @@ class ExportPropertyLibraryPlugin extends AbstractLibraryPlugin {
82
77
  exportsInfo.canMangleUse = false;
83
78
  } else {
84
79
  const exportsInfo = moduleGraph.getExportsInfo(module);
85
- if (this.nsObjectUsed) {
86
- exportsInfo.setUsedInUnknownWay(runtime);
87
- } else {
88
- exportsInfo.setAllKnownExportsUsed(runtime);
89
- }
80
+ exportsInfo.setUsedInUnknownWay(runtime);
90
81
  }
91
82
  moduleGraph.addExtraReason(module, "used as library export");
92
83
  }
93
84
 
94
85
  /**
95
86
  * @param {Chunk} chunk the chunk
96
- * @param {Set<string>} set runtime requirements
87
+ * @param {RuntimeRequirements} set runtime requirements
97
88
  * @param {LibraryContext<T>} libraryContext context
98
89
  * @returns {void}
99
90
  */
100
91
  runtimeRequirements(chunk, set, libraryContext) {
101
- if (this.runtimeExportsUsed) {
102
- set.add(RuntimeGlobals.exports);
103
- }
92
+ set.add(RuntimeGlobals.exports);
104
93
  }
105
94
 
106
95
  /**
@@ -111,7 +100,6 @@ class ExportPropertyLibraryPlugin extends AbstractLibraryPlugin {
111
100
  * @returns {Source} source with library export
112
101
  */
113
102
  renderStartup(source, module, renderContext, { options }) {
114
- if (!this.renderStartupUsed) return source;
115
103
  if (!options.export) return source;
116
104
  const postfix = `${RuntimeGlobals.exports} = ${
117
105
  RuntimeGlobals.exports
@@ -13,10 +13,13 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
13
13
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
14
14
  /** @typedef {import("../Chunk")} Chunk */
15
15
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
16
- /** @typedef {import("../Compiler")} Compiler */
17
16
  /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
18
17
  /** @typedef {import("../util/Hash")} Hash */
19
- /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
18
+
19
+ /**
20
+ * @template T
21
+ * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
22
+ */
20
23
 
21
24
  /**
22
25
  * @typedef {object} JsonpLibraryPluginOptions
@@ -6,24 +6,24 @@
6
6
  "use strict";
7
7
 
8
8
  const { ConcatSource } = require("webpack-sources");
9
+ const { UsageState } = require("../ExportsInfo");
9
10
  const RuntimeGlobals = require("../RuntimeGlobals");
10
11
  const Template = require("../Template");
11
- const CommonJsSelfReferenceDependency = require("../dependencies/CommonJsSelfReferenceDependency");
12
12
  const ConcatenatedModule = require("../optimize/ConcatenatedModule");
13
13
  const propertyAccess = require("../util/propertyAccess");
14
+ const { getEntryRuntime } = require("../util/runtime");
14
15
  const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
15
16
 
16
17
  /** @typedef {import("webpack-sources").Source} Source */
17
18
  /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
18
19
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
20
+ /** @typedef {import("../../declarations/WebpackOptions").LibraryExport} LibraryExport */
19
21
  /** @typedef {import("../Chunk")} Chunk */
20
- /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
21
22
  /** @typedef {import("../Compiler")} Compiler */
22
23
  /** @typedef {import("../Module")} Module */
23
- /** @typedef {import("../Module").BuildMeta} BuildMeta */
24
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
24
25
  /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
25
26
  /** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */
26
- /** @typedef {import("../util/Hash")} Hash */
27
27
 
28
28
  /**
29
29
  * @template T
@@ -38,7 +38,7 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
38
38
  /**
39
39
  * @typedef {object} ModuleLibraryPluginParsed
40
40
  * @property {string} name
41
- * @property {string | string[]=} export
41
+ * @property {LibraryExport=} export
42
42
  */
43
43
 
44
44
  const PLUGIN_NAME = "ModuleLibraryPlugin";
@@ -73,6 +73,47 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
73
73
  });
74
74
  }
75
75
 
76
+ /**
77
+ * @param {Module} module the exporting entry module
78
+ * @param {string} entryName the name of the entrypoint
79
+ * @param {LibraryContext<T>} libraryContext context
80
+ * @returns {void}
81
+ */
82
+ finishEntryModule(
83
+ module,
84
+ entryName,
85
+ { options, compilation, compilation: { moduleGraph } }
86
+ ) {
87
+ const runtime = getEntryRuntime(compilation, entryName);
88
+ if (options.export) {
89
+ const exportsInfo = moduleGraph.getExportInfo(
90
+ module,
91
+ Array.isArray(options.export) ? options.export[0] : options.export
92
+ );
93
+ exportsInfo.setUsed(UsageState.Used, runtime);
94
+ exportsInfo.canMangleUse = false;
95
+ } else {
96
+ const exportsInfo = moduleGraph.getExportsInfo(module);
97
+ // If the entry module is commonjs, its exports cannot be mangled
98
+ if (module.buildMeta && module.buildMeta.treatAsCommonJs) {
99
+ exportsInfo.setUsedInUnknownWay(runtime);
100
+ } else {
101
+ exportsInfo.setAllKnownExportsUsed(runtime);
102
+ }
103
+ }
104
+ moduleGraph.addExtraReason(module, "used as library export");
105
+ }
106
+
107
+ /**
108
+ * @param {Chunk} chunk the chunk
109
+ * @param {RuntimeRequirements} set runtime requirements
110
+ * @param {LibraryContext<T>} libraryContext context
111
+ * @returns {void}
112
+ */
113
+ runtimeRequirements(chunk, set, libraryContext) {
114
+ set.add(RuntimeGlobals.exports);
115
+ }
116
+
76
117
  /**
77
118
  * @param {LibraryOptions} library normalized library option
78
119
  * @returns {T | false} preprocess as needed by overriding
@@ -101,21 +142,18 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
101
142
  renderStartup(
102
143
  source,
103
144
  module,
104
- { moduleGraph, chunk, codeGenerationResults, inlined, inlinedInIIFE },
145
+ {
146
+ moduleGraph,
147
+ chunk,
148
+ codeGenerationResults,
149
+ inlined,
150
+ inlinedInIIFE,
151
+ runtimeTemplate
152
+ },
105
153
  { options, compilation }
106
154
  ) {
107
155
  const result = new ConcatSource(source);
108
156
 
109
- if (!module.buildMeta || !module.buildMeta.exportsType) {
110
- for (const dependency of module.dependencies) {
111
- if (dependency instanceof CommonJsSelfReferenceDependency) {
112
- result.add(`export { ${RuntimeGlobals.exports} as default }`);
113
- break;
114
- }
115
- }
116
- return result;
117
- }
118
-
119
157
  const exportsInfo = options.export
120
158
  ? [
121
159
  moduleGraph.getExportInfo(
@@ -126,9 +164,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
126
164
  : moduleGraph.getExportsInfo(module).orderedExports;
127
165
  const definitions =
128
166
  inlined && !inlinedInIIFE
129
- ? (module.buildMeta &&
130
- /** @type {GenerationMeta} */ module.buildMeta.exportsFinalName) ||
131
- {}
167
+ ? (module.buildMeta && module.buildMeta.exportsFinalName) || {}
132
168
  : {};
133
169
  /** @type {string[]} */
134
170
  const shortHandedExports = [];
@@ -136,54 +172,55 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
136
172
  const exports = [];
137
173
  const isAsync = moduleGraph.isAsync(module);
138
174
 
175
+ const treatAsCommonJs =
176
+ module.buildMeta && module.buildMeta.treatAsCommonJs;
177
+ const skipRenderDefaultExport = Boolean(treatAsCommonJs);
178
+
139
179
  if (isAsync) {
140
180
  result.add(
141
181
  `${RuntimeGlobals.exports} = await ${RuntimeGlobals.exports};\n`
142
182
  );
143
183
  }
144
184
 
145
- const varType = compilation.outputOptions.environment.const
146
- ? "const"
147
- : "var";
148
-
149
- for (const exportInfo of exportsInfo) {
185
+ outer: for (const exportInfo of exportsInfo) {
150
186
  if (!exportInfo.provided) continue;
151
187
 
152
- let shouldContinue = false;
188
+ const originalName = exportInfo.name;
153
189
 
154
- const reexport = exportInfo.findTarget(moduleGraph, (_m) => true);
190
+ if (skipRenderDefaultExport && originalName === "default") continue;
155
191
 
156
- if (reexport) {
157
- const exp = moduleGraph.getExportsInfo(reexport.module);
192
+ const target = exportInfo.findTarget(moduleGraph, (_m) => true);
193
+ if (target) {
194
+ const reexportsInfo = moduleGraph.getExportsInfo(target.module);
158
195
 
159
- for (const reexportInfo of exp.orderedExports) {
196
+ for (const reexportInfo of reexportsInfo.orderedExports) {
160
197
  if (
161
198
  reexportInfo.provided === false &&
162
199
  reexportInfo.name !== "default" &&
163
- reexportInfo.name === /** @type {string[]} */ (reexport.export)[0]
200
+ reexportInfo.name === /** @type {string[]} */ (target.export)[0]
164
201
  ) {
165
- shouldContinue = true;
202
+ continue outer;
166
203
  }
167
204
  }
168
205
  }
169
206
 
170
- if (shouldContinue) continue;
171
-
172
- const originalName = exportInfo.name;
173
207
  const usedName =
174
208
  /** @type {string} */
175
209
  (exportInfo.getUsedName(originalName, chunk.runtime));
176
210
  /** @type {string | undefined} */
177
211
  const definition = definitions[usedName];
178
- const finalName =
179
- definition ||
180
- `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`;
181
212
 
182
- if (!definition) {
213
+ /** @type {string | undefined} */
214
+ let finalName;
215
+
216
+ if (definition) {
217
+ finalName = definition;
218
+ } else {
219
+ finalName = `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`;
183
220
  result.add(
184
- `${varType} ${finalName} = ${RuntimeGlobals.exports}${propertyAccess([
185
- usedName
186
- ])};\n`
221
+ `${runtimeTemplate.renderConst()} ${finalName} = ${RuntimeGlobals.exports}${propertyAccess(
222
+ [usedName]
223
+ )};\n`
187
224
  );
188
225
  }
189
226
 
@@ -201,7 +238,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
201
238
 
202
239
  if (topLevelDeclarations && topLevelDeclarations.has(originalName)) {
203
240
  const name = `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`;
204
- result.add(`${varType} ${name} = ${finalName};\n`);
241
+ result.add(
242
+ `${runtimeTemplate.renderConst()} ${name} = ${finalName};\n`
243
+ );
205
244
  shortHandedExports.push(`${name} as ${originalName}`);
206
245
  } else {
207
246
  exports.push([originalName, finalName]);
@@ -218,12 +257,18 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
218
257
  }
219
258
  }
220
259
 
260
+ if (treatAsCommonJs) {
261
+ shortHandedExports.push(`${RuntimeGlobals.exports} as default`);
262
+ }
263
+
221
264
  if (shortHandedExports.length > 0) {
222
265
  result.add(`export { ${shortHandedExports.join(", ")} };\n`);
223
266
  }
224
267
 
225
268
  for (const [exportName, final] of exports) {
226
- result.add(`export ${varType} ${exportName} = ${final};\n`);
269
+ result.add(
270
+ `export ${runtimeTemplate.renderConst()} ${exportName} = ${final};\n`
271
+ );
227
272
  }
228
273
 
229
274
  return result;
@@ -17,7 +17,6 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
17
17
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
18
18
  /** @typedef {import("../Chunk")} Chunk */
19
19
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
20
- /** @typedef {import("../Compiler")} Compiler */
21
20
  /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
22
21
  /** @typedef {import("../util/Hash")} Hash */
23
22
  /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
@@ -16,14 +16,12 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
16
16
  /** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
17
17
  /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
18
18
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
19
- /** @typedef {import("../Compiler")} Compiler */
20
19
  /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
21
20
  /** @typedef {import("../ExternalModule").RequestRecord} RequestRecord */
22
- /** @typedef {import("../util/Hash")} Hash */
21
+
23
22
  /**
24
23
  * @template T
25
- * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>}
26
- * LibraryContext<T>
24
+ * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
27
25
  */
28
26
 
29
27
  /**
@@ -33,9 +31,11 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
33
31
  const accessorToObjectAccess = (accessor) =>
34
32
  accessor.map((a) => `[${JSON.stringify(a)}]`).join("");
35
33
 
34
+ /** @typedef {string | string[]} Accessor */
35
+
36
36
  /**
37
37
  * @param {string|undefined} base the path prefix
38
- * @param {string|string[]} accessor the accessor
38
+ * @param {Accessor} accessor the accessor
39
39
  * @param {string=} joinWith the element separator
40
40
  * @returns {string} the path
41
41
  */
@@ -55,8 +55,6 @@ const accessorAccess = (base, accessor, joinWith = ", ") => {
55
55
  .join(joinWith);
56
56
  };
57
57
 
58
- /** @typedef {string | string[] | LibraryCustomUmdObject} UmdLibraryPluginName */
59
-
60
58
  /**
61
59
  * @typedef {object} UmdLibraryPluginOptions
62
60
  * @property {LibraryType} type
@@ -194,10 +192,9 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
194
192
  /** @type {RequestRecord} */
195
193
  (request).root;
196
194
  }
197
- return `root${accessorToObjectAccess(
198
- /** @type {string[]} */
199
- ([...(Array.isArray(request) ? request : [request])])
200
- )}`;
195
+ return `root${accessorToObjectAccess([
196
+ ...(Array.isArray(request) ? request : [request])
197
+ ])}`;
201
198
  })
202
199
  .join(", ")
203
200
  );
@@ -250,17 +247,14 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
250
247
  .join(", ");
251
248
 
252
249
  /**
253
- * @param {string| string[]} library library name
250
+ * @param {Accessor} library library name
254
251
  * @returns {string} stringified library name
255
252
  */
256
253
  const libraryName = (library) =>
257
254
  JSON.stringify(
258
255
  replaceKeys(
259
256
  /** @type {string} */
260
- (
261
- /** @type {string[]} */
262
- ([...(Array.isArray(library) ? library : [library])]).pop()
263
- )
257
+ ([...(Array.isArray(library) ? library : [library])].pop())
264
258
  )
265
259
  );
266
260
 
@@ -324,7 +318,7 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
324
318
  "commonjs"
325
319
  )} else if(typeof exports === 'object')\n` +
326
320
  ` exports[${libraryName(
327
- /** @type {string | string[]} */
321
+ /** @type {Accessor} */
328
322
  (names.commonjs || names.root)
329
323
  )}] = factory(${externalsRequireArray(
330
324
  "commonjs"
@@ -332,7 +326,7 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
332
326
  ` ${replaceKeys(
333
327
  accessorAccess(
334
328
  "root",
335
- /** @type {string | string[]} */
329
+ /** @type {Accessor} */
336
330
  (names.root || names.commonjs)
337
331
  )
338
332
  )} = factory(${externalsRootArray(externals)});\n`
@@ -35,9 +35,11 @@ const LOG_SYMBOL = Symbol("webpack logger raw log method");
35
35
  const TIMERS_SYMBOL = Symbol("webpack logger times");
36
36
  const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times");
37
37
 
38
+ /** @typedef {EXPECTED_ANY[]} Args */
39
+
38
40
  class WebpackLogger {
39
41
  /**
40
- * @param {(type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} log log function
42
+ * @param {(type: LogTypeEnum, args?: Args) => void} log log function
41
43
  * @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger
42
44
  */
43
45
  constructor(log, getChildLogger) {
@@ -46,35 +48,35 @@ class WebpackLogger {
46
48
  }
47
49
 
48
50
  /**
49
- * @param {...EXPECTED_ANY} args args
51
+ * @param {Args} args args
50
52
  */
51
53
  error(...args) {
52
54
  this[LOG_SYMBOL](LogType.error, args);
53
55
  }
54
56
 
55
57
  /**
56
- * @param {...EXPECTED_ANY} args args
58
+ * @param {Args} args args
57
59
  */
58
60
  warn(...args) {
59
61
  this[LOG_SYMBOL](LogType.warn, args);
60
62
  }
61
63
 
62
64
  /**
63
- * @param {...EXPECTED_ANY} args args
65
+ * @param {Args} args args
64
66
  */
65
67
  info(...args) {
66
68
  this[LOG_SYMBOL](LogType.info, args);
67
69
  }
68
70
 
69
71
  /**
70
- * @param {...EXPECTED_ANY} args args
72
+ * @param {Args} args args
71
73
  */
72
74
  log(...args) {
73
75
  this[LOG_SYMBOL](LogType.log, args);
74
76
  }
75
77
 
76
78
  /**
77
- * @param {...EXPECTED_ANY} args args
79
+ * @param {Args} args args
78
80
  */
79
81
  debug(...args) {
80
82
  this[LOG_SYMBOL](LogType.debug, args);
@@ -82,7 +84,7 @@ class WebpackLogger {
82
84
 
83
85
  /**
84
86
  * @param {EXPECTED_ANY} assertion assertion
85
- * @param {...EXPECTED_ANY} args args
87
+ * @param {Args} args args
86
88
  */
87
89
  assert(assertion, ...args) {
88
90
  if (!assertion) {
@@ -99,21 +101,21 @@ class WebpackLogger {
99
101
  }
100
102
 
101
103
  /**
102
- * @param {...EXPECTED_ANY} args args
104
+ * @param {Args} args args
103
105
  */
104
106
  status(...args) {
105
107
  this[LOG_SYMBOL](LogType.status, args);
106
108
  }
107
109
 
108
110
  /**
109
- * @param {...EXPECTED_ANY} args args
111
+ * @param {Args} args args
110
112
  */
111
113
  group(...args) {
112
114
  this[LOG_SYMBOL](LogType.group, args);
113
115
  }
114
116
 
115
117
  /**
116
- * @param {...EXPECTED_ANY} args args
118
+ * @param {Args} args args
117
119
  */
118
120
  groupCollapsed(...args) {
119
121
  this[LOG_SYMBOL](LogType.groupCollapsed, args);