| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | const util = require("util"); | 
					
						
							| 
									
										
										
										
											2025-07-03 17:06:45 +08:00
										 |  |  | const { SyncWaterfallHook } = require("tapable"); | 
					
						
							| 
									
										
										
										
											2018-11-05 21:36:15 +08:00
										 |  |  | const RuntimeGlobals = require("./RuntimeGlobals"); | 
					
						
							| 
									
										
										
										
											2020-12-27 05:32:57 +08:00
										 |  |  | const memoize = require("./util/memoize"); | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | /** @typedef {import("tapable").Tap} Tap */ | 
					
						
							| 
									
										
										
										
											2018-07-02 22:18:49 +08:00
										 |  |  | /** @typedef {import("webpack-sources").Source} Source */ | 
					
						
							| 
									
										
										
										
											2020-08-03 02:09:36 +08:00
										 |  |  | /** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */ | 
					
						
							| 
									
										
										
										
											2018-04-24 21:44:50 +08:00
										 |  |  | /** @typedef {import("./ModuleTemplate")} ModuleTemplate */ | 
					
						
							|  |  |  | /** @typedef {import("./Chunk")} Chunk */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | /** @typedef {import("./Compilation")} Compilation */ | 
					
						
							| 
									
										
										
										
											2019-09-13 17:12:26 +08:00
										 |  |  | /** @typedef {import("./Compilation").AssetInfo} AssetInfo */ | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | /** @typedef {import("./Compilation").InterpolatedPathAndAssetInfo} InterpolatedPathAndAssetInfo */ | 
					
						
							| 
									
										
										
										
											2025-09-10 19:38:19 +08:00
										 |  |  | /** @typedef {import("./util/Hash")} Hash */ | 
					
						
							|  |  |  | /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | 
					
						
							|  |  |  | /** @typedef {import("./javascript/JavascriptModulesPlugin").RenderBootstrapContext} RenderBootstrapContext */ | 
					
						
							|  |  |  | /** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions */ | 
					
						
							|  |  |  | /** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry */ | 
					
						
							|  |  |  | /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */ | 
					
						
							|  |  |  | /** @typedef {import("./TemplatedPathPlugin").PathData} PathData */ | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @template T | 
					
						
							|  |  |  |  * @typedef {import("tapable").IfSet<T>} IfSet | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-05-01 23:47:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-27 05:32:57 +08:00
										 |  |  | const getJavascriptModulesPlugin = memoize(() => | 
					
						
							| 
									
										
										
										
											2019-10-11 21:46:57 +08:00
										 |  |  | 	require("./javascript/JavascriptModulesPlugin") | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | ); | 
					
						
							| 
									
										
										
										
											2020-12-27 05:32:57 +08:00
										 |  |  | const getJsonpTemplatePlugin = memoize(() => | 
					
						
							| 
									
										
										
										
											2020-07-02 23:02:48 +08:00
										 |  |  | 	require("./web/JsonpTemplatePlugin") | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2020-12-27 05:32:57 +08:00
										 |  |  | const getLoadScriptRuntimeModule = memoize(() => | 
					
						
							| 
									
										
										
										
											2020-08-19 21:05:49 +08:00
										 |  |  | 	require("./runtime/LoadScriptRuntimeModule") | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2018-04-21 08:35:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | // TODO webpack 6 remove this class
 | 
					
						
							|  |  |  | class MainTemplate { | 
					
						
							| 
									
										
										
										
											2018-04-21 08:35:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2020-08-03 02:09:36 +08:00
										 |  |  | 	 * @param {OutputOptions} outputOptions output options for the MainTemplate | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 	 * @param {Compilation} compilation the compilation | 
					
						
							| 
									
										
										
										
											2018-04-21 08:35:02 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 	constructor(outputOptions, compilation) { | 
					
						
							| 
									
										
										
										
											2020-08-03 02:09:36 +08:00
										 |  |  | 		/** @type {OutputOptions} */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 		this._outputOptions = outputOptions || {}; | 
					
						
							| 
									
										
										
										
											2018-07-30 20:25:40 +08:00
										 |  |  | 		this.hooks = Object.freeze({ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 			renderManifest: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @template AdditionalOptions | 
					
						
							|  |  |  | 					 * @param {string | Tap & IfSet<AdditionalOptions>} options options | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					 * @param {(renderManifestEntries: RenderManifestEntry[], renderManifestOptions: RenderManifestOptions) => RenderManifestEntry[]} fn fn | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 					(options, fn) => { | 
					
						
							|  |  |  | 						compilation.hooks.renderManifest.tap( | 
					
						
							|  |  |  | 							options, | 
					
						
							|  |  |  | 							(entries, options) => { | 
					
						
							|  |  |  | 								if (!options.chunk.hasRuntime()) return entries; | 
					
						
							|  |  |  | 								return fn(entries, options); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_RENDER_MANIFEST" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2019-10-09 19:26:00 +08:00
										 |  |  | 			modules: { | 
					
						
							|  |  |  | 				tap: () => { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						"MainTemplate.hooks.modules has been removed (there is no replacement, please create an issue to request that)" | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			moduleObj: { | 
					
						
							|  |  |  | 				tap: () => { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						"MainTemplate.hooks.moduleObj has been removed (there is no replacement, please create an issue to request that)" | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 			require: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @template AdditionalOptions | 
					
						
							|  |  |  | 					 * @param {string | Tap & IfSet<AdditionalOptions>} options options | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					 * @param {(value: string, renderBootstrapContext: RenderBootstrapContext) => string} fn fn | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 					(options, fn) => { | 
					
						
							|  |  |  | 						getJavascriptModulesPlugin() | 
					
						
							|  |  |  | 							.getCompilationHooks(compilation) | 
					
						
							|  |  |  | 							.renderRequire.tap(options, fn); | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.require is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderRequire instead)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2019-10-09 19:26:00 +08:00
										 |  |  | 			beforeStartup: { | 
					
						
							|  |  |  | 				tap: () => { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							| 
									
										
										
										
											2020-12-11 21:32:42 +08:00
										 |  |  | 						"MainTemplate.hooks.beforeStartup has been removed (use RuntimeGlobals.startupOnlyBefore instead)" | 
					
						
							| 
									
										
										
										
											2019-10-09 19:26:00 +08:00
										 |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			startup: { | 
					
						
							|  |  |  | 				tap: () => { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						"MainTemplate.hooks.startup has been removed (use RuntimeGlobals.startup instead)" | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			afterStartup: { | 
					
						
							|  |  |  | 				tap: () => { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							| 
									
										
										
										
											2020-12-11 21:32:42 +08:00
										 |  |  | 						"MainTemplate.hooks.afterStartup has been removed (use RuntimeGlobals.startupOnlyAfter instead)" | 
					
						
							| 
									
										
										
										
											2019-10-09 19:26:00 +08:00
										 |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			render: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @template AdditionalOptions | 
					
						
							|  |  |  | 					 * @param {string | Tap & IfSet<AdditionalOptions>} options options | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					 * @param {(source: Source, chunk: Chunk, hash: string | undefined, moduleTemplate: ModuleTemplate, dependencyTemplates: DependencyTemplates) => Source} fn fn | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2019-10-09 19:26:00 +08:00
										 |  |  | 					(options, fn) => { | 
					
						
							|  |  |  | 						getJavascriptModulesPlugin() | 
					
						
							|  |  |  | 							.getCompilationHooks(compilation) | 
					
						
							|  |  |  | 							.render.tap(options, (source, renderContext) => { | 
					
						
							|  |  |  | 								if ( | 
					
						
							|  |  |  | 									renderContext.chunkGraph.getNumberOfEntryModules( | 
					
						
							|  |  |  | 										renderContext.chunk | 
					
						
							|  |  |  | 									) === 0 || | 
					
						
							|  |  |  | 									!renderContext.chunk.hasRuntime() | 
					
						
							|  |  |  | 								) { | 
					
						
							|  |  |  | 									return source; | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								return fn( | 
					
						
							|  |  |  | 									source, | 
					
						
							|  |  |  | 									renderContext.chunk, | 
					
						
							|  |  |  | 									compilation.hash, | 
					
						
							|  |  |  | 									compilation.moduleTemplates.javascript, | 
					
						
							|  |  |  | 									compilation.dependencyTemplates | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 							}); | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.render is deprecated (use JavascriptModulesPlugin.getCompilationHooks().render instead)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_RENDER" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 			renderWithEntry: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @template AdditionalOptions | 
					
						
							|  |  |  | 					 * @param {string | Tap & IfSet<AdditionalOptions>} options options | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					 * @param {(source: Source, chunk: Chunk, hash: string | undefined) => Source} fn fn | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 					(options, fn) => { | 
					
						
							|  |  |  | 						getJavascriptModulesPlugin() | 
					
						
							|  |  |  | 							.getCompilationHooks(compilation) | 
					
						
							| 
									
										
										
										
											2019-10-09 17:55:56 +08:00
										 |  |  | 							.render.tap(options, (source, renderContext) => { | 
					
						
							|  |  |  | 								if ( | 
					
						
							|  |  |  | 									renderContext.chunkGraph.getNumberOfEntryModules( | 
					
						
							|  |  |  | 										renderContext.chunk | 
					
						
							|  |  |  | 									) === 0 || | 
					
						
							|  |  |  | 									!renderContext.chunk.hasRuntime() | 
					
						
							|  |  |  | 								) { | 
					
						
							|  |  |  | 									return source; | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 								return fn(source, renderContext.chunk, compilation.hash); | 
					
						
							|  |  |  | 							}); | 
					
						
							|  |  |  | 					}, | 
					
						
							| 
									
										
										
										
											2019-10-09 17:55:56 +08:00
										 |  |  | 					"MainTemplate.hooks.renderWithEntry is deprecated (use JavascriptModulesPlugin.getCompilationHooks().render instead)", | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_RENDER_WITH_ENTRY" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			assetPath: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @template AdditionalOptions | 
					
						
							|  |  |  | 					 * @param {string | Tap & IfSet<AdditionalOptions>} options options | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					 * @param {(value: string, path: PathData, assetInfo: AssetInfo | undefined) => string} fn fn | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 					(options, fn) => { | 
					
						
							|  |  |  | 						compilation.hooks.assetPath.tap(options, fn); | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.assetPath is deprecated (use Compilation.hooks.assetPath instead)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_ASSET_PATH" | 
					
						
							| 
									
										
										
										
											2019-10-10 19:48:56 +08:00
										 |  |  | 				), | 
					
						
							|  |  |  | 				call: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @param {TemplatePath} filename used to get asset path with hash | 
					
						
							|  |  |  | 					 * @param {PathData} options context data | 
					
						
							|  |  |  | 					 * @returns {string} interpolated path | 
					
						
							|  |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2024-07-31 11:31:11 +08:00
										 |  |  | 					(filename, options) => compilation.getAssetPath(filename, options), | 
					
						
							| 
									
										
										
										
											2019-10-10 19:48:56 +08:00
										 |  |  | 					"MainTemplate.hooks.assetPath is deprecated (use Compilation.hooks.assetPath instead)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_ASSET_PATH" | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			hash: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @template AdditionalOptions | 
					
						
							|  |  |  | 					 * @param {string | Tap & IfSet<AdditionalOptions>} options options | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					 * @param {(hash: Hash) => void} fn fn | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 					(options, fn) => { | 
					
						
							|  |  |  | 						compilation.hooks.fullHash.tap(options, fn); | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.hash is deprecated (use Compilation.hooks.fullHash instead)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_HASH" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			hashForChunk: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @template AdditionalOptions | 
					
						
							|  |  |  | 					 * @param {string | Tap & IfSet<AdditionalOptions>} options options | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					 * @param {(hash: Hash, chunk: Chunk) => void} fn fn | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 					 */ | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 					(options, fn) => { | 
					
						
							|  |  |  | 						getJavascriptModulesPlugin() | 
					
						
							|  |  |  | 							.getCompilationHooks(compilation) | 
					
						
							|  |  |  | 							.chunkHash.tap(options, (chunk, hash) => { | 
					
						
							|  |  |  | 								if (!chunk.hasRuntime()) return; | 
					
						
							|  |  |  | 								return fn(hash, chunk); | 
					
						
							|  |  |  | 							}); | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2019-10-09 19:26:00 +08:00
										 |  |  | 			globalHashPaths: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							|  |  |  | 					() => {}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.globalHashPaths has been removed (it's no longer needed)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			globalHash: { | 
					
						
							|  |  |  | 				tap: util.deprecate( | 
					
						
							|  |  |  | 					() => {}, | 
					
						
							|  |  |  | 					"MainTemplate.hooks.globalHash has been removed (it's no longer needed)", | 
					
						
							|  |  |  | 					"DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK" | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			hotBootstrap: { | 
					
						
							|  |  |  | 				tap: () => { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						"MainTemplate.hooks.hotBootstrap has been removed (use your own RuntimeModule instead)" | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// for compatibility:
 | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 			/** @type {SyncWaterfallHook<[string, Chunk, string, ModuleTemplate, DependencyTemplates]>} */ | 
					
						
							|  |  |  | 			bootstrap: new SyncWaterfallHook([ | 
					
						
							|  |  |  | 				"source", | 
					
						
							|  |  |  | 				"chunk", | 
					
						
							|  |  |  | 				"hash", | 
					
						
							|  |  |  | 				"moduleTemplate", | 
					
						
							|  |  |  | 				"dependencyTemplates" | 
					
						
							|  |  |  | 			]), | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 			/** @type {SyncWaterfallHook<[string, Chunk, string]>} */ | 
					
						
							|  |  |  | 			localVars: new SyncWaterfallHook(["source", "chunk", "hash"]), | 
					
						
							|  |  |  | 			/** @type {SyncWaterfallHook<[string, Chunk, string]>} */ | 
					
						
							|  |  |  | 			requireExtensions: new SyncWaterfallHook(["source", "chunk", "hash"]), | 
					
						
							|  |  |  | 			/** @type {SyncWaterfallHook<[string, Chunk, string, string]>} */ | 
					
						
							|  |  |  | 			requireEnsure: new SyncWaterfallHook([ | 
					
						
							|  |  |  | 				"source", | 
					
						
							|  |  |  | 				"chunk", | 
					
						
							|  |  |  | 				"hash", | 
					
						
							|  |  |  | 				"chunkIdExpression" | 
					
						
							| 
									
										
										
										
											2020-07-02 23:02:48 +08:00
										 |  |  | 			]), | 
					
						
							|  |  |  | 			get jsonpScript() { | 
					
						
							| 
									
										
										
										
											2021-05-11 15:31:46 +08:00
										 |  |  | 				const hooks = | 
					
						
							|  |  |  | 					getLoadScriptRuntimeModule().getCompilationHooks(compilation); | 
					
						
							| 
									
										
										
										
											2020-08-19 21:05:49 +08:00
										 |  |  | 				return hooks.createScript; | 
					
						
							| 
									
										
										
										
											2020-07-02 23:02:48 +08:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 			get linkPrefetch() { | 
					
						
							|  |  |  | 				const hooks = getJsonpTemplatePlugin().getCompilationHooks(compilation); | 
					
						
							|  |  |  | 				return hooks.linkPrefetch; | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			get linkPreload() { | 
					
						
							|  |  |  | 				const hooks = getJsonpTemplatePlugin().getCompilationHooks(compilation); | 
					
						
							|  |  |  | 				return hooks.linkPreload; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-07-30 20:25:40 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 		this.renderCurrentHashCode = util.deprecate( | 
					
						
							|  |  |  | 			/** | 
					
						
							|  |  |  | 			 * @deprecated | 
					
						
							|  |  |  | 			 * @param {string} hash the hash | 
					
						
							|  |  |  | 			 * @param {number=} length length of the hash | 
					
						
							|  |  |  | 			 * @returns {string} generated code | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 			 */ | 
					
						
							|  |  |  | 			(hash, length) => { | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 				if (length) { | 
					
						
							|  |  |  | 					return `${RuntimeGlobals.getFullHash} ? ${ | 
					
						
							|  |  |  | 						RuntimeGlobals.getFullHash | 
					
						
							|  |  |  | 					}().slice(0, ${length}) : ${hash.slice(0, length)}`;
 | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 				return `${RuntimeGlobals.getFullHash} ? ${RuntimeGlobals.getFullHash}() : ${hash}`; | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			"MainTemplate.renderCurrentHashCode is deprecated (use RuntimeGlobals.getFullHash runtime function instead)", | 
					
						
							|  |  |  | 			"DEP_WEBPACK_MAIN_TEMPLATE_RENDER_CURRENT_HASH_CODE" | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 		this.getPublicPath = util.deprecate( | 
					
						
							|  |  |  | 			/** | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 			 * @param {PathData} options context data | 
					
						
							|  |  |  | 			 * @returns {string} interpolated path | 
					
						
							| 
									
										
										
										
											2025-07-17 00:13:14 +08:00
										 |  |  | 			 */ (options) => | 
					
						
							| 
									
										
										
										
											2025-08-20 18:50:12 +08:00
										 |  |  | 				compilation.getAssetPath(compilation.outputOptions.publicPath, options), | 
					
						
							| 
									
										
										
										
											2020-03-13 00:51:26 +08:00
										 |  |  | 			"MainTemplate.getPublicPath is deprecated (use Compilation.getAssetPath(compilation.outputOptions.publicPath, options) instead)", | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 			"DEP_WEBPACK_MAIN_TEMPLATE_GET_PUBLIC_PATH" | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 		this.getAssetPath = util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 			/** | 
					
						
							|  |  |  | 			 * @param {TemplatePath} path used to get asset path with hash | 
					
						
							|  |  |  | 			 * @param {PathData} options context data | 
					
						
							|  |  |  | 			 * @returns {string} interpolated path | 
					
						
							|  |  |  | 			 */ | 
					
						
							| 
									
										
										
										
											2024-07-31 11:31:11 +08:00
										 |  |  | 			(path, options) => compilation.getAssetPath(path, options), | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 			"MainTemplate.getAssetPath is deprecated (use Compilation.getAssetPath instead)", | 
					
						
							|  |  |  | 			"DEP_WEBPACK_MAIN_TEMPLATE_GET_ASSET_PATH" | 
					
						
							| 
									
										
										
										
											2019-09-30 16:08:08 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2013-06-12 22:16:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 		this.getAssetPathWithInfo = util.deprecate( | 
					
						
							| 
									
										
										
										
											2024-08-09 01:03:17 +08:00
										 |  |  | 			/** | 
					
						
							|  |  |  | 			 * @param {TemplatePath} path used to get asset path with hash | 
					
						
							|  |  |  | 			 * @param {PathData} options context data | 
					
						
							|  |  |  | 			 * @returns {InterpolatedPathAndAssetInfo} interpolated path and asset info | 
					
						
							|  |  |  | 			 */ | 
					
						
							| 
									
										
										
										
											2024-07-31 11:31:11 +08:00
										 |  |  | 			(path, options) => compilation.getAssetPathWithInfo(path, options), | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 			"MainTemplate.getAssetPathWithInfo is deprecated (use Compilation.getAssetPath instead)", | 
					
						
							|  |  |  | 			"DEP_WEBPACK_MAIN_TEMPLATE_GET_ASSET_PATH_WITH_INFO" | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-11-29 01:43:01 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Object.defineProperty(MainTemplate.prototype, "requireFn", { | 
					
						
							|  |  |  | 	get: util.deprecate( | 
					
						
							| 
									
										
										
										
											2023-05-20 00:00:54 +08:00
										 |  |  | 		() => RuntimeGlobals.require, | 
					
						
							|  |  |  | 		`MainTemplate.requireFn is deprecated (use "${RuntimeGlobals.require}")`, | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 		"DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE_FN" | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Object.defineProperty(MainTemplate.prototype, "outputOptions", { | 
					
						
							|  |  |  | 	get: util.deprecate( | 
					
						
							|  |  |  | 		/** | 
					
						
							|  |  |  | 		 * @this {MainTemplate} | 
					
						
							| 
									
										
										
										
											2020-08-03 02:09:36 +08:00
										 |  |  | 		 * @returns {OutputOptions} output options | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2025-07-03 17:06:45 +08:00
										 |  |  | 		function outputOptions() { | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 			return this._outputOptions; | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		"MainTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)", | 
					
						
							|  |  |  | 		"DEP_WEBPACK_MAIN_TEMPLATE_OUTPUT_OPTIONS" | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = MainTemplate; |