@eriche/webpack 4.47.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 (361) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +784 -0
  3. package/SECURITY.md +9 -0
  4. package/bin/webpack.js +171 -0
  5. package/buildin/amd-define.js +3 -0
  6. package/buildin/amd-options.js +2 -0
  7. package/buildin/global.js +20 -0
  8. package/buildin/harmony-module.js +24 -0
  9. package/buildin/module.js +22 -0
  10. package/buildin/system.js +7 -0
  11. package/declarations/WebpackOptions.d.ts +1466 -0
  12. package/declarations/plugins/BannerPlugin.d.ts +49 -0
  13. package/declarations/plugins/DllPlugin.d.ts +32 -0
  14. package/declarations/plugins/DllReferencePlugin.d.ts +126 -0
  15. package/declarations/plugins/HashedModuleIdsPlugin.d.ts +24 -0
  16. package/declarations/plugins/IgnorePlugin.d.ts +27 -0
  17. package/declarations/plugins/LoaderOptionsPlugin.d.ts +27 -0
  18. package/declarations/plugins/ProgressPlugin.d.ts +42 -0
  19. package/declarations/plugins/SourceMapDevToolPlugin.d.ts +94 -0
  20. package/declarations/plugins/WatchIgnorePlugin.d.ts +10 -0
  21. package/declarations/plugins/debug/ProfilingPlugin.d.ts +12 -0
  22. package/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +24 -0
  23. package/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +16 -0
  24. package/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +12 -0
  25. package/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +12 -0
  26. package/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +12 -0
  27. package/hot/dev-server.js +61 -0
  28. package/hot/emitter.js +2 -0
  29. package/hot/log-apply-result.js +44 -0
  30. package/hot/log.js +59 -0
  31. package/hot/only-dev-server.js +102 -0
  32. package/hot/poll.js +37 -0
  33. package/hot/signal.js +62 -0
  34. package/lib/APIPlugin.js +84 -0
  35. package/lib/AbstractMethodError.js +43 -0
  36. package/lib/AmdMainTemplatePlugin.js +106 -0
  37. package/lib/AsyncDependenciesBlock.js +110 -0
  38. package/lib/AsyncDependencyToInitialChunkError.js +31 -0
  39. package/lib/AutomaticPrefetchPlugin.js +57 -0
  40. package/lib/BannerPlugin.js +122 -0
  41. package/lib/BasicEvaluatedExpression.js +248 -0
  42. package/lib/CachePlugin.js +100 -0
  43. package/lib/CaseSensitiveModulesWarning.js +67 -0
  44. package/lib/Chunk.js +875 -0
  45. package/lib/ChunkGroup.js +513 -0
  46. package/lib/ChunkRenderError.js +32 -0
  47. package/lib/ChunkTemplate.js +87 -0
  48. package/lib/CommentCompilationWarning.js +32 -0
  49. package/lib/CommonJsStuffPlugin.js +116 -0
  50. package/lib/CompatibilityPlugin.js +70 -0
  51. package/lib/Compilation.js +2327 -0
  52. package/lib/Compiler.js +735 -0
  53. package/lib/ConcurrentCompilationError.js +19 -0
  54. package/lib/ConstPlugin.js +348 -0
  55. package/lib/ContextExclusionPlugin.js +28 -0
  56. package/lib/ContextModule.js +872 -0
  57. package/lib/ContextModuleFactory.js +262 -0
  58. package/lib/ContextReplacementPlugin.js +133 -0
  59. package/lib/DefinePlugin.js +289 -0
  60. package/lib/DelegatedModule.js +114 -0
  61. package/lib/DelegatedModuleFactoryPlugin.js +95 -0
  62. package/lib/DelegatedPlugin.js +39 -0
  63. package/lib/DependenciesBlock.js +124 -0
  64. package/lib/DependenciesBlockVariable.js +72 -0
  65. package/lib/Dependency.js +89 -0
  66. package/lib/DllEntryPlugin.js +54 -0
  67. package/lib/DllModule.js +60 -0
  68. package/lib/DllModuleFactory.js +29 -0
  69. package/lib/DllPlugin.js +49 -0
  70. package/lib/DllReferencePlugin.js +156 -0
  71. package/lib/DynamicEntryPlugin.js +94 -0
  72. package/lib/EntryModuleNotFoundError.js +21 -0
  73. package/lib/EntryOptionPlugin.js +46 -0
  74. package/lib/Entrypoint.js +64 -0
  75. package/lib/EnvironmentPlugin.js +72 -0
  76. package/lib/ErrorHelpers.js +60 -0
  77. package/lib/EvalDevToolModulePlugin.js +27 -0
  78. package/lib/EvalDevToolModuleTemplatePlugin.js +61 -0
  79. package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +120 -0
  80. package/lib/EvalSourceMapDevToolPlugin.js +41 -0
  81. package/lib/ExportPropertyMainTemplatePlugin.js +53 -0
  82. package/lib/ExtendedAPIPlugin.js +88 -0
  83. package/lib/ExternalModule.js +179 -0
  84. package/lib/ExternalModuleFactoryPlugin.js +110 -0
  85. package/lib/ExternalsPlugin.js +23 -0
  86. package/lib/FlagAllModulesAsUsedPlugin.js +38 -0
  87. package/lib/FlagDependencyExportsPlugin.js +174 -0
  88. package/lib/FlagDependencyUsagePlugin.js +116 -0
  89. package/lib/FlagInitialModulesAsUsedPlugin.js +36 -0
  90. package/lib/FunctionModulePlugin.js +19 -0
  91. package/lib/FunctionModuleTemplatePlugin.js +102 -0
  92. package/lib/Generator.js +60 -0
  93. package/lib/GraphHelpers.js +65 -0
  94. package/lib/HarmonyLinkingError.js +17 -0
  95. package/lib/HashedModuleIdsPlugin.js +63 -0
  96. package/lib/HotModuleReplacement.runtime.js +721 -0
  97. package/lib/HotModuleReplacementPlugin.js +425 -0
  98. package/lib/HotUpdateChunk.js +17 -0
  99. package/lib/HotUpdateChunkTemplate.js +78 -0
  100. package/lib/IgnorePlugin.js +91 -0
  101. package/lib/JavascriptGenerator.js +229 -0
  102. package/lib/JavascriptModulesPlugin.js +185 -0
  103. package/lib/JsonGenerator.js +57 -0
  104. package/lib/JsonModulesPlugin.js +30 -0
  105. package/lib/JsonParser.js +27 -0
  106. package/lib/LibManifestPlugin.js +90 -0
  107. package/lib/LibraryTemplatePlugin.js +186 -0
  108. package/lib/LoaderOptionsPlugin.js +58 -0
  109. package/lib/LoaderTargetPlugin.js +24 -0
  110. package/lib/MainTemplate.js +568 -0
  111. package/lib/MemoryOutputFileSystem.js +5 -0
  112. package/lib/Module.js +435 -0
  113. package/lib/ModuleBuildError.js +52 -0
  114. package/lib/ModuleDependencyError.js +35 -0
  115. package/lib/ModuleDependencyWarning.js +25 -0
  116. package/lib/ModuleError.js +36 -0
  117. package/lib/ModuleFilenameHelpers.js +179 -0
  118. package/lib/ModuleNotFoundError.js +23 -0
  119. package/lib/ModuleParseError.js +67 -0
  120. package/lib/ModuleReason.js +48 -0
  121. package/lib/ModuleTemplate.js +93 -0
  122. package/lib/ModuleWarning.js +36 -0
  123. package/lib/MultiCompiler.js +290 -0
  124. package/lib/MultiEntryPlugin.js +80 -0
  125. package/lib/MultiModule.js +87 -0
  126. package/lib/MultiModuleFactory.js +23 -0
  127. package/lib/MultiStats.js +92 -0
  128. package/lib/MultiWatching.js +50 -0
  129. package/lib/NamedChunksPlugin.js +29 -0
  130. package/lib/NamedModulesPlugin.js +58 -0
  131. package/lib/NoEmitOnErrorsPlugin.js +20 -0
  132. package/lib/NoModeWarning.js +23 -0
  133. package/lib/NodeStuffPlugin.js +118 -0
  134. package/lib/NormalModule.js +582 -0
  135. package/lib/NormalModuleFactory.js +528 -0
  136. package/lib/NormalModuleReplacementPlugin.js +51 -0
  137. package/lib/NullFactory.js +12 -0
  138. package/lib/OptionsApply.js +10 -0
  139. package/lib/OptionsDefaulter.js +141 -0
  140. package/lib/Parser.js +2454 -0
  141. package/lib/ParserHelpers.js +103 -0
  142. package/lib/PrefetchPlugin.js +37 -0
  143. package/lib/ProgressPlugin.js +307 -0
  144. package/lib/ProvidePlugin.js +86 -0
  145. package/lib/RawModule.js +56 -0
  146. package/lib/RecordIdsPlugin.js +236 -0
  147. package/lib/RemovedPluginError.js +11 -0
  148. package/lib/RequestShortener.js +83 -0
  149. package/lib/RequireJsStuffPlugin.js +66 -0
  150. package/lib/ResolverFactory.js +74 -0
  151. package/lib/RuleSet.js +567 -0
  152. package/lib/RuntimeTemplate.js +336 -0
  153. package/lib/SetVarMainTemplatePlugin.js +69 -0
  154. package/lib/SingleEntryPlugin.js +63 -0
  155. package/lib/SizeFormatHelpers.js +24 -0
  156. package/lib/SourceMapDevToolModuleOptionsPlugin.js +49 -0
  157. package/lib/SourceMapDevToolPlugin.js +418 -0
  158. package/lib/Stats.js +1685 -0
  159. package/lib/SystemMainTemplatePlugin.js +137 -0
  160. package/lib/Template.js +291 -0
  161. package/lib/TemplatedPathPlugin.js +188 -0
  162. package/lib/UmdMainTemplatePlugin.js +305 -0
  163. package/lib/UnsupportedFeatureWarning.js +30 -0
  164. package/lib/UseStrictPlugin.js +54 -0
  165. package/lib/WarnCaseSensitiveModulesPlugin.js +37 -0
  166. package/lib/WarnNoModeSetPlugin.js +17 -0
  167. package/lib/WatchIgnorePlugin.js +106 -0
  168. package/lib/Watching.js +211 -0
  169. package/lib/WebpackError.js +31 -0
  170. package/lib/WebpackOptionsApply.js +546 -0
  171. package/lib/WebpackOptionsDefaulter.js +391 -0
  172. package/lib/WebpackOptionsValidationError.js +390 -0
  173. package/lib/buildChunkGraph.js +712 -0
  174. package/lib/compareLocations.js +52 -0
  175. package/lib/debug/ProfilingPlugin.js +442 -0
  176. package/lib/dependencies/AMDDefineDependency.js +137 -0
  177. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +336 -0
  178. package/lib/dependencies/AMDPlugin.js +249 -0
  179. package/lib/dependencies/AMDRequireArrayDependency.js +49 -0
  180. package/lib/dependencies/AMDRequireContextDependency.js +20 -0
  181. package/lib/dependencies/AMDRequireDependenciesBlock.js +47 -0
  182. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +274 -0
  183. package/lib/dependencies/AMDRequireDependency.js +135 -0
  184. package/lib/dependencies/AMDRequireItemDependency.js +22 -0
  185. package/lib/dependencies/CommonJsPlugin.js +158 -0
  186. package/lib/dependencies/CommonJsRequireContextDependency.js +23 -0
  187. package/lib/dependencies/CommonJsRequireDependency.js +22 -0
  188. package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +138 -0
  189. package/lib/dependencies/ConstDependency.js +33 -0
  190. package/lib/dependencies/ContextDependency.js +68 -0
  191. package/lib/dependencies/ContextDependencyHelpers.js +232 -0
  192. package/lib/dependencies/ContextDependencyTemplateAsId.js +43 -0
  193. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +39 -0
  194. package/lib/dependencies/ContextElementDependency.js +21 -0
  195. package/lib/dependencies/CriticalDependencyWarning.js +20 -0
  196. package/lib/dependencies/DelegatedExportsDependency.js +33 -0
  197. package/lib/dependencies/DelegatedSourceDependency.js +18 -0
  198. package/lib/dependencies/DependencyReference.js +64 -0
  199. package/lib/dependencies/DllEntryDependency.js +20 -0
  200. package/lib/dependencies/HarmonyAcceptDependency.js +48 -0
  201. package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -0
  202. package/lib/dependencies/HarmonyCompatibilityDependency.js +31 -0
  203. package/lib/dependencies/HarmonyDetectionParserPlugin.js +96 -0
  204. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +154 -0
  205. package/lib/dependencies/HarmonyExportExpressionDependency.js +58 -0
  206. package/lib/dependencies/HarmonyExportHeaderDependency.js +30 -0
  207. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +659 -0
  208. package/lib/dependencies/HarmonyExportSpecifierDependency.js +54 -0
  209. package/lib/dependencies/HarmonyImportDependency.js +109 -0
  210. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +222 -0
  211. package/lib/dependencies/HarmonyImportSideEffectDependency.js +31 -0
  212. package/lib/dependencies/HarmonyImportSpecifierDependency.js +163 -0
  213. package/lib/dependencies/HarmonyInitDependency.js +60 -0
  214. package/lib/dependencies/HarmonyModulesPlugin.js +143 -0
  215. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +26 -0
  216. package/lib/dependencies/ImportContextDependency.js +23 -0
  217. package/lib/dependencies/ImportDependenciesBlock.js +18 -0
  218. package/lib/dependencies/ImportDependency.js +34 -0
  219. package/lib/dependencies/ImportEagerDependency.js +32 -0
  220. package/lib/dependencies/ImportParserPlugin.js +248 -0
  221. package/lib/dependencies/ImportPlugin.js +79 -0
  222. package/lib/dependencies/ImportWeakDependency.js +34 -0
  223. package/lib/dependencies/JsonExportsDependency.js +26 -0
  224. package/lib/dependencies/LoaderDependency.js +21 -0
  225. package/lib/dependencies/LoaderPlugin.js +115 -0
  226. package/lib/dependencies/LocalModule.js +23 -0
  227. package/lib/dependencies/LocalModuleDependency.js +28 -0
  228. package/lib/dependencies/LocalModulesHelpers.js +52 -0
  229. package/lib/dependencies/ModuleDependency.js +23 -0
  230. package/lib/dependencies/ModuleDependencyTemplateAsId.js +17 -0
  231. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +17 -0
  232. package/lib/dependencies/ModuleHotAcceptDependency.js +23 -0
  233. package/lib/dependencies/ModuleHotDeclineDependency.js +23 -0
  234. package/lib/dependencies/MultiEntryDependency.js +25 -0
  235. package/lib/dependencies/NullDependency.js +20 -0
  236. package/lib/dependencies/PrefetchDependency.js +18 -0
  237. package/lib/dependencies/RequireContextDependency.js +22 -0
  238. package/lib/dependencies/RequireContextDependencyParserPlugin.js +56 -0
  239. package/lib/dependencies/RequireContextPlugin.js +143 -0
  240. package/lib/dependencies/RequireEnsureDependenciesBlock.js +33 -0
  241. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +116 -0
  242. package/lib/dependencies/RequireEnsureDependency.js +58 -0
  243. package/lib/dependencies/RequireEnsureItemDependency.js +21 -0
  244. package/lib/dependencies/RequireEnsurePlugin.js +74 -0
  245. package/lib/dependencies/RequireHeaderDependency.js +26 -0
  246. package/lib/dependencies/RequireIncludeDependency.js +39 -0
  247. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +23 -0
  248. package/lib/dependencies/RequireIncludePlugin.js +61 -0
  249. package/lib/dependencies/RequireResolveContextDependency.js +23 -0
  250. package/lib/dependencies/RequireResolveDependency.js +22 -0
  251. package/lib/dependencies/RequireResolveDependencyParserPlugin.js +86 -0
  252. package/lib/dependencies/RequireResolveHeaderDependency.js +26 -0
  253. package/lib/dependencies/SingleEntryDependency.js +21 -0
  254. package/lib/dependencies/SystemPlugin.js +122 -0
  255. package/lib/dependencies/UnsupportedDependency.js +27 -0
  256. package/lib/dependencies/WebAssemblyExportImportedDependency.js +31 -0
  257. package/lib/dependencies/WebAssemblyImportDependency.js +54 -0
  258. package/lib/dependencies/WebpackMissingModule.js +20 -0
  259. package/lib/dependencies/getFunctionExpression.js +52 -0
  260. package/lib/formatLocation.js +75 -0
  261. package/lib/logging/Logger.js +128 -0
  262. package/lib/logging/createConsoleLogger.js +210 -0
  263. package/lib/logging/runtime.js +36 -0
  264. package/lib/logging/truncateArgs.js +76 -0
  265. package/lib/node/NodeChunkTemplatePlugin.js +31 -0
  266. package/lib/node/NodeEnvironmentPlugin.js +44 -0
  267. package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -0
  268. package/lib/node/NodeMainTemplate.runtime.js +32 -0
  269. package/lib/node/NodeMainTemplateAsync.runtime.js +50 -0
  270. package/lib/node/NodeMainTemplatePlugin.js +321 -0
  271. package/lib/node/NodeOutputFileSystem.js +22 -0
  272. package/lib/node/NodeSourcePlugin.js +141 -0
  273. package/lib/node/NodeTargetPlugin.js +19 -0
  274. package/lib/node/NodeTemplatePlugin.js +31 -0
  275. package/lib/node/NodeWatchFileSystem.js +109 -0
  276. package/lib/node/ReadFileCompileWasmTemplatePlugin.js +61 -0
  277. package/lib/node/nodeConsole.js +135 -0
  278. package/lib/optimize/AggressiveMergingPlugin.js +87 -0
  279. package/lib/optimize/AggressiveSplittingPlugin.js +294 -0
  280. package/lib/optimize/ChunkModuleIdRangePlugin.js +66 -0
  281. package/lib/optimize/ConcatenatedModule.js +1477 -0
  282. package/lib/optimize/EnsureChunkConditionsPlugin.js +70 -0
  283. package/lib/optimize/FlagIncludedChunksPlugin.js +99 -0
  284. package/lib/optimize/LimitChunkCountPlugin.js +231 -0
  285. package/lib/optimize/MergeDuplicateChunksPlugin.js +78 -0
  286. package/lib/optimize/MinChunkSizePlugin.js +82 -0
  287. package/lib/optimize/MinMaxSizeWarning.js +29 -0
  288. package/lib/optimize/ModuleConcatenationPlugin.js +485 -0
  289. package/lib/optimize/NaturalChunkOrderPlugin.js +41 -0
  290. package/lib/optimize/OccurrenceChunkOrderPlugin.js +66 -0
  291. package/lib/optimize/OccurrenceModuleOrderPlugin.js +112 -0
  292. package/lib/optimize/OccurrenceOrderPlugin.js +135 -0
  293. package/lib/optimize/RemoveEmptyChunksPlugin.js +42 -0
  294. package/lib/optimize/RemoveParentModulesPlugin.js +127 -0
  295. package/lib/optimize/RuntimeChunkPlugin.js +41 -0
  296. package/lib/optimize/SideEffectsFlagPlugin.js +352 -0
  297. package/lib/optimize/SplitChunksPlugin.js +971 -0
  298. package/lib/performance/AssetsOverSizeLimitWarning.js +30 -0
  299. package/lib/performance/EntrypointsOverSizeLimitWarning.js +30 -0
  300. package/lib/performance/NoAsyncChunksWarning.js +21 -0
  301. package/lib/performance/SizeLimitsPlugin.js +125 -0
  302. package/lib/util/LazyBucketSortedSet.js +235 -0
  303. package/lib/util/Queue.js +46 -0
  304. package/lib/util/Semaphore.js +53 -0
  305. package/lib/util/SetHelpers.js +48 -0
  306. package/lib/util/SortableSet.js +140 -0
  307. package/lib/util/StackedSetMap.js +142 -0
  308. package/lib/util/TrackingSet.js +35 -0
  309. package/lib/util/cachedMerge.js +35 -0
  310. package/lib/util/cleverMerge.js +77 -0
  311. package/lib/util/createHash.js +174 -0
  312. package/lib/util/deterministicGrouping.js +274 -0
  313. package/lib/util/hash/BatchedHash.js +71 -0
  314. package/lib/util/hash/md4.js +25 -0
  315. package/lib/util/hash/wasm-hash.js +174 -0
  316. package/lib/util/identifier.js +127 -0
  317. package/lib/util/objectToMap.js +16 -0
  318. package/lib/validateSchema.js +67 -0
  319. package/lib/wasm/UnsupportedWebAssemblyFeatureError.js +17 -0
  320. package/lib/wasm/WasmFinalizeExportsPlugin.js +69 -0
  321. package/lib/wasm/WasmMainTemplatePlugin.js +341 -0
  322. package/lib/wasm/WebAssemblyGenerator.js +458 -0
  323. package/lib/wasm/WebAssemblyInInitialChunkError.js +88 -0
  324. package/lib/wasm/WebAssemblyJavascriptGenerator.js +152 -0
  325. package/lib/wasm/WebAssemblyModulesPlugin.js +128 -0
  326. package/lib/wasm/WebAssemblyParser.js +175 -0
  327. package/lib/wasm/WebAssemblyUtils.js +59 -0
  328. package/lib/web/FetchCompileWasmTemplatePlugin.js +37 -0
  329. package/lib/web/JsonpChunkTemplatePlugin.js +71 -0
  330. package/lib/web/JsonpExportMainTemplatePlugin.js +50 -0
  331. package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -0
  332. package/lib/web/JsonpMainTemplate.runtime.js +71 -0
  333. package/lib/web/JsonpMainTemplatePlugin.js +615 -0
  334. package/lib/web/JsonpTemplatePlugin.js +23 -0
  335. package/lib/web/WebEnvironmentPlugin.js +18 -0
  336. package/lib/webpack.js +206 -0
  337. package/lib/webpack.web.js +31 -0
  338. package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -0
  339. package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -0
  340. package/lib/webworker/WebWorkerMainTemplate.runtime.js +73 -0
  341. package/lib/webworker/WebWorkerMainTemplatePlugin.js +192 -0
  342. package/lib/webworker/WebWorkerTemplatePlugin.js +25 -0
  343. package/package.json +211 -0
  344. package/schemas/WebpackOptions.json +2285 -0
  345. package/schemas/ajv.absolutePath.js +57 -0
  346. package/schemas/plugins/BannerPlugin.json +101 -0
  347. package/schemas/plugins/DllPlugin.json +36 -0
  348. package/schemas/plugins/DllReferencePlugin.json +205 -0
  349. package/schemas/plugins/HashedModuleIdsPlugin.json +26 -0
  350. package/schemas/plugins/IgnorePlugin.json +37 -0
  351. package/schemas/plugins/LoaderOptionsPlugin.json +27 -0
  352. package/schemas/plugins/ProgressPlugin.json +52 -0
  353. package/schemas/plugins/SourceMapDevToolPlugin.json +185 -0
  354. package/schemas/plugins/WatchIgnorePlugin.json +18 -0
  355. package/schemas/plugins/debug/ProfilingPlugin.json +13 -0
  356. package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +23 -0
  357. package/schemas/plugins/optimize/LimitChunkCountPlugin.json +16 -0
  358. package/schemas/plugins/optimize/MinChunkSizePlugin.json +12 -0
  359. package/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +11 -0
  360. package/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +11 -0
  361. package/web_modules/node-libs-browser.js +0 -0
@@ -0,0 +1,1477 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ "use strict";
6
+
7
+ const Module = require("../Module");
8
+ const Template = require("../Template");
9
+ const Parser = require("../Parser");
10
+ const eslintScope = require("eslint-scope");
11
+ const { ConcatSource, ReplaceSource } = require("webpack-sources");
12
+ const DependencyReference = require("../dependencies/DependencyReference");
13
+ const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
14
+ const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency");
15
+ const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency");
16
+ const HarmonyExportSpecifierDependency = require("../dependencies/HarmonyExportSpecifierDependency");
17
+ const HarmonyExportExpressionDependency = require("../dependencies/HarmonyExportExpressionDependency");
18
+ const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
19
+ const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
20
+ const createHash = require("../util/createHash");
21
+
22
+ /** @typedef {import("../Dependency")} Dependency */
23
+ /** @typedef {import("../Compilation")} Compilation */
24
+ /** @typedef {import("../util/createHash").Hash} Hash */
25
+ /** @typedef {import("../RequestShortener")} RequestShortener */
26
+
27
+ const joinIterableWithComma = iterable => {
28
+ // This is more performant than Array.from().join(", ")
29
+ // as it doesn't create an array
30
+ let str = "";
31
+ let first = true;
32
+ for (const item of iterable) {
33
+ if (first) {
34
+ first = false;
35
+ } else {
36
+ str += ", ";
37
+ }
38
+ str += item;
39
+ }
40
+ return str;
41
+ };
42
+
43
+ /**
44
+ * @typedef {Object} ConcatenationEntry
45
+ * @property {"concatenated" | "external"} type
46
+ * @property {Module} module
47
+ */
48
+
49
+ const ensureNsObjSource = (
50
+ info,
51
+ moduleToInfoMap,
52
+ requestShortener,
53
+ strictHarmonyModule
54
+ ) => {
55
+ if (!info.hasNamespaceObject) {
56
+ info.hasNamespaceObject = true;
57
+ const name = info.exportMap.get(true);
58
+ const nsObj = [`var ${name} = {};`, `__webpack_require__.r(${name});`];
59
+ for (const exportName of info.module.buildMeta.providedExports) {
60
+ const finalName = getFinalName(
61
+ info,
62
+ exportName,
63
+ moduleToInfoMap,
64
+ requestShortener,
65
+ false,
66
+ strictHarmonyModule
67
+ );
68
+ nsObj.push(
69
+ `__webpack_require__.d(${name}, ${JSON.stringify(
70
+ exportName
71
+ )}, function() { return ${finalName}; });`
72
+ );
73
+ }
74
+ info.namespaceObjectSource = nsObj.join("\n") + "\n";
75
+ }
76
+ };
77
+
78
+ const getExternalImport = (
79
+ importedModule,
80
+ info,
81
+ exportName,
82
+ asCall,
83
+ strictHarmonyModule
84
+ ) => {
85
+ const used = importedModule.isUsed(exportName);
86
+ if (!used) return "/* unused reexport */undefined";
87
+ const comment =
88
+ used !== exportName ? ` ${Template.toNormalComment(exportName)}` : "";
89
+ switch (importedModule.buildMeta.exportsType) {
90
+ case "named":
91
+ if (exportName === "default") {
92
+ return info.name;
93
+ } else if (exportName === true) {
94
+ info.interopNamespaceObjectUsed = true;
95
+ return info.interopNamespaceObjectName;
96
+ } else {
97
+ break;
98
+ }
99
+ case "namespace":
100
+ if (exportName === true) {
101
+ return info.name;
102
+ } else {
103
+ break;
104
+ }
105
+ default:
106
+ if (strictHarmonyModule) {
107
+ if (exportName === "default") {
108
+ return info.name;
109
+ } else if (exportName === true) {
110
+ info.interopNamespaceObjectUsed = true;
111
+ return info.interopNamespaceObjectName;
112
+ } else {
113
+ return "/* non-default import from non-esm module */undefined";
114
+ }
115
+ } else {
116
+ if (exportName === "default") {
117
+ info.interopDefaultAccessUsed = true;
118
+ return asCall
119
+ ? `${info.interopDefaultAccessName}()`
120
+ : `${info.interopDefaultAccessName}.a`;
121
+ } else if (exportName === true) {
122
+ return info.name;
123
+ } else {
124
+ break;
125
+ }
126
+ }
127
+ }
128
+ const reference = `${info.name}[${JSON.stringify(used)}${comment}]`;
129
+ if (asCall) return `Object(${reference})`;
130
+ return reference;
131
+ };
132
+
133
+ const getFinalName = (
134
+ info,
135
+ exportName,
136
+ moduleToInfoMap,
137
+ requestShortener,
138
+ asCall,
139
+ strictHarmonyModule,
140
+ alreadyVisited = new Set()
141
+ ) => {
142
+ switch (info.type) {
143
+ case "concatenated": {
144
+ const directExport = info.exportMap.get(exportName);
145
+ if (directExport) {
146
+ if (exportName === true) {
147
+ ensureNsObjSource(
148
+ info,
149
+ moduleToInfoMap,
150
+ requestShortener,
151
+ strictHarmonyModule
152
+ );
153
+ } else if (!info.module.isUsed(exportName)) {
154
+ return "/* unused export */ undefined";
155
+ }
156
+ if (info.globalExports.has(directExport)) {
157
+ return directExport;
158
+ }
159
+ const name = info.internalNames.get(directExport);
160
+ if (!name) {
161
+ throw new Error(
162
+ `The export "${directExport}" in "${info.module.readableIdentifier(
163
+ requestShortener
164
+ )}" has no internal name`
165
+ );
166
+ }
167
+ return name;
168
+ }
169
+ const reexport = info.reexportMap.get(exportName);
170
+ if (reexport) {
171
+ if (alreadyVisited.has(reexport)) {
172
+ throw new Error(
173
+ `Circular reexports ${Array.from(
174
+ alreadyVisited,
175
+ e =>
176
+ `"${e.module.readableIdentifier(requestShortener)}".${
177
+ e.exportName
178
+ }`
179
+ ).join(
180
+ " --> "
181
+ )} -(circular)-> "${reexport.module.readableIdentifier(
182
+ requestShortener
183
+ )}".${reexport.exportName}`
184
+ );
185
+ }
186
+ alreadyVisited.add(reexport);
187
+ const refInfo = moduleToInfoMap.get(reexport.module);
188
+ if (refInfo) {
189
+ // module is in the concatenation
190
+ return getFinalName(
191
+ refInfo,
192
+ reexport.exportName,
193
+ moduleToInfoMap,
194
+ requestShortener,
195
+ asCall,
196
+ strictHarmonyModule,
197
+ alreadyVisited
198
+ );
199
+ }
200
+ }
201
+ const problem =
202
+ `Cannot get final name for export "${exportName}" in "${info.module.readableIdentifier(
203
+ requestShortener
204
+ )}"` +
205
+ ` (known exports: ${Array.from(info.exportMap.keys())
206
+ .filter(name => name !== true)
207
+ .join(" ")}, ` +
208
+ `known reexports: ${Array.from(info.reexportMap.keys()).join(" ")})`;
209
+ return `${Template.toNormalComment(problem)} undefined`;
210
+ }
211
+ case "external": {
212
+ const importedModule = info.module;
213
+ return getExternalImport(
214
+ importedModule,
215
+ info,
216
+ exportName,
217
+ asCall,
218
+ strictHarmonyModule
219
+ );
220
+ }
221
+ }
222
+ };
223
+
224
+ const addScopeSymbols1 = (s, nameSet, scopeSet) => {
225
+ let scope = s;
226
+ while (scope) {
227
+ if (scopeSet.has(scope)) break;
228
+ scopeSet.add(scope);
229
+ for (const variable of scope.variables) {
230
+ nameSet.add(variable.name);
231
+ }
232
+ scope = scope.upper;
233
+ }
234
+ };
235
+
236
+ const addScopeSymbols2 = (s, nameSet, scopeSet1, scopeSet2) => {
237
+ let scope = s;
238
+ while (scope) {
239
+ if (scopeSet1.has(scope)) break;
240
+ if (scopeSet2.has(scope)) break;
241
+ scopeSet1.add(scope);
242
+ for (const variable of scope.variables) {
243
+ nameSet.add(variable.name);
244
+ }
245
+ scope = scope.upper;
246
+ }
247
+ };
248
+
249
+ const getAllReferences = variable => {
250
+ let set = variable.references;
251
+ // Look for inner scope variables too (like in class Foo { t() { Foo } })
252
+ const identifiers = new Set(variable.identifiers);
253
+ for (const scope of variable.scope.childScopes) {
254
+ for (const innerVar of scope.variables) {
255
+ if (innerVar.identifiers.some(id => identifiers.has(id))) {
256
+ set = set.concat(innerVar.references);
257
+ break;
258
+ }
259
+ }
260
+ }
261
+ return set;
262
+ };
263
+
264
+ const getPathInAst = (ast, node) => {
265
+ if (ast === node) {
266
+ return [];
267
+ }
268
+
269
+ const nr = node.range;
270
+
271
+ const enterNode = n => {
272
+ if (!n) return undefined;
273
+ const r = n.range;
274
+ if (r) {
275
+ if (r[0] <= nr[0] && r[1] >= nr[1]) {
276
+ const path = getPathInAst(n, node);
277
+ if (path) {
278
+ path.push(n);
279
+ return path;
280
+ }
281
+ }
282
+ }
283
+ return undefined;
284
+ };
285
+
286
+ var i;
287
+ if (Array.isArray(ast)) {
288
+ for (i = 0; i < ast.length; i++) {
289
+ const enterResult = enterNode(ast[i]);
290
+ if (enterResult !== undefined) return enterResult;
291
+ }
292
+ } else if (ast && typeof ast === "object") {
293
+ const keys = Object.keys(ast);
294
+ for (i = 0; i < keys.length; i++) {
295
+ const value = ast[keys[i]];
296
+ if (Array.isArray(value)) {
297
+ const pathResult = getPathInAst(value, node);
298
+ if (pathResult !== undefined) return pathResult;
299
+ } else if (value && typeof value === "object") {
300
+ const enterResult = enterNode(value);
301
+ if (enterResult !== undefined) return enterResult;
302
+ }
303
+ }
304
+ }
305
+ };
306
+
307
+ const getHarmonyExportImportedSpecifierDependencyExports = dep => {
308
+ const importModule = dep._module;
309
+ if (!importModule) return [];
310
+ if (dep._id) {
311
+ // export { named } from "module"
312
+ return [
313
+ {
314
+ name: dep.name,
315
+ id: dep._id,
316
+ module: importModule
317
+ }
318
+ ];
319
+ }
320
+ if (dep.name) {
321
+ // export * as abc from "module"
322
+ return [
323
+ {
324
+ name: dep.name,
325
+ id: true,
326
+ module: importModule
327
+ }
328
+ ];
329
+ }
330
+ // export * from "module"
331
+ return importModule.buildMeta.providedExports
332
+ .filter(exp => exp !== "default" && !dep.activeExports.has(exp))
333
+ .map(exp => {
334
+ return {
335
+ name: exp,
336
+ id: exp,
337
+ module: importModule
338
+ };
339
+ });
340
+ };
341
+
342
+ class ConcatenatedModule extends Module {
343
+ constructor(rootModule, modules, concatenationList) {
344
+ super("javascript/esm", null);
345
+ super.setChunks(rootModule._chunks);
346
+
347
+ // Info from Factory
348
+ this.rootModule = rootModule;
349
+ this.factoryMeta = rootModule.factoryMeta;
350
+
351
+ // Info from Compilation
352
+ this.index = rootModule.index;
353
+ this.index2 = rootModule.index2;
354
+ this.depth = rootModule.depth;
355
+
356
+ // Info from Optimization
357
+ this.used = rootModule.used;
358
+ this.usedExports = rootModule.usedExports;
359
+
360
+ // Info from Build
361
+ this.buildInfo = {
362
+ strict: true,
363
+ cacheable: modules.every(m => m.buildInfo.cacheable),
364
+ moduleArgument: rootModule.buildInfo.moduleArgument,
365
+ exportsArgument: rootModule.buildInfo.exportsArgument,
366
+ fileDependencies: new Set(),
367
+ contextDependencies: new Set(),
368
+ assets: undefined
369
+ };
370
+ this.built = modules.some(m => m.built);
371
+ this.buildMeta = rootModule.buildMeta;
372
+
373
+ // Caching
374
+ this._numberOfConcatenatedModules = modules.length;
375
+
376
+ // Graph
377
+ const modulesSet = new Set(modules);
378
+ this.reasons = rootModule.reasons.filter(
379
+ reason =>
380
+ !(reason.dependency instanceof HarmonyImportDependency) ||
381
+ !modulesSet.has(reason.module)
382
+ );
383
+
384
+ this.dependencies = [];
385
+ this.blocks = [];
386
+
387
+ this.warnings = [];
388
+ this.errors = [];
389
+ this._orderedConcatenationList =
390
+ concatenationList ||
391
+ ConcatenatedModule.createConcatenationList(rootModule, modulesSet, null);
392
+ for (const info of this._orderedConcatenationList) {
393
+ if (info.type === "concatenated") {
394
+ const m = info.module;
395
+
396
+ // populate dependencies
397
+ for (const d of m.dependencies.filter(
398
+ dep =>
399
+ !(dep instanceof HarmonyImportDependency) ||
400
+ !modulesSet.has(dep._module)
401
+ )) {
402
+ this.dependencies.push(d);
403
+ }
404
+ // populate blocks
405
+ for (const d of m.blocks) {
406
+ this.blocks.push(d);
407
+ }
408
+ // populate file dependencies
409
+ if (m.buildInfo.fileDependencies) {
410
+ for (const file of m.buildInfo.fileDependencies) {
411
+ this.buildInfo.fileDependencies.add(file);
412
+ }
413
+ }
414
+ // populate context dependencies
415
+ if (m.buildInfo.contextDependencies) {
416
+ for (const context of m.buildInfo.contextDependencies) {
417
+ this.buildInfo.contextDependencies.add(context);
418
+ }
419
+ }
420
+ // populate warnings
421
+ for (const warning of m.warnings) {
422
+ this.warnings.push(warning);
423
+ }
424
+ // populate errors
425
+ for (const error of m.errors) {
426
+ this.errors.push(error);
427
+ }
428
+
429
+ if (m.buildInfo.assets) {
430
+ if (this.buildInfo.assets === undefined) {
431
+ this.buildInfo.assets = Object.create(null);
432
+ }
433
+ Object.assign(this.buildInfo.assets, m.buildInfo.assets);
434
+ }
435
+ if (m.buildInfo.assetsInfo) {
436
+ if (this.buildInfo.assetsInfo === undefined) {
437
+ this.buildInfo.assetsInfo = new Map();
438
+ }
439
+ for (const [key, value] of m.buildInfo.assetsInfo) {
440
+ this.buildInfo.assetsInfo.set(key, value);
441
+ }
442
+ }
443
+ }
444
+ }
445
+ this._identifier = this._createIdentifier();
446
+ }
447
+
448
+ get modules() {
449
+ return this._orderedConcatenationList
450
+ .filter(info => info.type === "concatenated")
451
+ .map(info => info.module);
452
+ }
453
+
454
+ identifier() {
455
+ return this._identifier;
456
+ }
457
+
458
+ readableIdentifier(requestShortener) {
459
+ return (
460
+ this.rootModule.readableIdentifier(requestShortener) +
461
+ ` + ${this._numberOfConcatenatedModules - 1} modules`
462
+ );
463
+ }
464
+
465
+ libIdent(options) {
466
+ return this.rootModule.libIdent(options);
467
+ }
468
+
469
+ nameForCondition() {
470
+ return this.rootModule.nameForCondition();
471
+ }
472
+
473
+ build(options, compilation, resolver, fs, callback) {
474
+ throw new Error("Cannot build this module. It should be already built.");
475
+ }
476
+
477
+ size() {
478
+ // Guess size from embedded modules
479
+ return this._orderedConcatenationList.reduce((sum, info) => {
480
+ switch (info.type) {
481
+ case "concatenated":
482
+ return sum + info.module.size();
483
+ case "external":
484
+ return sum + 5;
485
+ }
486
+ return sum;
487
+ }, 0);
488
+ }
489
+
490
+ /**
491
+ * @param {Module} rootModule the root of the concatenation
492
+ * @param {Set<Module>} modulesSet a set of modules which should be concatenated
493
+ * @param {Compilation} compilation the compilation context
494
+ * @returns {ConcatenationEntry[]} concatenation list
495
+ */
496
+ static createConcatenationList(rootModule, modulesSet, compilation) {
497
+ const list = [];
498
+ const set = new Set();
499
+
500
+ /**
501
+ * @param {Module} module a module
502
+ * @returns {(function(): Module)[]} imported modules in order
503
+ */
504
+ const getConcatenatedImports = module => {
505
+ /** @type {WeakMap<DependencyReference, Dependency>} */
506
+ const map = new WeakMap();
507
+ const references = module.dependencies
508
+ .filter(dep => dep instanceof HarmonyImportDependency)
509
+ .map(dep => {
510
+ const ref = compilation.getDependencyReference(module, dep);
511
+ if (ref) map.set(ref, dep);
512
+ return ref;
513
+ })
514
+ .filter(ref => ref);
515
+ DependencyReference.sort(references);
516
+ // TODO webpack 5: remove this hack, see also DependencyReference
517
+ return references.map(ref => {
518
+ const dep = map.get(ref);
519
+ return () => compilation.getDependencyReference(module, dep).module;
520
+ });
521
+ };
522
+
523
+ const enterModule = getModule => {
524
+ const module = getModule();
525
+ if (!module) return;
526
+ if (set.has(module)) return;
527
+ set.add(module);
528
+ if (modulesSet.has(module)) {
529
+ const imports = getConcatenatedImports(module);
530
+ imports.forEach(enterModule);
531
+ list.push({
532
+ type: "concatenated",
533
+ module
534
+ });
535
+ } else {
536
+ list.push({
537
+ type: "external",
538
+ get module() {
539
+ // We need to use a getter here, because the module in the dependency
540
+ // could be replaced by some other process (i. e. also replaced with a
541
+ // concatenated module)
542
+ return getModule();
543
+ }
544
+ });
545
+ }
546
+ };
547
+
548
+ enterModule(() => rootModule);
549
+
550
+ return list;
551
+ }
552
+
553
+ _createIdentifier() {
554
+ let orderedConcatenationListIdentifiers = "";
555
+ for (let i = 0; i < this._orderedConcatenationList.length; i++) {
556
+ if (this._orderedConcatenationList[i].type === "concatenated") {
557
+ orderedConcatenationListIdentifiers += this._orderedConcatenationList[
558
+ i
559
+ ].module.identifier();
560
+ orderedConcatenationListIdentifiers += " ";
561
+ }
562
+ }
563
+ const hash = createHash("md4");
564
+ hash.update(orderedConcatenationListIdentifiers);
565
+ return this.rootModule.identifier() + " " + hash.digest("hex");
566
+ }
567
+
568
+ source(dependencyTemplates, runtimeTemplate) {
569
+ const requestShortener = runtimeTemplate.requestShortener;
570
+ // Metainfo for each module
571
+ const modulesWithInfo = this._orderedConcatenationList.map((info, idx) => {
572
+ switch (info.type) {
573
+ case "concatenated": {
574
+ const exportMap = new Map();
575
+ const reexportMap = new Map();
576
+ for (const dep of info.module.dependencies) {
577
+ if (dep instanceof HarmonyExportSpecifierDependency) {
578
+ if (!exportMap.has(dep.name)) {
579
+ exportMap.set(dep.name, dep.id);
580
+ }
581
+ } else if (dep instanceof HarmonyExportExpressionDependency) {
582
+ if (!exportMap.has("default")) {
583
+ exportMap.set("default", "__WEBPACK_MODULE_DEFAULT_EXPORT__");
584
+ }
585
+ } else if (
586
+ dep instanceof HarmonyExportImportedSpecifierDependency
587
+ ) {
588
+ const exportName = dep.name;
589
+ const importName = dep._id;
590
+ const importedModule = dep._module;
591
+ if (exportName && importName) {
592
+ if (!reexportMap.has(exportName)) {
593
+ reexportMap.set(exportName, {
594
+ module: importedModule,
595
+ exportName: importName,
596
+ dependency: dep
597
+ });
598
+ }
599
+ } else if (exportName) {
600
+ if (!reexportMap.has(exportName)) {
601
+ reexportMap.set(exportName, {
602
+ module: importedModule,
603
+ exportName: true,
604
+ dependency: dep
605
+ });
606
+ }
607
+ } else if (importedModule) {
608
+ for (const name of importedModule.buildMeta.providedExports) {
609
+ if (dep.activeExports.has(name) || name === "default") {
610
+ continue;
611
+ }
612
+ if (!reexportMap.has(name)) {
613
+ reexportMap.set(name, {
614
+ module: importedModule,
615
+ exportName: name,
616
+ dependency: dep
617
+ });
618
+ }
619
+ }
620
+ }
621
+ }
622
+ }
623
+ return {
624
+ type: "concatenated",
625
+ module: info.module,
626
+ index: idx,
627
+ ast: undefined,
628
+ internalSource: undefined,
629
+ source: undefined,
630
+ globalScope: undefined,
631
+ moduleScope: undefined,
632
+ internalNames: new Map(),
633
+ globalExports: new Set(),
634
+ exportMap: exportMap,
635
+ reexportMap: reexportMap,
636
+ hasNamespaceObject: false,
637
+ namespaceObjectSource: null
638
+ };
639
+ }
640
+ case "external":
641
+ return {
642
+ type: "external",
643
+ module: info.module,
644
+ index: idx,
645
+ name: undefined,
646
+ interopNamespaceObjectUsed: false,
647
+ interopNamespaceObjectName: undefined,
648
+ interopDefaultAccessUsed: false,
649
+ interopDefaultAccessName: undefined
650
+ };
651
+ default:
652
+ throw new Error(`Unsupported concatenation entry type ${info.type}`);
653
+ }
654
+ });
655
+
656
+ // Create mapping from module to info
657
+ const moduleToInfoMap = new Map();
658
+ for (const m of modulesWithInfo) {
659
+ moduleToInfoMap.set(m.module, m);
660
+ }
661
+
662
+ // Configure template decorators for dependencies
663
+ const innerDependencyTemplates = new Map(dependencyTemplates);
664
+
665
+ innerDependencyTemplates.set(
666
+ HarmonyImportSpecifierDependency,
667
+ new HarmonyImportSpecifierDependencyConcatenatedTemplate(
668
+ dependencyTemplates.get(HarmonyImportSpecifierDependency),
669
+ moduleToInfoMap
670
+ )
671
+ );
672
+ innerDependencyTemplates.set(
673
+ HarmonyImportSideEffectDependency,
674
+ new HarmonyImportSideEffectDependencyConcatenatedTemplate(
675
+ dependencyTemplates.get(HarmonyImportSideEffectDependency),
676
+ moduleToInfoMap
677
+ )
678
+ );
679
+ innerDependencyTemplates.set(
680
+ HarmonyExportSpecifierDependency,
681
+ new NullTemplate()
682
+ );
683
+ innerDependencyTemplates.set(
684
+ HarmonyExportExpressionDependency,
685
+ new HarmonyExportExpressionDependencyConcatenatedTemplate(
686
+ dependencyTemplates.get(HarmonyExportExpressionDependency),
687
+ this.rootModule
688
+ )
689
+ );
690
+ innerDependencyTemplates.set(
691
+ HarmonyExportImportedSpecifierDependency,
692
+ new NullTemplate()
693
+ );
694
+ innerDependencyTemplates.set(
695
+ HarmonyCompatibilityDependency,
696
+ new NullTemplate()
697
+ );
698
+
699
+ // Must use full identifier in our cache here to ensure that the source
700
+ // is updated should our dependencies list change.
701
+ // TODO webpack 5 refactor
702
+ innerDependencyTemplates.set(
703
+ "hash",
704
+ innerDependencyTemplates.get("hash") + this.identifier()
705
+ );
706
+
707
+ // Generate source code and analyse scopes
708
+ // Prepare a ReplaceSource for the final source
709
+ for (const info of modulesWithInfo) {
710
+ if (info.type === "concatenated") {
711
+ const m = info.module;
712
+ const source = m.source(innerDependencyTemplates, runtimeTemplate);
713
+ const code = source.source();
714
+ let ast;
715
+ try {
716
+ ast = Parser.parse(code, {
717
+ sourceType: "module"
718
+ });
719
+ } catch (err) {
720
+ if (
721
+ err.loc &&
722
+ typeof err.loc === "object" &&
723
+ typeof err.loc.line === "number"
724
+ ) {
725
+ const lineNumber = err.loc.line;
726
+ const lines = code.split("\n");
727
+ err.message +=
728
+ "\n| " +
729
+ lines
730
+ .slice(Math.max(0, lineNumber - 3), lineNumber + 2)
731
+ .join("\n| ");
732
+ }
733
+ throw err;
734
+ }
735
+ const scopeManager = eslintScope.analyze(ast, {
736
+ ecmaVersion: 6,
737
+ sourceType: "module",
738
+ optimistic: true,
739
+ ignoreEval: true,
740
+ impliedStrict: true
741
+ });
742
+ const globalScope = scopeManager.acquire(ast);
743
+ const moduleScope = globalScope.childScopes[0];
744
+ const resultSource = new ReplaceSource(source);
745
+ info.ast = ast;
746
+ info.internalSource = source;
747
+ info.source = resultSource;
748
+ info.globalScope = globalScope;
749
+ info.moduleScope = moduleScope;
750
+ }
751
+ }
752
+
753
+ // List of all used names to avoid conflicts
754
+ const allUsedNames = new Set([
755
+ "__WEBPACK_MODULE_DEFAULT_EXPORT__", // avoid using this internal name
756
+
757
+ "abstract",
758
+ "arguments",
759
+ "async",
760
+ "await",
761
+ "boolean",
762
+ "break",
763
+ "byte",
764
+ "case",
765
+ "catch",
766
+ "char",
767
+ "class",
768
+ "const",
769
+ "continue",
770
+ "debugger",
771
+ "default",
772
+ "delete",
773
+ "do",
774
+ "double",
775
+ "else",
776
+ "enum",
777
+ "eval",
778
+ "export",
779
+ "extends",
780
+ "false",
781
+ "final",
782
+ "finally",
783
+ "float",
784
+ "for",
785
+ "function",
786
+ "goto",
787
+ "if",
788
+ "implements",
789
+ "import",
790
+ "in",
791
+ "instanceof",
792
+ "int",
793
+ "interface",
794
+ "let",
795
+ "long",
796
+ "native",
797
+ "new",
798
+ "null",
799
+ "package",
800
+ "private",
801
+ "protected",
802
+ "public",
803
+ "return",
804
+ "short",
805
+ "static",
806
+ "super",
807
+ "switch",
808
+ "synchronized",
809
+ "this",
810
+ "throw",
811
+ "throws",
812
+ "transient",
813
+ "true",
814
+ "try",
815
+ "typeof",
816
+ "var",
817
+ "void",
818
+ "volatile",
819
+ "while",
820
+ "with",
821
+ "yield",
822
+
823
+ "module",
824
+ "__dirname",
825
+ "__filename",
826
+ "exports",
827
+
828
+ "Array",
829
+ "Date",
830
+ "eval",
831
+ "function",
832
+ "hasOwnProperty",
833
+ "Infinity",
834
+ "isFinite",
835
+ "isNaN",
836
+ "isPrototypeOf",
837
+ "length",
838
+ "Math",
839
+ "NaN",
840
+ "name",
841
+ "Number",
842
+ "Object",
843
+ "prototype",
844
+ "String",
845
+ "toString",
846
+ "undefined",
847
+ "valueOf",
848
+
849
+ "alert",
850
+ "all",
851
+ "anchor",
852
+ "anchors",
853
+ "area",
854
+ "assign",
855
+ "blur",
856
+ "button",
857
+ "checkbox",
858
+ "clearInterval",
859
+ "clearTimeout",
860
+ "clientInformation",
861
+ "close",
862
+ "closed",
863
+ "confirm",
864
+ "constructor",
865
+ "crypto",
866
+ "decodeURI",
867
+ "decodeURIComponent",
868
+ "defaultStatus",
869
+ "document",
870
+ "element",
871
+ "elements",
872
+ "embed",
873
+ "embeds",
874
+ "encodeURI",
875
+ "encodeURIComponent",
876
+ "escape",
877
+ "event",
878
+ "fileUpload",
879
+ "focus",
880
+ "form",
881
+ "forms",
882
+ "frame",
883
+ "innerHeight",
884
+ "innerWidth",
885
+ "layer",
886
+ "layers",
887
+ "link",
888
+ "location",
889
+ "mimeTypes",
890
+ "navigate",
891
+ "navigator",
892
+ "frames",
893
+ "frameRate",
894
+ "hidden",
895
+ "history",
896
+ "image",
897
+ "images",
898
+ "offscreenBuffering",
899
+ "open",
900
+ "opener",
901
+ "option",
902
+ "outerHeight",
903
+ "outerWidth",
904
+ "packages",
905
+ "pageXOffset",
906
+ "pageYOffset",
907
+ "parent",
908
+ "parseFloat",
909
+ "parseInt",
910
+ "password",
911
+ "pkcs11",
912
+ "plugin",
913
+ "prompt",
914
+ "propertyIsEnum",
915
+ "radio",
916
+ "reset",
917
+ "screenX",
918
+ "screenY",
919
+ "scroll",
920
+ "secure",
921
+ "select",
922
+ "self",
923
+ "setInterval",
924
+ "setTimeout",
925
+ "status",
926
+ "submit",
927
+ "taint",
928
+ "text",
929
+ "textarea",
930
+ "top",
931
+ "unescape",
932
+ "untaint",
933
+ "window",
934
+
935
+ "onblur",
936
+ "onclick",
937
+ "onerror",
938
+ "onfocus",
939
+ "onkeydown",
940
+ "onkeypress",
941
+ "onkeyup",
942
+ "onmouseover",
943
+ "onload",
944
+ "onmouseup",
945
+ "onmousedown",
946
+ "onsubmit"
947
+ ]);
948
+
949
+ // Set of already checked scopes
950
+ const alreadyCheckedScopes = new Set();
951
+
952
+ // get all global names
953
+ for (const info of modulesWithInfo) {
954
+ const superClassExpressions = [];
955
+
956
+ // ignore symbols from moduleScope
957
+ if (info.moduleScope) {
958
+ alreadyCheckedScopes.add(info.moduleScope);
959
+
960
+ // The super class expression in class scopes behaves weird
961
+ // We store ranges of all super class expressions to make
962
+ // renaming to work correctly
963
+ for (const childScope of info.moduleScope.childScopes) {
964
+ if (childScope.type !== "class") continue;
965
+ if (!childScope.block.superClass) continue;
966
+ superClassExpressions.push({
967
+ range: childScope.block.superClass.range,
968
+ variables: childScope.variables
969
+ });
970
+ }
971
+ }
972
+
973
+ // add global symbols
974
+ if (info.globalScope) {
975
+ for (const reference of info.globalScope.through) {
976
+ const name = reference.identifier.name;
977
+ if (
978
+ /^__WEBPACK_MODULE_REFERENCE__\d+_([\da-f]+|ns)(_call)?(_strict)?__$/.test(
979
+ name
980
+ )
981
+ ) {
982
+ for (const expr of superClassExpressions) {
983
+ if (
984
+ expr.range[0] <= reference.identifier.range[0] &&
985
+ expr.range[1] >= reference.identifier.range[1]
986
+ ) {
987
+ for (const variable of expr.variables) {
988
+ allUsedNames.add(variable.name);
989
+ }
990
+ }
991
+ }
992
+ addScopeSymbols1(
993
+ reference.from,
994
+ allUsedNames,
995
+ alreadyCheckedScopes
996
+ );
997
+ } else {
998
+ allUsedNames.add(name);
999
+ }
1000
+ }
1001
+ }
1002
+
1003
+ // add exported globals
1004
+ if (info.type === "concatenated") {
1005
+ const variables = new Set();
1006
+ for (const variable of info.moduleScope.variables) {
1007
+ variables.add(variable.name);
1008
+ }
1009
+ for (const [, variable] of info.exportMap) {
1010
+ if (!variables.has(variable)) {
1011
+ info.globalExports.add(variable);
1012
+ }
1013
+ }
1014
+ }
1015
+ }
1016
+
1017
+ // generate names for symbols
1018
+ for (const info of modulesWithInfo) {
1019
+ switch (info.type) {
1020
+ case "concatenated": {
1021
+ const namespaceObjectName = this.findNewName(
1022
+ "namespaceObject",
1023
+ allUsedNames,
1024
+ null,
1025
+ info.module.readableIdentifier(requestShortener)
1026
+ );
1027
+ allUsedNames.add(namespaceObjectName);
1028
+ info.internalNames.set(namespaceObjectName, namespaceObjectName);
1029
+ info.exportMap.set(true, namespaceObjectName);
1030
+ for (const variable of info.moduleScope.variables) {
1031
+ const name = variable.name;
1032
+ if (allUsedNames.has(name)) {
1033
+ const references = getAllReferences(variable);
1034
+ const symbolsInReferences = new Set();
1035
+ const alreadyCheckedInnerScopes = new Set();
1036
+ for (const ref of references) {
1037
+ addScopeSymbols2(
1038
+ ref.from,
1039
+ symbolsInReferences,
1040
+ alreadyCheckedInnerScopes,
1041
+ alreadyCheckedScopes
1042
+ );
1043
+ }
1044
+ const newName = this.findNewName(
1045
+ name,
1046
+ allUsedNames,
1047
+ symbolsInReferences,
1048
+ info.module.readableIdentifier(requestShortener)
1049
+ );
1050
+ allUsedNames.add(newName);
1051
+ info.internalNames.set(name, newName);
1052
+ const source = info.source;
1053
+ const allIdentifiers = new Set(
1054
+ references.map(r => r.identifier).concat(variable.identifiers)
1055
+ );
1056
+ for (const identifier of allIdentifiers) {
1057
+ const r = identifier.range;
1058
+ const path = getPathInAst(info.ast, identifier);
1059
+ if (
1060
+ path &&
1061
+ path.length > 1 &&
1062
+ path[1].type === "Property" &&
1063
+ path[1].shorthand
1064
+ ) {
1065
+ source.insert(r[1], `: ${newName}`);
1066
+ } else {
1067
+ source.replace(r[0], r[1] - 1, newName);
1068
+ }
1069
+ }
1070
+ } else {
1071
+ allUsedNames.add(name);
1072
+ info.internalNames.set(name, name);
1073
+ }
1074
+ }
1075
+ break;
1076
+ }
1077
+ case "external": {
1078
+ const externalName = this.findNewName(
1079
+ "",
1080
+ allUsedNames,
1081
+ null,
1082
+ info.module.readableIdentifier(requestShortener)
1083
+ );
1084
+ allUsedNames.add(externalName);
1085
+ info.name = externalName;
1086
+ if (
1087
+ info.module.buildMeta.exportsType === "named" ||
1088
+ !info.module.buildMeta.exportsType
1089
+ ) {
1090
+ const externalNameInterop = this.findNewName(
1091
+ "namespaceObject",
1092
+ allUsedNames,
1093
+ null,
1094
+ info.module.readableIdentifier(requestShortener)
1095
+ );
1096
+ allUsedNames.add(externalNameInterop);
1097
+ info.interopNamespaceObjectName = externalNameInterop;
1098
+ }
1099
+ if (!info.module.buildMeta.exportsType) {
1100
+ const externalNameInterop = this.findNewName(
1101
+ "default",
1102
+ allUsedNames,
1103
+ null,
1104
+ info.module.readableIdentifier(requestShortener)
1105
+ );
1106
+ allUsedNames.add(externalNameInterop);
1107
+ info.interopDefaultAccessName = externalNameInterop;
1108
+ }
1109
+ break;
1110
+ }
1111
+ }
1112
+ }
1113
+
1114
+ // Find and replace referenced to modules
1115
+ for (const info of modulesWithInfo) {
1116
+ if (info.type === "concatenated") {
1117
+ for (const reference of info.globalScope.through) {
1118
+ const name = reference.identifier.name;
1119
+ const match = /^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_strict)?__$/.exec(
1120
+ name
1121
+ );
1122
+ if (match) {
1123
+ const referencedModule = modulesWithInfo[+match[1]];
1124
+ let exportName;
1125
+ if (match[2] === "ns") {
1126
+ exportName = true;
1127
+ } else {
1128
+ const exportData = match[2];
1129
+ exportName = Buffer.from(exportData, "hex").toString("utf-8");
1130
+ }
1131
+ const asCall = !!match[3];
1132
+ const strictHarmonyModule = !!match[4];
1133
+ const finalName = getFinalName(
1134
+ referencedModule,
1135
+ exportName,
1136
+ moduleToInfoMap,
1137
+ requestShortener,
1138
+ asCall,
1139
+ strictHarmonyModule
1140
+ );
1141
+ const r = reference.identifier.range;
1142
+ const source = info.source;
1143
+ source.replace(r[0], r[1] - 1, finalName);
1144
+ }
1145
+ }
1146
+ }
1147
+ }
1148
+
1149
+ // Map with all root exposed used exports
1150
+ /** @type {Map<string, function(RequestShortener): string>} */
1151
+ const exportsMap = new Map();
1152
+
1153
+ // Set with all root exposed unused exports
1154
+ /** @type {Set<string>} */
1155
+ const unusedExports = new Set();
1156
+
1157
+ for (const dep of this.rootModule.dependencies) {
1158
+ if (dep instanceof HarmonyExportSpecifierDependency) {
1159
+ const used = this.rootModule.isUsed(dep.name);
1160
+ if (used) {
1161
+ const info = moduleToInfoMap.get(this.rootModule);
1162
+ if (!exportsMap.has(used)) {
1163
+ exportsMap.set(
1164
+ used,
1165
+ () => `/* binding */ ${info.internalNames.get(dep.id)}`
1166
+ );
1167
+ }
1168
+ } else {
1169
+ unusedExports.add(dep.name || "namespace");
1170
+ }
1171
+ } else if (dep instanceof HarmonyExportImportedSpecifierDependency) {
1172
+ const exportDefs = getHarmonyExportImportedSpecifierDependencyExports(
1173
+ dep
1174
+ );
1175
+ for (const def of exportDefs) {
1176
+ const info = moduleToInfoMap.get(def.module);
1177
+ const used = dep.originModule.isUsed(def.name);
1178
+ if (used) {
1179
+ if (!exportsMap.has(used)) {
1180
+ exportsMap.set(used, requestShortener => {
1181
+ const finalName = getFinalName(
1182
+ info,
1183
+ def.id,
1184
+ moduleToInfoMap,
1185
+ requestShortener,
1186
+ false,
1187
+ this.rootModule.buildMeta.strictHarmonyModule
1188
+ );
1189
+ return `/* reexport */ ${finalName}`;
1190
+ });
1191
+ }
1192
+ } else {
1193
+ unusedExports.add(def.name);
1194
+ }
1195
+ }
1196
+ }
1197
+ }
1198
+
1199
+ const result = new ConcatSource();
1200
+
1201
+ // add harmony compatibility flag (must be first because of possible circular dependencies)
1202
+ const usedExports = this.rootModule.usedExports;
1203
+ if (usedExports === true || usedExports === null) {
1204
+ result.add(`// ESM COMPAT FLAG\n`);
1205
+ result.add(
1206
+ runtimeTemplate.defineEsModuleFlagStatement({
1207
+ exportsArgument: this.exportsArgument
1208
+ })
1209
+ );
1210
+ }
1211
+
1212
+ // define exports
1213
+ if (exportsMap.size > 0) {
1214
+ result.add(`\n// EXPORTS\n`);
1215
+ for (const [key, value] of exportsMap) {
1216
+ result.add(
1217
+ `__webpack_require__.d(${this.exportsArgument}, ${JSON.stringify(
1218
+ key
1219
+ )}, function() { return ${value(requestShortener)}; });\n`
1220
+ );
1221
+ }
1222
+ }
1223
+
1224
+ // list unused exports
1225
+ if (unusedExports.size > 0) {
1226
+ result.add(
1227
+ `\n// UNUSED EXPORTS: ${joinIterableWithComma(unusedExports)}\n`
1228
+ );
1229
+ }
1230
+
1231
+ // define required namespace objects (must be before evaluation modules)
1232
+ for (const info of modulesWithInfo) {
1233
+ if (info.namespaceObjectSource) {
1234
+ result.add(
1235
+ `\n// NAMESPACE OBJECT: ${info.module.readableIdentifier(
1236
+ requestShortener
1237
+ )}\n`
1238
+ );
1239
+ result.add(info.namespaceObjectSource);
1240
+ }
1241
+ }
1242
+
1243
+ // evaluate modules in order
1244
+ for (const info of modulesWithInfo) {
1245
+ switch (info.type) {
1246
+ case "concatenated":
1247
+ result.add(
1248
+ `\n// CONCATENATED MODULE: ${info.module.readableIdentifier(
1249
+ requestShortener
1250
+ )}\n`
1251
+ );
1252
+ result.add(info.source);
1253
+ break;
1254
+ case "external":
1255
+ result.add(
1256
+ `\n// EXTERNAL MODULE: ${info.module.readableIdentifier(
1257
+ requestShortener
1258
+ )}\n`
1259
+ );
1260
+ result.add(
1261
+ `var ${info.name} = __webpack_require__(${JSON.stringify(
1262
+ info.module.id
1263
+ )});\n`
1264
+ );
1265
+ if (info.interopNamespaceObjectUsed) {
1266
+ if (info.module.buildMeta.exportsType === "named") {
1267
+ result.add(
1268
+ `var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name}, 2);\n`
1269
+ );
1270
+ } else if (!info.module.buildMeta.exportsType) {
1271
+ result.add(
1272
+ `var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name});\n`
1273
+ );
1274
+ }
1275
+ }
1276
+ if (info.interopDefaultAccessUsed) {
1277
+ result.add(
1278
+ `var ${info.interopDefaultAccessName} = /*#__PURE__*/__webpack_require__.n(${info.name});\n`
1279
+ );
1280
+ }
1281
+ break;
1282
+ default:
1283
+ throw new Error(`Unsupported concatenation entry type ${info.type}`);
1284
+ }
1285
+ }
1286
+
1287
+ return result;
1288
+ }
1289
+
1290
+ findNewName(oldName, usedNamed1, usedNamed2, extraInfo) {
1291
+ let name = oldName;
1292
+
1293
+ if (name === "__WEBPACK_MODULE_DEFAULT_EXPORT__") name = "";
1294
+
1295
+ // Remove uncool stuff
1296
+ extraInfo = extraInfo.replace(
1297
+ /\.+\/|(\/index)?\.([a-zA-Z0-9]{1,4})($|\s|\?)|\s*\+\s*\d+\s*modules/g,
1298
+ ""
1299
+ );
1300
+
1301
+ const splittedInfo = extraInfo.split("/");
1302
+ while (splittedInfo.length) {
1303
+ name = splittedInfo.pop() + (name ? "_" + name : "");
1304
+ const nameIdent = Template.toIdentifier(name);
1305
+ if (
1306
+ !usedNamed1.has(nameIdent) &&
1307
+ (!usedNamed2 || !usedNamed2.has(nameIdent))
1308
+ )
1309
+ return nameIdent;
1310
+ }
1311
+
1312
+ let i = 0;
1313
+ let nameWithNumber = Template.toIdentifier(`${name}_${i}`);
1314
+ while (
1315
+ usedNamed1.has(nameWithNumber) ||
1316
+ (usedNamed2 && usedNamed2.has(nameWithNumber))
1317
+ ) {
1318
+ i++;
1319
+ nameWithNumber = Template.toIdentifier(`${name}_${i}`);
1320
+ }
1321
+ return nameWithNumber;
1322
+ }
1323
+
1324
+ /**
1325
+ * @param {Hash} hash the hash used to track dependencies
1326
+ * @returns {void}
1327
+ */
1328
+ updateHash(hash) {
1329
+ for (const info of this._orderedConcatenationList) {
1330
+ switch (info.type) {
1331
+ case "concatenated":
1332
+ info.module.updateHash(hash);
1333
+ break;
1334
+ case "external":
1335
+ hash.update(`${info.module.id}`);
1336
+ break;
1337
+ }
1338
+ }
1339
+ super.updateHash(hash);
1340
+ }
1341
+ }
1342
+
1343
+ class HarmonyImportSpecifierDependencyConcatenatedTemplate {
1344
+ constructor(originalTemplate, modulesMap) {
1345
+ this.originalTemplate = originalTemplate;
1346
+ this.modulesMap = modulesMap;
1347
+ }
1348
+
1349
+ getHarmonyInitOrder(dep) {
1350
+ const module = dep._module;
1351
+ const info = this.modulesMap.get(module);
1352
+ if (!info) {
1353
+ return this.originalTemplate.getHarmonyInitOrder(dep);
1354
+ }
1355
+ return NaN;
1356
+ }
1357
+
1358
+ harmonyInit(dep, source, runtimeTemplate, dependencyTemplates) {
1359
+ const module = dep._module;
1360
+ const info = this.modulesMap.get(module);
1361
+ if (!info) {
1362
+ this.originalTemplate.harmonyInit(
1363
+ dep,
1364
+ source,
1365
+ runtimeTemplate,
1366
+ dependencyTemplates
1367
+ );
1368
+ return;
1369
+ }
1370
+ }
1371
+
1372
+ apply(dep, source, runtime, dependencyTemplates) {
1373
+ const module = dep._module;
1374
+ const info = this.modulesMap.get(module);
1375
+ if (!info) {
1376
+ this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
1377
+ return;
1378
+ }
1379
+ let content;
1380
+ const callFlag = dep.call ? "_call" : "";
1381
+ const strictFlag = dep.originModule.buildMeta.strictHarmonyModule
1382
+ ? "_strict"
1383
+ : "";
1384
+ if (dep._id === null) {
1385
+ content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
1386
+ } else if (dep.namespaceObjectAsContext) {
1387
+ content = `__WEBPACK_MODULE_REFERENCE__${
1388
+ info.index
1389
+ }_ns${strictFlag}__[${JSON.stringify(dep._id)}]`;
1390
+ } else {
1391
+ const exportData = Buffer.from(dep._id, "utf-8").toString("hex");
1392
+ content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${strictFlag}__`;
1393
+ }
1394
+ if (dep.shorthand) {
1395
+ content = dep.name + ": " + content;
1396
+ }
1397
+ source.replace(dep.range[0], dep.range[1] - 1, content);
1398
+ }
1399
+ }
1400
+
1401
+ class HarmonyImportSideEffectDependencyConcatenatedTemplate {
1402
+ constructor(originalTemplate, modulesMap) {
1403
+ this.originalTemplate = originalTemplate;
1404
+ this.modulesMap = modulesMap;
1405
+ }
1406
+
1407
+ getHarmonyInitOrder(dep) {
1408
+ const module = dep._module;
1409
+ const info = this.modulesMap.get(module);
1410
+ if (!info) {
1411
+ return this.originalTemplate.getHarmonyInitOrder(dep);
1412
+ }
1413
+ return NaN;
1414
+ }
1415
+
1416
+ harmonyInit(dep, source, runtime, dependencyTemplates) {
1417
+ const module = dep._module;
1418
+ const info = this.modulesMap.get(module);
1419
+ if (!info) {
1420
+ this.originalTemplate.harmonyInit(
1421
+ dep,
1422
+ source,
1423
+ runtime,
1424
+ dependencyTemplates
1425
+ );
1426
+ return;
1427
+ }
1428
+ }
1429
+
1430
+ apply(dep, source, runtime, dependencyTemplates) {
1431
+ const module = dep._module;
1432
+ const info = this.modulesMap.get(module);
1433
+ if (!info) {
1434
+ this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
1435
+ return;
1436
+ }
1437
+ }
1438
+ }
1439
+
1440
+ class HarmonyExportExpressionDependencyConcatenatedTemplate {
1441
+ constructor(originalTemplate, rootModule) {
1442
+ this.originalTemplate = originalTemplate;
1443
+ this.rootModule = rootModule;
1444
+ }
1445
+
1446
+ apply(dep, source, runtime, dependencyTemplates) {
1447
+ let content =
1448
+ "/* harmony default export */ var __WEBPACK_MODULE_DEFAULT_EXPORT__ = ";
1449
+ if (dep.originModule === this.rootModule) {
1450
+ const used = dep.originModule.isUsed("default");
1451
+ const exportsName = dep.originModule.exportsArgument;
1452
+ if (used) content += `${exportsName}[${JSON.stringify(used)}] = `;
1453
+ }
1454
+
1455
+ if (dep.range) {
1456
+ source.replace(
1457
+ dep.rangeStatement[0],
1458
+ dep.range[0] - 1,
1459
+ content + "(" + dep.prefix
1460
+ );
1461
+ source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
1462
+ return;
1463
+ }
1464
+
1465
+ source.replace(
1466
+ dep.rangeStatement[0],
1467
+ dep.rangeStatement[1] - 1,
1468
+ content + dep.prefix
1469
+ );
1470
+ }
1471
+ }
1472
+
1473
+ class NullTemplate {
1474
+ apply() {}
1475
+ }
1476
+
1477
+ module.exports = ConcatenatedModule;