| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const RuntimeGlobals = require("./RuntimeGlobals"); | 
					
						
							| 
									
										
										
										
											2022-01-13 22:26:56 +08:00
										 |  |  | const { getChunkFilenameTemplate } = require("./css/CssModulesPlugin"); | 
					
						
							| 
									
										
										
										
											2019-10-07 17:16:38 +08:00
										 |  |  | const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency"); | 
					
						
							| 
									
										
										
										
											2019-11-15 00:28:43 +08:00
										 |  |  | const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin"); | 
					
						
							| 
									
										
										
										
											2021-01-29 18:12:11 +08:00
										 |  |  | const AsyncModuleRuntimeModule = require("./runtime/AsyncModuleRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | const AutoPublicPathRuntimeModule = require("./runtime/AutoPublicPathRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-11-20 17:50:18 +08:00
										 |  |  | const CompatGetDefaultExportRuntimeModule = require("./runtime/CompatGetDefaultExportRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2020-07-02 23:02:48 +08:00
										 |  |  | const CompatRuntimeModule = require("./runtime/CompatRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-11-20 17:33:02 +08:00
										 |  |  | const CreateFakeNamespaceObjectRuntimeModule = require("./runtime/CreateFakeNamespaceObjectRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2021-09-07 18:40:07 +08:00
										 |  |  | const CreateScriptRuntimeModule = require("./runtime/CreateScriptRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2021-05-10 16:09:18 +08:00
										 |  |  | const CreateScriptUrlRuntimeModule = require("./runtime/CreateScriptUrlRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | const DefinePropertyGettersRuntimeModule = require("./runtime/DefinePropertyGettersRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-11-23 16:37:33 +08:00
										 |  |  | const EnsureChunkRuntimeModule = require("./runtime/EnsureChunkRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-11-21 18:32:10 +08:00
										 |  |  | const GetChunkFilenameRuntimeModule = require("./runtime/GetChunkFilenameRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | const GetMainFilenameRuntimeModule = require("./runtime/GetMainFilenameRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2021-09-08 19:09:01 +08:00
										 |  |  | const GetTrustedTypesPolicyRuntimeModule = require("./runtime/GetTrustedTypesPolicyRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-12-06 19:11:01 +08:00
										 |  |  | const GlobalRuntimeModule = require("./runtime/GlobalRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2019-12-03 21:27:39 +08:00
										 |  |  | const HasOwnPropertyRuntimeModule = require("./runtime/HasOwnPropertyRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2020-06-03 21:04:54 +08:00
										 |  |  | const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-11-20 17:22:10 +08:00
										 |  |  | const MakeNamespaceObjectRuntimeModule = require("./runtime/MakeNamespaceObjectRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2021-03-09 16:42:01 +08:00
										 |  |  | const OnChunksLoadedRuntimeModule = require("./runtime/OnChunksLoadedRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | const PublicPathRuntimeModule = require("./runtime/PublicPathRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2021-02-16 23:05:47 +08:00
										 |  |  | const RelativeUrlRuntimeModule = require("./runtime/RelativeUrlRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2020-10-23 20:52:23 +08:00
										 |  |  | const RuntimeIdRuntimeModule = require("./runtime/RuntimeIdRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2019-05-13 04:29:50 +08:00
										 |  |  | const SystemContextRuntimeModule = require("./runtime/SystemContextRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2020-05-23 22:08:51 +08:00
										 |  |  | const ShareRuntimeModule = require("./sharing/ShareRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2020-08-14 12:37:25 +08:00
										 |  |  | const StringXor = require("./util/StringXor"); | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** @typedef {import("./Chunk")} Chunk */ | 
					
						
							|  |  |  | /** @typedef {import("./Compiler")} Compiler */ | 
					
						
							|  |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | const GLOBALS_ON_REQUIRE = [ | 
					
						
							|  |  |  | 	RuntimeGlobals.chunkName, | 
					
						
							| 
									
										
										
										
											2020-10-23 20:52:23 +08:00
										 |  |  | 	RuntimeGlobals.runtimeId, | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 	RuntimeGlobals.compatGetDefaultExport, | 
					
						
							|  |  |  | 	RuntimeGlobals.createFakeNamespaceObject, | 
					
						
							| 
									
										
										
										
											2021-09-07 18:40:07 +08:00
										 |  |  | 	RuntimeGlobals.createScript, | 
					
						
							| 
									
										
										
										
											2021-05-10 15:09:34 +08:00
										 |  |  | 	RuntimeGlobals.createScriptUrl, | 
					
						
							| 
									
										
										
										
											2021-09-07 18:40:07 +08:00
										 |  |  | 	RuntimeGlobals.getTrustedTypesPolicy, | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 	RuntimeGlobals.definePropertyGetters, | 
					
						
							|  |  |  | 	RuntimeGlobals.ensureChunk, | 
					
						
							|  |  |  | 	RuntimeGlobals.entryModuleId, | 
					
						
							|  |  |  | 	RuntimeGlobals.getFullHash, | 
					
						
							|  |  |  | 	RuntimeGlobals.global, | 
					
						
							|  |  |  | 	RuntimeGlobals.makeNamespaceObject, | 
					
						
							|  |  |  | 	RuntimeGlobals.moduleCache, | 
					
						
							|  |  |  | 	RuntimeGlobals.moduleFactories, | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 	RuntimeGlobals.moduleFactoriesAddOnly, | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 	RuntimeGlobals.interceptModuleExecution, | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 	RuntimeGlobals.publicPath, | 
					
						
							| 
									
										
										
										
											2021-02-05 23:17:18 +08:00
										 |  |  | 	RuntimeGlobals.baseURI, | 
					
						
							| 
									
										
										
										
											2021-02-16 23:05:47 +08:00
										 |  |  | 	RuntimeGlobals.relativeUrl, | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 	RuntimeGlobals.scriptNonce, | 
					
						
							|  |  |  | 	RuntimeGlobals.uncaughtErrorHandler, | 
					
						
							| 
									
										
										
										
											2021-01-29 18:12:11 +08:00
										 |  |  | 	RuntimeGlobals.asyncModule, | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 	RuntimeGlobals.wasmInstances, | 
					
						
							| 
									
										
										
										
											2020-05-23 22:08:51 +08:00
										 |  |  | 	RuntimeGlobals.instantiateWasm, | 
					
						
							|  |  |  | 	RuntimeGlobals.shareScopeMap, | 
					
						
							| 
									
										
										
										
											2020-06-03 21:04:54 +08:00
										 |  |  | 	RuntimeGlobals.initializeSharing, | 
					
						
							| 
									
										
										
										
											2021-02-11 02:14:50 +08:00
										 |  |  | 	RuntimeGlobals.loadScript, | 
					
						
							| 
									
										
										
										
											2021-03-09 03:18:49 +08:00
										 |  |  | 	RuntimeGlobals.systemContext, | 
					
						
							|  |  |  | 	RuntimeGlobals.onChunksLoaded | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-04 21:12:16 +08:00
										 |  |  | const MODULE_DEPENDENCIES = { | 
					
						
							|  |  |  | 	[RuntimeGlobals.moduleLoaded]: [RuntimeGlobals.module], | 
					
						
							|  |  |  | 	[RuntimeGlobals.moduleId]: [RuntimeGlobals.module] | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | const TREE_DEPENDENCIES = { | 
					
						
							| 
									
										
										
										
											2019-12-03 21:27:39 +08:00
										 |  |  | 	[RuntimeGlobals.definePropertyGetters]: [RuntimeGlobals.hasOwnProperty], | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 	[RuntimeGlobals.compatGetDefaultExport]: [ | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 		RuntimeGlobals.definePropertyGetters | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 	], | 
					
						
							|  |  |  | 	[RuntimeGlobals.createFakeNamespaceObject]: [ | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 		RuntimeGlobals.definePropertyGetters, | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 		RuntimeGlobals.makeNamespaceObject, | 
					
						
							|  |  |  | 		RuntimeGlobals.require | 
					
						
							| 
									
										
										
										
											2020-05-23 22:08:51 +08:00
										 |  |  | 	], | 
					
						
							|  |  |  | 	[RuntimeGlobals.initializeSharing]: [RuntimeGlobals.shareScopeMap], | 
					
						
							|  |  |  | 	[RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty] | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class RuntimePlugin { | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the Compiler | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(compiler) { | 
					
						
							|  |  |  | 		compiler.hooks.compilation.tap("RuntimePlugin", compilation => { | 
					
						
							| 
									
										
										
										
											2019-10-07 17:16:38 +08:00
										 |  |  | 			compilation.dependencyTemplates.set( | 
					
						
							|  |  |  | 				RuntimeRequirementsDependency, | 
					
						
							|  |  |  | 				new RuntimeRequirementsDependency.Template() | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 			for (const req of GLOBALS_ON_REQUIRE) { | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 				compilation.hooks.runtimeRequirementInModule | 
					
						
							|  |  |  | 					.for(req) | 
					
						
							|  |  |  | 					.tap("RuntimePlugin", (module, set) => { | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 						set.add(RuntimeGlobals.requireScope); | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 				compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 					.for(req) | 
					
						
							|  |  |  | 					.tap("RuntimePlugin", (module, set) => { | 
					
						
							|  |  |  | 						set.add(RuntimeGlobals.requireScope); | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 					}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			for (const req of Object.keys(TREE_DEPENDENCIES)) { | 
					
						
							|  |  |  | 				const deps = TREE_DEPENDENCIES[req]; | 
					
						
							|  |  |  | 				compilation.hooks.runtimeRequirementInTree | 
					
						
							| 
									
										
										
										
											2019-12-04 21:12:16 +08:00
										 |  |  | 					.for(req) | 
					
						
							|  |  |  | 					.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 						for (const dep of deps) set.add(dep); | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			for (const req of Object.keys(MODULE_DEPENDENCIES)) { | 
					
						
							|  |  |  | 				const deps = MODULE_DEPENDENCIES[req]; | 
					
						
							|  |  |  | 				compilation.hooks.runtimeRequirementInModule | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 					.for(req) | 
					
						
							|  |  |  | 					.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 						for (const dep of deps) set.add(dep); | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 					}); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-11-18 19:59:33 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 				.for(RuntimeGlobals.definePropertyGetters) | 
					
						
							| 
									
										
										
										
											2018-11-18 19:59:33 +08:00
										 |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 						new DefinePropertyGettersRuntimeModule() | 
					
						
							| 
									
										
										
										
											2018-11-18 19:59:33 +08:00
										 |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-20 17:22:10 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.makeNamespaceObject) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new MakeNamespaceObjectRuntimeModule() | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-20 17:33:02 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.createFakeNamespaceObject) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new CreateFakeNamespaceObjectRuntimeModule() | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2019-12-03 21:27:39 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.hasOwnProperty) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new HasOwnPropertyRuntimeModule() | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-20 17:50:18 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.compatGetDefaultExport) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new CompatGetDefaultExportRuntimeModule() | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							| 
									
										
										
										
											2020-10-23 20:52:23 +08:00
										 |  |  | 				.for(RuntimeGlobals.runtimeId) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule(chunk, new RuntimeIdRuntimeModule()); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 				.for(RuntimeGlobals.publicPath) | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							| 
									
										
										
										
											2020-09-17 04:07:06 +08:00
										 |  |  | 					const { outputOptions } = compilation; | 
					
						
							| 
									
										
										
										
											2021-04-14 22:38:01 +08:00
										 |  |  | 					const { publicPath: globalPublicPath, scriptType } = outputOptions; | 
					
						
							|  |  |  | 					const entryOptions = chunk.getEntryOptions(); | 
					
						
							|  |  |  | 					const publicPath = | 
					
						
							| 
									
										
										
										
											2021-04-15 02:21:17 +08:00
										 |  |  | 						entryOptions && entryOptions.publicPath !== undefined | 
					
						
							|  |  |  | 							? entryOptions.publicPath | 
					
						
							|  |  |  | 							: globalPublicPath; | 
					
						
							| 
									
										
										
										
											2020-09-15 05:27:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | 					if (publicPath === "auto") { | 
					
						
							|  |  |  | 						const module = new AutoPublicPathRuntimeModule(); | 
					
						
							|  |  |  | 						if (scriptType !== "module") set.add(RuntimeGlobals.global); | 
					
						
							|  |  |  | 						compilation.addRuntimeModule(chunk, module); | 
					
						
							|  |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2021-04-14 22:38:01 +08:00
										 |  |  | 						const module = new PublicPathRuntimeModule(publicPath); | 
					
						
							| 
									
										
										
										
											2020-09-15 05:27:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | 						if ( | 
					
						
							|  |  |  | 							typeof publicPath !== "string" || | 
					
						
							|  |  |  | 							/\[(full)?hash\]/.test(publicPath) | 
					
						
							|  |  |  | 						) { | 
					
						
							|  |  |  | 							module.fullHash = true; | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2020-09-15 05:27:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-18 16:12:13 +08:00
										 |  |  | 						compilation.addRuntimeModule(chunk, module); | 
					
						
							| 
									
										
										
										
											2020-09-15 05:27:38 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-12-06 19:11:01 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.global) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule(chunk, new GlobalRuntimeModule()); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-01-29 18:12:11 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.asyncModule) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule(chunk, new AsyncModuleRuntimeModule()); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2019-05-13 04:29:50 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.systemContext) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", chunk => { | 
					
						
							| 
									
										
										
										
											2021-06-28 22:46:22 +08:00
										 |  |  | 					const { outputOptions } = compilation; | 
					
						
							|  |  |  | 					const { library: globalLibrary } = outputOptions; | 
					
						
							|  |  |  | 					const entryOptions = chunk.getEntryOptions(); | 
					
						
							|  |  |  | 					const libraryType = | 
					
						
							|  |  |  | 						entryOptions && entryOptions.library !== undefined | 
					
						
							|  |  |  | 							? entryOptions.library.type | 
					
						
							|  |  |  | 							: globalLibrary.type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					if (libraryType === "system") { | 
					
						
							| 
									
										
										
										
											2019-05-13 04:29:50 +08:00
										 |  |  | 						compilation.addRuntimeModule( | 
					
						
							|  |  |  | 							chunk, | 
					
						
							|  |  |  | 							new SystemContextRuntimeModule() | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-21 18:32:10 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.getChunkScriptFilename) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							| 
									
										
										
										
											2018-12-26 03:14:58 +08:00
										 |  |  | 					if ( | 
					
						
							| 
									
										
										
										
											2020-09-25 17:04:14 +08:00
										 |  |  | 						typeof compilation.outputOptions.chunkFilename === "string" && | 
					
						
							| 
									
										
										
										
											2018-12-26 03:14:58 +08:00
										 |  |  | 						/\[(full)?hash(:\d+)?\]/.test( | 
					
						
							|  |  |  | 							compilation.outputOptions.chunkFilename | 
					
						
							|  |  |  | 						) | 
					
						
							| 
									
										
										
										
											2020-09-25 17:04:14 +08:00
										 |  |  | 					) { | 
					
						
							| 
									
										
										
										
											2018-11-21 18:32:10 +08:00
										 |  |  | 						set.add(RuntimeGlobals.getFullHash); | 
					
						
							| 
									
										
										
										
											2020-09-25 17:04:14 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-11-21 18:32:10 +08:00
										 |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new GetChunkFilenameRuntimeModule( | 
					
						
							|  |  |  | 							"javascript", | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 							"javascript", | 
					
						
							| 
									
										
										
										
											2018-11-21 18:32:10 +08:00
										 |  |  | 							RuntimeGlobals.getChunkScriptFilename, | 
					
						
							| 
									
										
										
										
											2018-12-29 19:48:59 +08:00
										 |  |  | 							chunk => | 
					
						
							| 
									
										
										
										
											2019-02-18 17:03:07 +08:00
										 |  |  | 								chunk.filenameTemplate || | 
					
						
							| 
									
										
										
										
											2020-09-08 00:02:14 +08:00
										 |  |  | 								(chunk.canBeInitial() | 
					
						
							| 
									
										
										
										
											2019-02-18 17:03:07 +08:00
										 |  |  | 									? compilation.outputOptions.filename | 
					
						
							|  |  |  | 									: compilation.outputOptions.chunkFilename), | 
					
						
							|  |  |  | 							false | 
					
						
							| 
									
										
										
										
											2018-11-21 18:32:10 +08:00
										 |  |  | 						) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-11-30 19:55:51 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.getChunkCssFilename) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					if ( | 
					
						
							| 
									
										
										
										
											2021-12-17 19:18:01 +08:00
										 |  |  | 						typeof compilation.outputOptions.cssChunkFilename === "string" && | 
					
						
							|  |  |  | 						/\[(full)?hash(:\d+)?\]/.test( | 
					
						
							|  |  |  | 							compilation.outputOptions.cssChunkFilename | 
					
						
							|  |  |  | 						) | 
					
						
							| 
									
										
										
										
											2021-11-30 19:55:51 +08:00
										 |  |  | 					) { | 
					
						
							|  |  |  | 						set.add(RuntimeGlobals.getFullHash); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new GetChunkFilenameRuntimeModule( | 
					
						
							|  |  |  | 							"css", | 
					
						
							|  |  |  | 							"css", | 
					
						
							|  |  |  | 							RuntimeGlobals.getChunkCssFilename, | 
					
						
							|  |  |  | 							chunk => | 
					
						
							| 
									
										
										
										
											2022-01-13 22:26:56 +08:00
										 |  |  | 								getChunkFilenameTemplate(chunk, compilation.outputOptions), | 
					
						
							|  |  |  | 							set.has(RuntimeGlobals.hmrDownloadUpdateHandlers) | 
					
						
							| 
									
										
										
										
											2021-11-30 19:55:51 +08:00
										 |  |  | 						) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.getChunkUpdateScriptFilename) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					if ( | 
					
						
							| 
									
										
										
										
											2018-12-26 03:14:58 +08:00
										 |  |  | 						/\[(full)?hash(:\d+)?\]/.test( | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 							compilation.outputOptions.hotUpdateChunkFilename | 
					
						
							|  |  |  | 						) | 
					
						
							|  |  |  | 					) | 
					
						
							|  |  |  | 						set.add(RuntimeGlobals.getFullHash); | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new GetChunkFilenameRuntimeModule( | 
					
						
							|  |  |  | 							"javascript", | 
					
						
							|  |  |  | 							"javascript update", | 
					
						
							|  |  |  | 							RuntimeGlobals.getChunkUpdateScriptFilename, | 
					
						
							| 
									
										
										
										
											2019-02-18 17:03:07 +08:00
										 |  |  | 							c => compilation.outputOptions.hotUpdateChunkFilename, | 
					
						
							|  |  |  | 							true | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 						) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.getUpdateManifestFilename) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					if ( | 
					
						
							| 
									
										
										
										
											2018-12-26 03:14:58 +08:00
										 |  |  | 						/\[(full)?hash(:\d+)?\]/.test( | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 							compilation.outputOptions.hotUpdateMainFilename | 
					
						
							|  |  |  | 						) | 
					
						
							| 
									
										
										
										
											2018-12-18 05:05:08 +08:00
										 |  |  | 					) { | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 						set.add(RuntimeGlobals.getFullHash); | 
					
						
							| 
									
										
										
										
											2018-12-18 05:05:08 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new GetMainFilenameRuntimeModule( | 
					
						
							|  |  |  | 							"update manifest", | 
					
						
							|  |  |  | 							RuntimeGlobals.getUpdateManifestFilename, | 
					
						
							|  |  |  | 							compilation.outputOptions.hotUpdateMainFilename | 
					
						
							|  |  |  | 						) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-23 16:37:33 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.ensureChunk) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					const hasAsyncChunks = chunk.hasAsyncChunks(); | 
					
						
							|  |  |  | 					if (hasAsyncChunks) { | 
					
						
							|  |  |  | 						set.add(RuntimeGlobals.ensureChunkHandlers); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							| 
									
										
										
										
											2018-12-29 19:48:59 +08:00
										 |  |  | 						new EnsureChunkRuntimeModule(set) | 
					
						
							| 
									
										
										
										
											2018-11-23 16:37:33 +08:00
										 |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-12-29 19:48:59 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.ensureChunkIncludeEntries) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					set.add(RuntimeGlobals.ensureChunkHandlers); | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2020-05-23 22:08:51 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.shareScopeMap) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule(chunk, new ShareRuntimeModule()); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2020-06-03 21:04:54 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.loadScript) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							| 
									
										
										
										
											2021-05-10 16:34:21 +08:00
										 |  |  | 					const withCreateScriptUrl = !!compilation.outputOptions.trustedTypes; | 
					
						
							| 
									
										
										
										
											2021-05-10 15:33:04 +08:00
										 |  |  | 					if (withCreateScriptUrl) { | 
					
						
							|  |  |  | 						set.add(RuntimeGlobals.createScriptUrl); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new LoadScriptRuntimeModule(withCreateScriptUrl) | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2020-06-03 21:04:54 +08:00
										 |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-09-07 18:40:07 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.createScript) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					if (compilation.outputOptions.trustedTypes) { | 
					
						
							|  |  |  | 						set.add(RuntimeGlobals.getTrustedTypesPolicy); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					compilation.addRuntimeModule(chunk, new CreateScriptRuntimeModule()); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-04-21 09:12:49 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							| 
									
										
										
										
											2021-05-10 15:09:34 +08:00
										 |  |  | 				.for(RuntimeGlobals.createScriptUrl) | 
					
						
							| 
									
										
										
										
											2021-04-21 09:12:49 +08:00
										 |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							| 
									
										
										
										
											2021-09-07 18:40:07 +08:00
										 |  |  | 					if (compilation.outputOptions.trustedTypes) { | 
					
						
							|  |  |  | 						set.add(RuntimeGlobals.getTrustedTypesPolicy); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2021-05-10 16:09:18 +08:00
										 |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new CreateScriptUrlRuntimeModule() | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2021-04-21 09:12:49 +08:00
										 |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-09-07 18:40:07 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.getTrustedTypesPolicy) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new GetTrustedTypesPolicyRuntimeModule(set) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-02-16 23:05:47 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.relativeUrl) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							|  |  |  | 					compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule()); | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2021-03-09 03:18:49 +08:00
										 |  |  | 			compilation.hooks.runtimeRequirementInTree | 
					
						
							|  |  |  | 				.for(RuntimeGlobals.onChunksLoaded) | 
					
						
							|  |  |  | 				.tap("RuntimePlugin", (chunk, set) => { | 
					
						
							| 
									
										
										
										
											2021-03-09 16:42:01 +08:00
										 |  |  | 					compilation.addRuntimeModule( | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						new OnChunksLoadedRuntimeModule() | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2021-03-09 03:18:49 +08:00
										 |  |  | 					return true; | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2020-07-02 23:02:48 +08:00
										 |  |  | 			// TODO webpack 6: remove CompatRuntimeModule
 | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 			compilation.hooks.additionalTreeRuntimeRequirements.tap( | 
					
						
							|  |  |  | 				"RuntimePlugin", | 
					
						
							|  |  |  | 				(chunk, set) => { | 
					
						
							|  |  |  | 					const { mainTemplate } = compilation; | 
					
						
							|  |  |  | 					if ( | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 						mainTemplate.hooks.bootstrap.isUsed() || | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 						mainTemplate.hooks.localVars.isUsed() || | 
					
						
							|  |  |  | 						mainTemplate.hooks.requireEnsure.isUsed() || | 
					
						
							|  |  |  | 						mainTemplate.hooks.requireExtensions.isUsed() | 
					
						
							|  |  |  | 					) { | 
					
						
							| 
									
										
										
										
											2020-07-02 23:02:48 +08:00
										 |  |  | 						compilation.addRuntimeModule(chunk, new CompatRuntimeModule()); | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2019-11-15 00:28:43 +08:00
										 |  |  | 			JavascriptModulesPlugin.getCompilationHooks(compilation).chunkHash.tap( | 
					
						
							|  |  |  | 				"RuntimePlugin", | 
					
						
							|  |  |  | 				(chunk, hash, { chunkGraph }) => { | 
					
						
							| 
									
										
										
										
											2020-08-14 12:37:25 +08:00
										 |  |  | 					const xor = new StringXor(); | 
					
						
							|  |  |  | 					for (const m of chunkGraph.getChunkRuntimeModulesIterable(chunk)) { | 
					
						
							|  |  |  | 						xor.add(chunkGraph.getModuleHash(m, chunk.runtime)); | 
					
						
							| 
									
										
										
										
											2019-11-15 00:28:43 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2020-08-14 12:37:25 +08:00
										 |  |  | 					xor.updateHash(hash); | 
					
						
							| 
									
										
										
										
											2019-11-15 00:28:43 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = RuntimePlugin; |