| 
									
										
										
										
											2013-06-19 19:49:57 +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-09 02:11:26 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2018-03-22 19:05:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-30 00:14:40 +08:00
										 |  |  | const { SyncBailHook } = require("tapable"); | 
					
						
							| 
									
										
										
										
											2018-03-22 19:05:58 +08:00
										 |  |  | const { RawSource } = require("webpack-sources"); | 
					
						
							| 
									
										
										
										
											2019-12-16 20:21:39 +08:00
										 |  |  | const ChunkGraph = require("./ChunkGraph"); | 
					
						
							| 
									
										
										
										
											2020-05-12 18:16:51 +08:00
										 |  |  | const Compilation = require("./Compilation"); | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | const HotUpdateChunk = require("./HotUpdateChunk"); | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | const NormalModule = require("./NormalModule"); | 
					
						
							| 
									
										
										
										
											2018-11-05 21:36:15 +08:00
										 |  |  | const RuntimeGlobals = require("./RuntimeGlobals"); | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | const WebpackError = require("./WebpackError"); | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | const ConstDependency = require("./dependencies/ConstDependency"); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | const ImportMetaHotAcceptDependency = require("./dependencies/ImportMetaHotAcceptDependency"); | 
					
						
							|  |  |  | const ImportMetaHotDeclineDependency = require("./dependencies/ImportMetaHotDeclineDependency"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const ModuleHotAcceptDependency = require("./dependencies/ModuleHotAcceptDependency"); | 
					
						
							|  |  |  | const ModuleHotDeclineDependency = require("./dependencies/ModuleHotDeclineDependency"); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | const HotModuleReplacementRuntimeModule = require("./hmr/HotModuleReplacementRuntimeModule"); | 
					
						
							| 
									
										
										
										
											2019-10-11 21:46:57 +08:00
										 |  |  | const JavascriptParser = require("./javascript/JavascriptParser"); | 
					
						
							| 
									
										
										
										
											2019-10-22 15:27:52 +08:00
										 |  |  | const { | 
					
						
							| 
									
										
										
										
											2020-09-11 18:37:17 +08:00
										 |  |  | 	evaluateToIdentifier | 
					
						
							| 
									
										
										
										
											2019-10-22 15:27:52 +08:00
										 |  |  | } = require("./javascript/JavascriptParserHelpers"); | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | const { find, isSubset } = require("./util/SetHelpers"); | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | const TupleSet = require("./util/TupleSet"); | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | const { compareModulesById } = require("./util/comparators"); | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | const { | 
					
						
							|  |  |  | 	getRuntimeKey, | 
					
						
							|  |  |  | 	keyToRuntime, | 
					
						
							|  |  |  | 	forEachRuntime, | 
					
						
							|  |  |  | 	mergeRuntimeOwned, | 
					
						
							| 
									
										
										
										
											2021-05-27 04:16:32 +08:00
										 |  |  | 	subtractRuntime, | 
					
						
							|  |  |  | 	intersectRuntime | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | } = require("./util/runtime"); | 
					
						
							| 
									
										
										
										
											2013-06-19 19:49:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | const { | 
					
						
							|  |  |  | 	JAVASCRIPT_MODULE_TYPE_AUTO, | 
					
						
							|  |  |  | 	JAVASCRIPT_MODULE_TYPE_DYNAMIC, | 
					
						
							|  |  |  | 	JAVASCRIPT_MODULE_TYPE_ESM | 
					
						
							|  |  |  | } = require("./ModuleTypeConstants"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 21:26:06 +08:00
										 |  |  | /** @typedef {import("./Chunk")} Chunk */ | 
					
						
							| 
									
										
										
										
											2020-07-17 20:57:11 +08:00
										 |  |  | /** @typedef {import("./Compilation").AssetInfo} AssetInfo */ | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | /** @typedef {import("./Compiler")} Compiler */ | 
					
						
							|  |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | /** @typedef {import("./RuntimeModule")} RuntimeModule */ | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */ | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 21:26:06 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} HMRJavascriptParserHooks | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  |  * @property {SyncBailHook<[TODO, string[]], void>} hotAcceptCallback | 
					
						
							|  |  |  |  * @property {SyncBailHook<[TODO, string[]], void>} hotAcceptWithoutCallback | 
					
						
							| 
									
										
										
										
											2018-11-12 21:26:06 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** @type {WeakMap<JavascriptParser, HMRJavascriptParserHooks>} */ | 
					
						
							| 
									
										
										
										
											2018-07-06 18:51:14 +08:00
										 |  |  | const parserHooksMap = new WeakMap(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | const PLUGIN_NAME = "HotModuleReplacementPlugin"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 00:54:54 +08:00
										 |  |  | class HotModuleReplacementPlugin { | 
					
						
							| 
									
										
										
										
											2018-11-12 21:26:06 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {JavascriptParser} parser the parser | 
					
						
							|  |  |  | 	 * @returns {HMRJavascriptParserHooks} the attached hooks | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-31 00:54:54 +08:00
										 |  |  | 	static getParserHooks(parser) { | 
					
						
							| 
									
										
										
										
											2018-07-09 14:41:59 +08:00
										 |  |  | 		if (!(parser instanceof JavascriptParser)) { | 
					
						
							|  |  |  | 			throw new TypeError( | 
					
						
							|  |  |  | 				"The 'parser' argument must be an instance of JavascriptParser" | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-07-06 18:51:14 +08:00
										 |  |  | 		let hooks = parserHooksMap.get(parser); | 
					
						
							|  |  |  | 		if (hooks === undefined) { | 
					
						
							|  |  |  | 			hooks = { | 
					
						
							|  |  |  | 				hotAcceptCallback: new SyncBailHook(["expression", "requests"]), | 
					
						
							|  |  |  | 				hotAcceptWithoutCallback: new SyncBailHook(["expression", "requests"]) | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 			parserHooksMap.set(parser, hooks); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return hooks; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-18 02:57:32 +08:00
										 |  |  | 	constructor(options) { | 
					
						
							|  |  |  | 		this.options = options || {}; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2020-04-23 16:48:36 +08:00
										 |  |  | 	 * Apply the plugin | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the compiler instance | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-06-18 02:57:32 +08:00
										 |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2021-11-05 16:53:32 +08:00
										 |  |  | 		const { _backCompat: backCompat } = compiler; | 
					
						
							| 
									
										
										
										
											2021-03-09 18:52:10 +08:00
										 |  |  | 		if (compiler.options.output.strictModuleErrorHandling === undefined) | 
					
						
							|  |  |  | 			compiler.options.output.strictModuleErrorHandling = true; | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 		const runtimeRequirements = [RuntimeGlobals.module]; | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 		const createAcceptHandler = (parser, ParamDependency) => { | 
					
						
							| 
									
										
										
										
											2021-05-11 15:31:46 +08:00
										 |  |  | 			const { hotAcceptCallback, hotAcceptWithoutCallback } = | 
					
						
							|  |  |  | 				HotModuleReplacementPlugin.getParserHooks(parser); | 
					
						
							| 
									
										
										
										
											2018-07-06 18:51:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 			return expr => { | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				const module = parser.state.module; | 
					
						
							|  |  |  | 				const dep = new ConstDependency( | 
					
						
							|  |  |  | 					`${module.moduleArgument}.hot.accept`, | 
					
						
							|  |  |  | 					expr.callee.range, | 
					
						
							|  |  |  | 					runtimeRequirements | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				dep.loc = expr.loc; | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				module.addPresentationalDependency(dep); | 
					
						
							| 
									
										
										
										
											2020-09-11 18:37:17 +08:00
										 |  |  | 				module.buildInfo.moduleConcatenationBailout = "Hot Module Replacement"; | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				if (expr.arguments.length >= 1) { | 
					
						
							|  |  |  | 					const arg = parser.evaluateExpression(expr.arguments[0]); | 
					
						
							|  |  |  | 					let params = []; | 
					
						
							|  |  |  | 					let requests = []; | 
					
						
							|  |  |  | 					if (arg.isString()) { | 
					
						
							|  |  |  | 						params = [arg]; | 
					
						
							|  |  |  | 					} else if (arg.isArray()) { | 
					
						
							|  |  |  | 						params = arg.items.filter(param => param.isString()); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					if (params.length > 0) { | 
					
						
							|  |  |  | 						params.forEach((param, idx) => { | 
					
						
							|  |  |  | 							const request = param.string; | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 							const dep = new ParamDependency(request, param.range); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 							dep.optional = true; | 
					
						
							|  |  |  | 							dep.loc = Object.create(expr.loc); | 
					
						
							|  |  |  | 							dep.loc.index = idx; | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 							module.addDependency(dep); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 							requests.push(request); | 
					
						
							|  |  |  | 						}); | 
					
						
							|  |  |  | 						if (expr.arguments.length > 1) { | 
					
						
							|  |  |  | 							hotAcceptCallback.call(expr.arguments[1], requests); | 
					
						
							| 
									
										
										
										
											2021-03-09 18:52:10 +08:00
										 |  |  | 							for (let i = 1; i < expr.arguments.length; i++) { | 
					
						
							|  |  |  | 								parser.walkExpression(expr.arguments[i]); | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 							return true; | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							hotAcceptWithoutCallback.call(expr, requests); | 
					
						
							|  |  |  | 							return true; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				parser.walkExpressions(expr.arguments); | 
					
						
							|  |  |  | 				return true; | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 		const createDeclineHandler = (parser, ParamDependency) => expr => { | 
					
						
							|  |  |  | 			const module = parser.state.module; | 
					
						
							|  |  |  | 			const dep = new ConstDependency( | 
					
						
							|  |  |  | 				`${module.moduleArgument}.hot.decline`, | 
					
						
							|  |  |  | 				expr.callee.range, | 
					
						
							|  |  |  | 				runtimeRequirements | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 			dep.loc = expr.loc; | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 			module.addPresentationalDependency(dep); | 
					
						
							| 
									
										
										
										
											2020-09-11 18:37:17 +08:00
										 |  |  | 			module.buildInfo.moduleConcatenationBailout = "Hot Module Replacement"; | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 			if (expr.arguments.length === 1) { | 
					
						
							|  |  |  | 				const arg = parser.evaluateExpression(expr.arguments[0]); | 
					
						
							|  |  |  | 				let params = []; | 
					
						
							|  |  |  | 				if (arg.isString()) { | 
					
						
							|  |  |  | 					params = [arg]; | 
					
						
							|  |  |  | 				} else if (arg.isArray()) { | 
					
						
							|  |  |  | 					params = arg.items.filter(param => param.isString()); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				params.forEach((param, idx) => { | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 					const dep = new ParamDependency(param.string, param.range); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 					dep.optional = true; | 
					
						
							|  |  |  | 					dep.loc = Object.create(expr.loc); | 
					
						
							|  |  |  | 					dep.loc.index = idx; | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 					module.addDependency(dep); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const createHMRExpressionHandler = parser => expr => { | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 			const module = parser.state.module; | 
					
						
							|  |  |  | 			const dep = new ConstDependency( | 
					
						
							|  |  |  | 				`${module.moduleArgument}.hot`, | 
					
						
							|  |  |  | 				expr.range, | 
					
						
							|  |  |  | 				runtimeRequirements | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 			dep.loc = expr.loc; | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 			module.addPresentationalDependency(dep); | 
					
						
							| 
									
										
										
										
											2020-09-11 18:37:17 +08:00
										 |  |  | 			module.buildInfo.moduleConcatenationBailout = "Hot Module Replacement"; | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 			return true; | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 		const applyModuleHot = parser => { | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 			parser.hooks.evaluateIdentifier.for("module.hot").tap( | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					name: PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 					before: "NodeStuffPlugin" | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				expr => { | 
					
						
							| 
									
										
										
										
											2019-08-29 21:28:19 +08:00
										 |  |  | 					return evaluateToIdentifier( | 
					
						
							|  |  |  | 						"module.hot", | 
					
						
							|  |  |  | 						"module", | 
					
						
							|  |  |  | 						() => ["hot"], | 
					
						
							|  |  |  | 						true | 
					
						
							|  |  |  | 					)(expr); | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 			parser.hooks.call | 
					
						
							|  |  |  | 				.for("module.hot.accept") | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				.tap( | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 					createAcceptHandler(parser, ModuleHotAcceptDependency) | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 			parser.hooks.call | 
					
						
							|  |  |  | 				.for("module.hot.decline") | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				.tap( | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 					createDeclineHandler(parser, ModuleHotDeclineDependency) | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 			parser.hooks.expression | 
					
						
							|  |  |  | 				.for("module.hot") | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 				.tap(PLUGIN_NAME, createHMRExpressionHandler(parser)); | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 		const applyImportMetaHot = parser => { | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 			parser.hooks.evaluateIdentifier | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				.for("import.meta.webpackHot") | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 				.tap(PLUGIN_NAME, expr => { | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 					return evaluateToIdentifier( | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 						"import.meta.webpackHot", | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 						"import.meta", | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 						() => ["webpackHot"], | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 						true | 
					
						
							|  |  |  | 					)(expr); | 
					
						
							| 
									
										
										
										
											2018-11-18 19:25:13 +08:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 			parser.hooks.call | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				.for("import.meta.webpackHot.accept") | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				.tap( | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 					createAcceptHandler(parser, ImportMetaHotAcceptDependency) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			parser.hooks.call | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				.for("import.meta.webpackHot.decline") | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				.tap( | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 					createDeclineHandler(parser, ImportMetaHotDeclineDependency) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			parser.hooks.expression | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				.for("import.meta.webpackHot") | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 				.tap(PLUGIN_NAME, createHMRExpressionHandler(parser)); | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap( | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 			PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			(compilation, { normalModuleFactory }) => { | 
					
						
							| 
									
										
										
										
											2019-09-23 17:42:48 +08:00
										 |  |  | 				// This applies the HMR plugin only to the targeted compiler
 | 
					
						
							|  |  |  | 				// It should not affect child compilations
 | 
					
						
							|  |  |  | 				if (compilation.compiler !== compiler) return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				//#region module.hot.* API
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				compilation.dependencyFactories.set( | 
					
						
							|  |  |  | 					ModuleHotAcceptDependency, | 
					
						
							|  |  |  | 					normalModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				compilation.dependencyTemplates.set( | 
					
						
							|  |  |  | 					ModuleHotAcceptDependency, | 
					
						
							|  |  |  | 					new ModuleHotAcceptDependency.Template() | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				compilation.dependencyFactories.set( | 
					
						
							|  |  |  | 					ModuleHotDeclineDependency, | 
					
						
							|  |  |  | 					normalModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				compilation.dependencyTemplates.set( | 
					
						
							|  |  |  | 					ModuleHotDeclineDependency, | 
					
						
							|  |  |  | 					new ModuleHotDeclineDependency.Template() | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				//#endregion
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				//#region import.meta.webpackHot.* API
 | 
					
						
							| 
									
										
										
										
											2020-06-22 23:49:57 +08:00
										 |  |  | 				compilation.dependencyFactories.set( | 
					
						
							|  |  |  | 					ImportMetaHotAcceptDependency, | 
					
						
							|  |  |  | 					normalModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				compilation.dependencyTemplates.set( | 
					
						
							|  |  |  | 					ImportMetaHotAcceptDependency, | 
					
						
							|  |  |  | 					new ImportMetaHotAcceptDependency.Template() | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				compilation.dependencyFactories.set( | 
					
						
							|  |  |  | 					ImportMetaHotDeclineDependency, | 
					
						
							|  |  |  | 					normalModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				compilation.dependencyTemplates.set( | 
					
						
							|  |  |  | 					ImportMetaHotDeclineDependency, | 
					
						
							|  |  |  | 					new ImportMetaHotDeclineDependency.Template() | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				//#endregion
 | 
					
						
							| 
									
										
										
										
											2017-06-18 02:57:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 				let hotIndex = 0; | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 				const fullHashChunkModuleHashes = {}; | 
					
						
							|  |  |  | 				const chunkModuleHashes = {}; | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 				compilation.hooks.record.tap(PLUGIN_NAME, (compilation, records) => { | 
					
						
							|  |  |  | 					if (records.hash === compilation.hash) return; | 
					
						
							|  |  |  | 					const chunkGraph = compilation.chunkGraph; | 
					
						
							|  |  |  | 					records.hash = compilation.hash; | 
					
						
							|  |  |  | 					records.hotIndex = hotIndex; | 
					
						
							|  |  |  | 					records.fullHashChunkModuleHashes = fullHashChunkModuleHashes; | 
					
						
							|  |  |  | 					records.chunkModuleHashes = chunkModuleHashes; | 
					
						
							|  |  |  | 					records.chunkHashes = {}; | 
					
						
							|  |  |  | 					records.chunkRuntime = {}; | 
					
						
							|  |  |  | 					for (const chunk of compilation.chunks) { | 
					
						
							|  |  |  | 						records.chunkHashes[chunk.id] = chunk.hash; | 
					
						
							|  |  |  | 						records.chunkRuntime[chunk.id] = getRuntimeKey(chunk.runtime); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					records.chunkModuleIds = {}; | 
					
						
							|  |  |  | 					for (const chunk of compilation.chunks) { | 
					
						
							|  |  |  | 						records.chunkModuleIds[chunk.id] = Array.from( | 
					
						
							|  |  |  | 							chunkGraph.getOrderedChunkModulesIterable( | 
					
						
							|  |  |  | 								chunk, | 
					
						
							|  |  |  | 								compareModulesById(chunkGraph) | 
					
						
							|  |  |  | 							), | 
					
						
							|  |  |  | 							m => chunkGraph.getModuleId(m) | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 				/** @type {TupleSet<[Module, Chunk]>} */ | 
					
						
							|  |  |  | 				const updatedModules = new TupleSet(); | 
					
						
							|  |  |  | 				/** @type {TupleSet<[Module, Chunk]>} */ | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 				const fullHashModules = new TupleSet(); | 
					
						
							|  |  |  | 				/** @type {TupleSet<[Module, RuntimeSpec]>} */ | 
					
						
							|  |  |  | 				const nonCodeGeneratedModules = new TupleSet(); | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 				compilation.hooks.fullHash.tap(PLUGIN_NAME, hash => { | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 					const chunkGraph = compilation.chunkGraph; | 
					
						
							|  |  |  | 					const records = compilation.records; | 
					
						
							|  |  |  | 					for (const chunk of compilation.chunks) { | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 						const getModuleHash = module => { | 
					
						
							|  |  |  | 							if ( | 
					
						
							|  |  |  | 								compilation.codeGenerationResults.has(module, chunk.runtime) | 
					
						
							|  |  |  | 							) { | 
					
						
							|  |  |  | 								return compilation.codeGenerationResults.getHash( | 
					
						
							|  |  |  | 									module, | 
					
						
							|  |  |  | 									chunk.runtime | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								nonCodeGeneratedModules.add(module, chunk.runtime); | 
					
						
							|  |  |  | 								return chunkGraph.getModuleHash(module, chunk.runtime); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						}; | 
					
						
							| 
									
										
										
										
											2021-05-11 15:31:46 +08:00
										 |  |  | 						const fullHashModulesInThisChunk = | 
					
						
							|  |  |  | 							chunkGraph.getChunkFullHashModulesSet(chunk); | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 						if (fullHashModulesInThisChunk !== undefined) { | 
					
						
							|  |  |  | 							for (const module of fullHashModulesInThisChunk) { | 
					
						
							|  |  |  | 								fullHashModules.add(module, chunk); | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 						const modules = chunkGraph.getChunkModulesIterable(chunk); | 
					
						
							|  |  |  | 						if (modules !== undefined) { | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 							if (records.chunkModuleHashes) { | 
					
						
							|  |  |  | 								if (fullHashModulesInThisChunk !== undefined) { | 
					
						
							|  |  |  | 									for (const module of modules) { | 
					
						
							|  |  |  | 										const key = `${chunk.id}|${module.identifier()}`; | 
					
						
							|  |  |  | 										const hash = getModuleHash(module); | 
					
						
							|  |  |  | 										if ( | 
					
						
							|  |  |  | 											fullHashModulesInThisChunk.has( | 
					
						
							|  |  |  | 												/** @type {RuntimeModule} */ (module) | 
					
						
							|  |  |  | 											) | 
					
						
							|  |  |  | 										) { | 
					
						
							|  |  |  | 											if (records.fullHashChunkModuleHashes[key] !== hash) { | 
					
						
							|  |  |  | 												updatedModules.add(module, chunk); | 
					
						
							|  |  |  | 											} | 
					
						
							|  |  |  | 											fullHashChunkModuleHashes[key] = hash; | 
					
						
							|  |  |  | 										} else { | 
					
						
							|  |  |  | 											if (records.chunkModuleHashes[key] !== hash) { | 
					
						
							|  |  |  | 												updatedModules.add(module, chunk); | 
					
						
							|  |  |  | 											} | 
					
						
							|  |  |  | 											chunkModuleHashes[key] = hash; | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 										} | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 									} | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									for (const module of modules) { | 
					
						
							|  |  |  | 										const key = `${chunk.id}|${module.identifier()}`; | 
					
						
							|  |  |  | 										const hash = getModuleHash(module); | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 										if (records.chunkModuleHashes[key] !== hash) { | 
					
						
							|  |  |  | 											updatedModules.add(module, chunk); | 
					
						
							|  |  |  | 										} | 
					
						
							|  |  |  | 										chunkModuleHashes[key] = hash; | 
					
						
							|  |  |  | 									} | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 							} else { | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 								if (fullHashModulesInThisChunk !== undefined) { | 
					
						
							|  |  |  | 									for (const module of modules) { | 
					
						
							|  |  |  | 										const key = `${chunk.id}|${module.identifier()}`; | 
					
						
							|  |  |  | 										const hash = getModuleHash(module); | 
					
						
							|  |  |  | 										if ( | 
					
						
							|  |  |  | 											fullHashModulesInThisChunk.has( | 
					
						
							|  |  |  | 												/** @type {RuntimeModule} */ (module) | 
					
						
							|  |  |  | 											) | 
					
						
							|  |  |  | 										) { | 
					
						
							|  |  |  | 											fullHashChunkModuleHashes[key] = hash; | 
					
						
							|  |  |  | 										} else { | 
					
						
							|  |  |  | 											chunkModuleHashes[key] = hash; | 
					
						
							|  |  |  | 										} | 
					
						
							|  |  |  | 									} | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									for (const module of modules) { | 
					
						
							|  |  |  | 										const key = `${chunk.id}|${module.identifier()}`; | 
					
						
							|  |  |  | 										const hash = getModuleHash(module); | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 										chunkModuleHashes[key] = hash; | 
					
						
							|  |  |  | 									} | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 					hotIndex = records.hotIndex || 0; | 
					
						
							|  |  |  | 					if (updatedModules.size > 0) hotIndex++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					hash.update(`${hotIndex}`); | 
					
						
							| 
									
										
										
										
											2017-06-18 02:57:32 +08:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2020-05-12 18:16:51 +08:00
										 |  |  | 				compilation.hooks.processAssets.tap( | 
					
						
							|  |  |  | 					{ | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 						name: PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2020-05-12 18:16:51 +08:00
										 |  |  | 						stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL | 
					
						
							|  |  |  | 					}, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					() => { | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 						const chunkGraph = compilation.chunkGraph; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						const records = compilation.records; | 
					
						
							|  |  |  | 						if (records.hash === compilation.hash) return; | 
					
						
							|  |  |  | 						if ( | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 							!records.chunkModuleHashes || | 
					
						
							| 
									
										
										
										
											2021-08-04 05:51:25 +08:00
										 |  |  | 							!records.chunkHashes || | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							!records.chunkModuleIds | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 						) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							return; | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 						for (const [module, chunk] of fullHashModules) { | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 							const key = `${chunk.id}|${module.identifier()}`; | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 							const hash = nonCodeGeneratedModules.has(module, chunk.runtime) | 
					
						
							|  |  |  | 								? chunkGraph.getModuleHash(module, chunk.runtime) | 
					
						
							|  |  |  | 								: compilation.codeGenerationResults.getHash( | 
					
						
							|  |  |  | 										module, | 
					
						
							|  |  |  | 										chunk.runtime | 
					
						
							|  |  |  | 								  ); | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 							if (records.chunkModuleHashes[key] !== hash) { | 
					
						
							|  |  |  | 								updatedModules.add(module, chunk); | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 							chunkModuleHashes[key] = hash; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | 						/** @type {Map<string, { updatedChunkIds: Set<string|number>, removedChunkIds: Set<string|number>, removedModules: Set<Module>, filename: string, assetInfo: AssetInfo }>} */ | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 						const hotUpdateMainContentByRuntime = new Map(); | 
					
						
							|  |  |  | 						let allOldRuntime; | 
					
						
							|  |  |  | 						for (const key of Object.keys(records.chunkRuntime)) { | 
					
						
							|  |  |  | 							const runtime = keyToRuntime(records.chunkRuntime[key]); | 
					
						
							|  |  |  | 							allOldRuntime = mergeRuntimeOwned(allOldRuntime, runtime); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						forEachRuntime(allOldRuntime, runtime => { | 
					
						
							| 
									
										
										
										
											2021-05-11 15:31:46 +08:00
										 |  |  | 							const { path: filename, info: assetInfo } = | 
					
						
							|  |  |  | 								compilation.getPathWithInfo( | 
					
						
							|  |  |  | 									compilation.outputOptions.hotUpdateMainFilename, | 
					
						
							|  |  |  | 									{ | 
					
						
							|  |  |  | 										hash: records.hash, | 
					
						
							|  |  |  | 										runtime | 
					
						
							|  |  |  | 									} | 
					
						
							|  |  |  | 								); | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 							hotUpdateMainContentByRuntime.set(runtime, { | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | 								updatedChunkIds: new Set(), | 
					
						
							|  |  |  | 								removedChunkIds: new Set(), | 
					
						
							|  |  |  | 								removedModules: new Set(), | 
					
						
							|  |  |  | 								filename, | 
					
						
							|  |  |  | 								assetInfo | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 							}); | 
					
						
							|  |  |  | 						}); | 
					
						
							|  |  |  | 						if (hotUpdateMainContentByRuntime.size === 0) return; | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						// Create a list of all active modules to verify which modules are removed completely
 | 
					
						
							|  |  |  | 						/** @type {Map<number|string, Module>} */ | 
					
						
							|  |  |  | 						const allModules = new Map(); | 
					
						
							|  |  |  | 						for (const module of compilation.modules) { | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 							const id = chunkGraph.getModuleId(module); | 
					
						
							|  |  |  | 							allModules.set(id, module); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						// List of completely removed modules
 | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 						/** @type {Set<string | number>} */ | 
					
						
							|  |  |  | 						const completelyRemovedModules = new Set(); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-04 05:51:25 +08:00
										 |  |  | 						for (const key of Object.keys(records.chunkHashes)) { | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 							const oldRuntime = keyToRuntime(records.chunkRuntime[key]); | 
					
						
							|  |  |  | 							/** @type {Module[]} */ | 
					
						
							|  |  |  | 							const remainingModules = []; | 
					
						
							|  |  |  | 							// Check which modules are removed
 | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 							for (const id of records.chunkModuleIds[key]) { | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								const module = allModules.get(id); | 
					
						
							|  |  |  | 								if (module === undefined) { | 
					
						
							|  |  |  | 									completelyRemovedModules.add(id); | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									remainingModules.push(module); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							let chunkId; | 
					
						
							|  |  |  | 							let newModules; | 
					
						
							|  |  |  | 							let newRuntimeModules; | 
					
						
							|  |  |  | 							let newFullHashModules; | 
					
						
							| 
									
										
										
										
											2021-09-02 16:00:24 +08:00
										 |  |  | 							let newDependentHashModules; | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 							let newRuntime; | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 							let removedFromRuntime; | 
					
						
							| 
									
										
										
										
											2018-09-06 22:59:11 +08:00
										 |  |  | 							const currentChunk = find( | 
					
						
							|  |  |  | 								compilation.chunks, | 
					
						
							| 
									
										
										
										
											2018-10-30 15:49:48 +08:00
										 |  |  | 								chunk => `${chunk.id}` === key | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							); | 
					
						
							|  |  |  | 							if (currentChunk) { | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								chunkId = currentChunk.id; | 
					
						
							| 
									
										
										
										
											2021-05-27 04:16:32 +08:00
										 |  |  | 								newRuntime = intersectRuntime( | 
					
						
							|  |  |  | 									currentChunk.runtime, | 
					
						
							|  |  |  | 									allOldRuntime | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 								if (newRuntime === undefined) continue; | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								newModules = chunkGraph | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 									.getChunkModules(currentChunk) | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 									.filter(module => updatedModules.has(module, currentChunk)); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								newRuntimeModules = Array.from( | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 									chunkGraph.getChunkRuntimeModulesIterable(currentChunk) | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 								).filter(module => updatedModules.has(module, currentChunk)); | 
					
						
							| 
									
										
										
										
											2021-05-11 15:31:46 +08:00
										 |  |  | 								const fullHashModules = | 
					
						
							|  |  |  | 									chunkGraph.getChunkFullHashModulesIterable(currentChunk); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								newFullHashModules = | 
					
						
							| 
									
										
										
										
											2020-04-30 23:52:27 +08:00
										 |  |  | 									fullHashModules && | 
					
						
							|  |  |  | 									Array.from(fullHashModules).filter(module => | 
					
						
							| 
									
										
										
										
											2020-07-28 20:06:04 +08:00
										 |  |  | 										updatedModules.has(module, currentChunk) | 
					
						
							| 
									
										
										
										
											2020-04-30 23:52:27 +08:00
										 |  |  | 									); | 
					
						
							| 
									
										
										
										
											2021-09-02 16:00:24 +08:00
										 |  |  | 								const dependentHashModules = | 
					
						
							|  |  |  | 									chunkGraph.getChunkDependentHashModulesIterable(currentChunk); | 
					
						
							|  |  |  | 								newDependentHashModules = | 
					
						
							|  |  |  | 									dependentHashModules && | 
					
						
							|  |  |  | 									Array.from(dependentHashModules).filter(module => | 
					
						
							|  |  |  | 										updatedModules.has(module, currentChunk) | 
					
						
							|  |  |  | 									); | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								removedFromRuntime = subtractRuntime(oldRuntime, newRuntime); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 							} else { | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								// chunk has completely removed
 | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								chunkId = `${+key}` === key ? +key : key; | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								removedFromRuntime = oldRuntime; | 
					
						
							|  |  |  | 								newRuntime = oldRuntime; | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							if (removedFromRuntime) { | 
					
						
							|  |  |  | 								// chunk was removed from some runtimes
 | 
					
						
							|  |  |  | 								forEachRuntime(removedFromRuntime, runtime => { | 
					
						
							|  |  |  | 									hotUpdateMainContentByRuntime | 
					
						
							|  |  |  | 										.get(runtime) | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | 										.removedChunkIds.add(chunkId); | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								}); | 
					
						
							|  |  |  | 								// dispose modules from the chunk in these runtimes
 | 
					
						
							|  |  |  | 								// where they are no longer in this runtime
 | 
					
						
							|  |  |  | 								for (const module of remainingModules) { | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 									const moduleKey = `${key}|${module.identifier()}`; | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 									const oldHash = records.chunkModuleHashes[moduleKey]; | 
					
						
							|  |  |  | 									const runtimes = chunkGraph.getModuleRuntimes(module); | 
					
						
							|  |  |  | 									if (oldRuntime === newRuntime && runtimes.has(newRuntime)) { | 
					
						
							|  |  |  | 										// Module is still in the same runtime combination
 | 
					
						
							| 
									
										
										
										
											2021-01-26 07:48:37 +08:00
										 |  |  | 										const hash = nonCodeGeneratedModules.has(module, newRuntime) | 
					
						
							|  |  |  | 											? chunkGraph.getModuleHash(module, newRuntime) | 
					
						
							|  |  |  | 											: compilation.codeGenerationResults.getHash( | 
					
						
							|  |  |  | 													module, | 
					
						
							|  |  |  | 													newRuntime | 
					
						
							|  |  |  | 											  ); | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 										if (hash !== oldHash) { | 
					
						
							|  |  |  | 											if (module.type === "runtime") { | 
					
						
							|  |  |  | 												newRuntimeModules = newRuntimeModules || []; | 
					
						
							|  |  |  | 												newRuntimeModules.push( | 
					
						
							|  |  |  | 													/** @type {RuntimeModule} */ (module) | 
					
						
							|  |  |  | 												); | 
					
						
							|  |  |  | 											} else { | 
					
						
							|  |  |  | 												newModules = newModules || []; | 
					
						
							|  |  |  | 												newModules.push(module); | 
					
						
							|  |  |  | 											} | 
					
						
							|  |  |  | 										} | 
					
						
							|  |  |  | 									} else { | 
					
						
							|  |  |  | 										// module is no longer in this runtime combination
 | 
					
						
							|  |  |  | 										// We (incorrectly) assume that it's not in an overlapping runtime combination
 | 
					
						
							|  |  |  | 										// and dispose it from the main runtimes the chunk was removed from
 | 
					
						
							|  |  |  | 										forEachRuntime(removedFromRuntime, runtime => { | 
					
						
							|  |  |  | 											// If the module is still used in this runtime, do not dispose it
 | 
					
						
							|  |  |  | 											// This could create a bad runtime state where the module is still loaded,
 | 
					
						
							|  |  |  | 											// but no chunk which contains it. This means we don't receive further HMR updates
 | 
					
						
							|  |  |  | 											// to this module and that's bad.
 | 
					
						
							|  |  |  | 											// TODO force load one of the chunks which contains the module
 | 
					
						
							|  |  |  | 											for (const moduleRuntime of runtimes) { | 
					
						
							|  |  |  | 												if (typeof moduleRuntime === "string") { | 
					
						
							|  |  |  | 													if (moduleRuntime === runtime) return; | 
					
						
							|  |  |  | 												} else if (moduleRuntime !== undefined) { | 
					
						
							|  |  |  | 													if (moduleRuntime.has(runtime)) return; | 
					
						
							|  |  |  | 												} | 
					
						
							|  |  |  | 											} | 
					
						
							|  |  |  | 											hotUpdateMainContentByRuntime | 
					
						
							|  |  |  | 												.get(runtime) | 
					
						
							|  |  |  | 												.removedModules.add(module); | 
					
						
							|  |  |  | 										}); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 									} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								} | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 							} | 
					
						
							|  |  |  | 							if ( | 
					
						
							|  |  |  | 								(newModules && newModules.length > 0) || | 
					
						
							|  |  |  | 								(newRuntimeModules && newRuntimeModules.length > 0) | 
					
						
							|  |  |  | 							) { | 
					
						
							|  |  |  | 								const hotUpdateChunk = new HotUpdateChunk(); | 
					
						
							| 
									
										
										
										
											2021-11-05 16:53:32 +08:00
										 |  |  | 								if (backCompat) | 
					
						
							|  |  |  | 									ChunkGraph.setChunkGraphForChunk(hotUpdateChunk, chunkGraph); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								hotUpdateChunk.id = chunkId; | 
					
						
							|  |  |  | 								hotUpdateChunk.runtime = newRuntime; | 
					
						
							| 
									
										
										
										
											2020-09-25 02:28:08 +08:00
										 |  |  | 								if (currentChunk) { | 
					
						
							|  |  |  | 									for (const group of currentChunk.groupsIterable) | 
					
						
							|  |  |  | 										hotUpdateChunk.addGroup(group); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								chunkGraph.attachModules(hotUpdateChunk, newModules || []); | 
					
						
							|  |  |  | 								chunkGraph.attachRuntimeModules( | 
					
						
							|  |  |  | 									hotUpdateChunk, | 
					
						
							|  |  |  | 									newRuntimeModules || [] | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								if (newFullHashModules) { | 
					
						
							|  |  |  | 									chunkGraph.attachFullHashModules( | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 										hotUpdateChunk, | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 										newFullHashModules | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 									); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								} | 
					
						
							| 
									
										
										
										
											2021-09-02 16:00:24 +08:00
										 |  |  | 								if (newDependentHashModules) { | 
					
						
							|  |  |  | 									chunkGraph.attachDependentHashModules( | 
					
						
							|  |  |  | 										hotUpdateChunk, | 
					
						
							|  |  |  | 										newDependentHashModules | 
					
						
							|  |  |  | 									); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 								const renderManifest = compilation.getRenderManifest({ | 
					
						
							|  |  |  | 									chunk: hotUpdateChunk, | 
					
						
							|  |  |  | 									hash: records.hash, | 
					
						
							|  |  |  | 									fullHash: records.hash, | 
					
						
							|  |  |  | 									outputOptions: compilation.outputOptions, | 
					
						
							|  |  |  | 									moduleTemplates: compilation.moduleTemplates, | 
					
						
							|  |  |  | 									dependencyTemplates: compilation.dependencyTemplates, | 
					
						
							|  |  |  | 									codeGenerationResults: compilation.codeGenerationResults, | 
					
						
							|  |  |  | 									runtimeTemplate: compilation.runtimeTemplate, | 
					
						
							|  |  |  | 									moduleGraph: compilation.moduleGraph, | 
					
						
							|  |  |  | 									chunkGraph | 
					
						
							|  |  |  | 								}); | 
					
						
							|  |  |  | 								for (const entry of renderManifest) { | 
					
						
							|  |  |  | 									/** @type {string} */ | 
					
						
							|  |  |  | 									let filename; | 
					
						
							|  |  |  | 									/** @type {AssetInfo} */ | 
					
						
							|  |  |  | 									let assetInfo; | 
					
						
							|  |  |  | 									if ("filename" in entry) { | 
					
						
							|  |  |  | 										filename = entry.filename; | 
					
						
							|  |  |  | 										assetInfo = entry.info; | 
					
						
							|  |  |  | 									} else { | 
					
						
							| 
									
										
										
										
											2021-05-11 15:31:46 +08:00
										 |  |  | 										({ path: filename, info: assetInfo } = | 
					
						
							|  |  |  | 											compilation.getPathWithInfo( | 
					
						
							|  |  |  | 												entry.filenameTemplate, | 
					
						
							|  |  |  | 												entry.pathOptions | 
					
						
							|  |  |  | 											)); | 
					
						
							| 
									
										
										
										
											2020-04-30 23:52:27 +08:00
										 |  |  | 									} | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 									const source = entry.render(); | 
					
						
							|  |  |  | 									compilation.additionalChunkAssets.push(filename); | 
					
						
							|  |  |  | 									compilation.emitAsset(filename, source, { | 
					
						
							|  |  |  | 										hotModuleReplacement: true, | 
					
						
							|  |  |  | 										...assetInfo | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 									}); | 
					
						
							| 
									
										
										
										
											2020-09-04 06:19:39 +08:00
										 |  |  | 									if (currentChunk) { | 
					
						
							| 
									
										
										
										
											2019-06-14 16:45:56 +08:00
										 |  |  | 										currentChunk.files.add(filename); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 										compilation.hooks.chunkAsset.call(currentChunk, filename); | 
					
						
							|  |  |  | 									} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								} | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								forEachRuntime(newRuntime, runtime => { | 
					
						
							|  |  |  | 									hotUpdateMainContentByRuntime | 
					
						
							|  |  |  | 										.get(runtime) | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | 										.updatedChunkIds.add(chunkId); | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								}); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 						const completelyRemovedModulesArray = Array.from( | 
					
						
							|  |  |  | 							completelyRemovedModules | 
					
						
							| 
									
										
										
										
											2020-02-17 17:27:46 +08:00
										 |  |  | 						); | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | 						const hotUpdateMainContentByFilename = new Map(); | 
					
						
							|  |  |  | 						for (const { | 
					
						
							|  |  |  | 							removedChunkIds, | 
					
						
							|  |  |  | 							removedModules, | 
					
						
							|  |  |  | 							updatedChunkIds, | 
					
						
							|  |  |  | 							filename, | 
					
						
							|  |  |  | 							assetInfo | 
					
						
							|  |  |  | 						} of hotUpdateMainContentByRuntime.values()) { | 
					
						
							|  |  |  | 							const old = hotUpdateMainContentByFilename.get(filename); | 
					
						
							|  |  |  | 							if ( | 
					
						
							|  |  |  | 								old && | 
					
						
							|  |  |  | 								(!isSubset(old.removedChunkIds, removedChunkIds) || | 
					
						
							|  |  |  | 									!isSubset(old.removedModules, removedModules) || | 
					
						
							|  |  |  | 									!isSubset(old.updatedChunkIds, updatedChunkIds)) | 
					
						
							|  |  |  | 							) { | 
					
						
							|  |  |  | 								compilation.warnings.push( | 
					
						
							|  |  |  | 									new WebpackError(`HotModuleReplacementPlugin
 | 
					
						
							|  |  |  | The configured output.hotUpdateMainFilename doesn't lead to unique filenames per runtime and HMR update differs between runtimes. | 
					
						
							|  |  |  | This might lead to incorrect runtime behavior of the applied update. | 
					
						
							|  |  |  | To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename option, or use the default config.`)
 | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 								for (const chunkId of removedChunkIds) | 
					
						
							|  |  |  | 									old.removedChunkIds.add(chunkId); | 
					
						
							|  |  |  | 								for (const chunkId of removedModules) | 
					
						
							|  |  |  | 									old.removedModules.add(chunkId); | 
					
						
							|  |  |  | 								for (const chunkId of updatedChunkIds) | 
					
						
							|  |  |  | 									old.updatedChunkIds.add(chunkId); | 
					
						
							|  |  |  | 								continue; | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							hotUpdateMainContentByFilename.set(filename, { | 
					
						
							|  |  |  | 								removedChunkIds, | 
					
						
							|  |  |  | 								removedModules, | 
					
						
							|  |  |  | 								updatedChunkIds, | 
					
						
							|  |  |  | 								assetInfo | 
					
						
							|  |  |  | 							}); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 						for (const [ | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | 							filename, | 
					
						
							|  |  |  | 							{ removedChunkIds, removedModules, updatedChunkIds, assetInfo } | 
					
						
							|  |  |  | 						] of hotUpdateMainContentByFilename) { | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 							const hotUpdateMainJson = { | 
					
						
							| 
									
										
										
										
											2020-11-28 22:48:01 +08:00
										 |  |  | 								c: Array.from(updatedChunkIds), | 
					
						
							|  |  |  | 								r: Array.from(removedChunkIds), | 
					
						
							| 
									
										
										
										
											2020-11-28 19:42:03 +08:00
										 |  |  | 								m: | 
					
						
							|  |  |  | 									removedModules.size === 0 | 
					
						
							|  |  |  | 										? completelyRemovedModulesArray | 
					
						
							|  |  |  | 										: completelyRemovedModulesArray.concat( | 
					
						
							|  |  |  | 												Array.from(removedModules, m => | 
					
						
							|  |  |  | 													chunkGraph.getModuleId(m) | 
					
						
							|  |  |  | 												) | 
					
						
							|  |  |  | 										  ) | 
					
						
							|  |  |  | 							}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							const source = new RawSource(JSON.stringify(hotUpdateMainJson)); | 
					
						
							|  |  |  | 							compilation.emitAsset(filename, source, { | 
					
						
							|  |  |  | 								hotModuleReplacement: true, | 
					
						
							|  |  |  | 								...assetInfo | 
					
						
							|  |  |  | 							}); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 				compilation.hooks.additionalTreeRuntimeRequirements.tap( | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 					(chunk, runtimeRequirements) => { | 
					
						
							|  |  |  | 						runtimeRequirements.add(RuntimeGlobals.hmrDownloadManifest); | 
					
						
							|  |  |  | 						runtimeRequirements.add(RuntimeGlobals.hmrDownloadUpdateHandlers); | 
					
						
							|  |  |  | 						runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution); | 
					
						
							|  |  |  | 						runtimeRequirements.add(RuntimeGlobals.moduleCache); | 
					
						
							|  |  |  | 						compilation.addRuntimeModule( | 
					
						
							|  |  |  | 							chunk, | 
					
						
							|  |  |  | 							new HotModuleReplacementRuntimeModule() | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						); | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				normalModuleFactory.hooks.parser | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					.for(JAVASCRIPT_MODULE_TYPE_AUTO) | 
					
						
							|  |  |  | 					.tap(PLUGIN_NAME, parser => { | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 						applyModuleHot(parser); | 
					
						
							|  |  |  | 						applyImportMetaHot(parser); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				normalModuleFactory.hooks.parser | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC) | 
					
						
							|  |  |  | 					.tap(PLUGIN_NAME, parser => { | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 						applyModuleHot(parser); | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 				normalModuleFactory.hooks.parser | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					.for(JAVASCRIPT_MODULE_TYPE_ESM) | 
					
						
							|  |  |  | 					.tap(PLUGIN_NAME, parser => { | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 						applyImportMetaHot(parser); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-01-03 19:27:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | 				NormalModule.getCompilationHooks(compilation).loader.tap( | 
					
						
							| 
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 |  |  | 					PLUGIN_NAME, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					context => { | 
					
						
							|  |  |  | 						context.hot = true; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-06-18 02:57:32 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-31 00:54:54 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = HotModuleReplacementPlugin; |