| 
									
										
										
										
											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-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 { | 
					
						
							|  |  |  | 	evaluateToIdentifier, | 
					
						
							|  |  |  | 	evaluateToString, | 
					
						
							|  |  |  | 	toConstantDependency | 
					
						
							|  |  |  | } = require("./javascript/JavascriptParserHelpers"); | 
					
						
							| 
									
										
										
										
											2018-09-06 22:59:11 +08:00
										 |  |  | const { find } = require("./util/SetHelpers"); | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | const { compareModulesById } = require("./util/comparators"); | 
					
						
							| 
									
										
										
										
											2013-06-19 19:49:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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) { | 
					
						
							| 
									
										
										
										
											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) => { | 
					
						
							| 
									
										
										
										
											2018-07-06 18:51:14 +08:00
										 |  |  | 			const { | 
					
						
							|  |  |  | 				hotAcceptCallback, | 
					
						
							|  |  |  | 				hotAcceptWithoutCallback | 
					
						
							| 
									
										
										
										
											2018-07-31 00:54:54 +08:00
										 |  |  | 			} = 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-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); | 
					
						
							|  |  |  | 							parser.walkExpression(expr.arguments[1]); // other args are ignored
 | 
					
						
							|  |  |  | 							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-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-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( | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					name: "HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					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( | 
					
						
							|  |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					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( | 
					
						
							|  |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					createDeclineHandler(parser, ModuleHotDeclineDependency) | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 			parser.hooks.expression | 
					
						
							|  |  |  | 				.for("module.hot") | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 				.tap("HotModuleReplacementPlugin", createHMRExpressionHandler(parser)); | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											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") | 
					
						
							| 
									
										
										
										
											2018-11-18 19:25:13 +08:00
										 |  |  | 				.tap("HotModuleReplacementPlugin", 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( | 
					
						
							|  |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					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( | 
					
						
							|  |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					createDeclineHandler(parser, ImportMetaHotDeclineDependency) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			parser.hooks.expression | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:44 +08:00
										 |  |  | 				.for("import.meta.webpackHot") | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 				.tap("HotModuleReplacementPlugin", createHMRExpressionHandler(parser)); | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const applyWebpackHash = parser => { | 
					
						
							|  |  |  | 			parser.hooks.expression | 
					
						
							|  |  |  | 				.for("__webpack_hash__") | 
					
						
							|  |  |  | 				.tap( | 
					
						
							|  |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					toConstantDependency(parser, `${RuntimeGlobals.getFullHash}()`, [ | 
					
						
							|  |  |  | 						RuntimeGlobals.getFullHash | 
					
						
							|  |  |  | 					]) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			parser.hooks.evaluateTypeof | 
					
						
							|  |  |  | 				.for("__webpack_hash__") | 
					
						
							|  |  |  | 				.tap("HotModuleReplacementPlugin", evaluateToString("string")); | 
					
						
							| 
									
										
										
										
											2018-07-05 17:25:34 +08:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap( | 
					
						
							|  |  |  | 			"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 			(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; | 
					
						
							|  |  |  | 				const fullHashModuleHashes = {}; | 
					
						
							|  |  |  | 				const moduleHashes = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				compilation.hooks.record.tap( | 
					
						
							|  |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					(compilation, records) => { | 
					
						
							|  |  |  | 						if (records.hash === compilation.hash) return; | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 						const chunkGraph = compilation.chunkGraph; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						records.hash = compilation.hash; | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 						records.hotIndex = hotIndex; | 
					
						
							|  |  |  | 						records.fullHashModuleHashes = fullHashModuleHashes; | 
					
						
							|  |  |  | 						records.moduleHashes = moduleHashes; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						records.chunkHashs = {}; | 
					
						
							|  |  |  | 						for (const chunk of compilation.chunks) { | 
					
						
							|  |  |  | 							records.chunkHashs[chunk.id] = chunk.hash; | 
					
						
							| 
									
										
										
										
											2017-06-18 02:57:32 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						records.chunkModuleIds = {}; | 
					
						
							|  |  |  | 						for (const chunk of compilation.chunks) { | 
					
						
							| 
									
										
										
										
											2019-11-15 17:20:45 +08:00
										 |  |  | 							records.chunkModuleIds[ | 
					
						
							|  |  |  | 								chunk.id | 
					
						
							|  |  |  | 							] = Array.from( | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 								chunkGraph.getOrderedChunkModulesIterable( | 
					
						
							|  |  |  | 									chunk, | 
					
						
							| 
									
										
										
										
											2018-08-28 17:50:33 +08:00
										 |  |  | 									compareModulesById(chunkGraph) | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 								), | 
					
						
							| 
									
										
										
										
											2018-08-28 17:56:48 +08:00
										 |  |  | 								m => chunkGraph.getModuleId(m) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 				/** @type {Set<Module>} */ | 
					
						
							|  |  |  | 				const updatedModules = new Set(); | 
					
						
							|  |  |  | 				/** @type {Set<Module>} */ | 
					
						
							|  |  |  | 				const lazyHashedModules = new Set(); | 
					
						
							|  |  |  | 				compilation.hooks.fullHash.tap("HotModuleReplacementPlugin", hash => { | 
					
						
							|  |  |  | 					const chunkGraph = compilation.chunkGraph; | 
					
						
							|  |  |  | 					const records = compilation.records; | 
					
						
							|  |  |  | 					for (const chunk of compilation.chunks) { | 
					
						
							|  |  |  | 						const modules = chunkGraph.getChunkFullHashModulesIterable(chunk); | 
					
						
							|  |  |  | 						if (modules !== undefined) { | 
					
						
							|  |  |  | 							for (const module of modules) { | 
					
						
							|  |  |  | 								lazyHashedModules.add(module); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2013-07-01 19:59:02 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 					if (records.moduleHashes && records.fullHashModuleHashes) { | 
					
						
							|  |  |  | 						for (const module of compilation.modules) { | 
					
						
							|  |  |  | 							const identifier = module.identifier(); | 
					
						
							|  |  |  | 							const hash = chunkGraph.getModuleHash(module); | 
					
						
							|  |  |  | 							if (lazyHashedModules.has(module)) { | 
					
						
							|  |  |  | 								if (records.fullHashModuleHashes[identifier] !== hash) { | 
					
						
							|  |  |  | 									updatedModules.add(module); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								fullHashModuleHashes[identifier] = hash; | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								if (records.moduleHashes[identifier] !== hash) { | 
					
						
							|  |  |  | 									updatedModules.add(module); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								moduleHashes[identifier] = hash; | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						for (const module of compilation.modules) { | 
					
						
							|  |  |  | 							const identifier = module.identifier(); | 
					
						
							|  |  |  | 							const hash = chunkGraph.getModuleHash(module); | 
					
						
							|  |  |  | 							if (lazyHashedModules.has(module)) { | 
					
						
							|  |  |  | 								fullHashModuleHashes[identifier] = hash; | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								moduleHashes[identifier] = hash; | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +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( | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						name: "HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 						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-08 23:20:14 +08:00
										 |  |  | 							!records.moduleHashes || | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							!records.chunkHashs || | 
					
						
							|  |  |  | 							!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
										 |  |  | 						} | 
					
						
							|  |  |  | 						for (const module of lazyHashedModules) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							const identifier = module.identifier(); | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  | 							const hash = chunkGraph.getModuleHash(module); | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 							if (records.moduleHashes[identifier] !== hash) { | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 								updatedModules.add(module); | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 							moduleHashes[identifier] = hash; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 						const hotUpdateMainContent = { | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 							c: [], | 
					
						
							|  |  |  | 							r: [], | 
					
						
							|  |  |  | 							m: undefined | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						}; | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 						const allRemovedModules = new Set(); | 
					
						
							| 
									
										
										
										
											2018-04-12 07:04:52 +08:00
										 |  |  | 						for (const key of Object.keys(records.chunkHashs)) { | 
					
						
							| 
									
										
										
										
											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-01-15 17:43:58 +08:00
										 |  |  | 								const chunkId = currentChunk.id; | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 								const newModules = chunkGraph | 
					
						
							|  |  |  | 									.getChunkModules(currentChunk) | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 									.filter(module => updatedModules.has(module)); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 								const newRuntimeModules = Array.from( | 
					
						
							|  |  |  | 									chunkGraph.getChunkRuntimeModulesIterable(currentChunk) | 
					
						
							|  |  |  | 								).filter(module => updatedModules.has(module)); | 
					
						
							| 
									
										
										
										
											2020-04-30 23:52:27 +08:00
										 |  |  | 								const fullHashModules = chunkGraph.getChunkFullHashModulesIterable( | 
					
						
							|  |  |  | 									currentChunk | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 								const newFullHashModules = | 
					
						
							|  |  |  | 									fullHashModules && | 
					
						
							|  |  |  | 									Array.from(fullHashModules).filter(module => | 
					
						
							|  |  |  | 										updatedModules.has(module) | 
					
						
							|  |  |  | 									); | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 								/** @type {Set<number|string>} */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								const allModules = new Set(); | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 								for (const module of chunkGraph.getChunkModulesIterable( | 
					
						
							|  |  |  | 									currentChunk | 
					
						
							|  |  |  | 								)) { | 
					
						
							| 
									
										
										
										
											2018-08-28 17:56:48 +08:00
										 |  |  | 									allModules.add(chunkGraph.getModuleId(module)); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 								const removedModules = records.chunkModuleIds[chunkId].filter( | 
					
						
							|  |  |  | 									id => !allModules.has(id) | 
					
						
							|  |  |  | 								); | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 								if ( | 
					
						
							|  |  |  | 									newModules.length > 0 || | 
					
						
							|  |  |  | 									newRuntimeModules.length > 0 || | 
					
						
							|  |  |  | 									removedModules.length > 0 | 
					
						
							|  |  |  | 								) { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 									const hotUpdateChunk = new HotUpdateChunk(); | 
					
						
							| 
									
										
										
										
											2019-12-16 20:21:39 +08:00
										 |  |  | 									ChunkGraph.setChunkGraphForChunk(hotUpdateChunk, chunkGraph); | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 									hotUpdateChunk.id = chunkId; | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 									chunkGraph.attachModules(hotUpdateChunk, newModules); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 									chunkGraph.attachRuntimeModules( | 
					
						
							|  |  |  | 										hotUpdateChunk, | 
					
						
							|  |  |  | 										newRuntimeModules | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 									); | 
					
						
							| 
									
										
										
										
											2020-04-30 23:52:27 +08:00
										 |  |  | 									if (newFullHashModules) { | 
					
						
							|  |  |  | 										chunkGraph.attachFullHashModules( | 
					
						
							|  |  |  | 											hotUpdateChunk, | 
					
						
							| 
									
										
										
										
											2020-07-08 23:20:14 +08:00
										 |  |  | 											newFullHashModules | 
					
						
							| 
									
										
										
										
											2020-04-30 23:52:27 +08:00
										 |  |  | 										); | 
					
						
							|  |  |  | 									} | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 									hotUpdateChunk.removedModules = removedModules; | 
					
						
							| 
									
										
										
										
											2019-10-02 14:54:21 +08:00
										 |  |  | 									const renderManifest = compilation.getRenderManifest({ | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 										chunk: hotUpdateChunk, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 										hash: records.hash, | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 										fullHash: records.hash, | 
					
						
							| 
									
										
										
										
											2019-10-04 18:24:52 +08:00
										 |  |  | 										outputOptions: compilation.outputOptions, | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 										moduleTemplates: compilation.moduleTemplates, | 
					
						
							|  |  |  | 										dependencyTemplates: compilation.dependencyTemplates, | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 										codeGenerationResults: compilation.codeGenerationResults, | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 										runtimeTemplate: compilation.runtimeTemplate, | 
					
						
							|  |  |  | 										moduleGraph: compilation.moduleGraph, | 
					
						
							|  |  |  | 										chunkGraph | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 									}); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 									for (const entry of renderManifest) { | 
					
						
							| 
									
										
										
										
											2020-07-17 20:57:11 +08:00
										 |  |  | 										/** @type {string} */ | 
					
						
							|  |  |  | 										let filename; | 
					
						
							|  |  |  | 										/** @type {AssetInfo} */ | 
					
						
							|  |  |  | 										let assetInfo; | 
					
						
							|  |  |  | 										if ("filename" in entry) { | 
					
						
							|  |  |  | 											filename = entry.filename; | 
					
						
							|  |  |  | 											assetInfo = entry.info; | 
					
						
							|  |  |  | 										} else { | 
					
						
							|  |  |  | 											({ | 
					
						
							|  |  |  | 												path: filename, | 
					
						
							|  |  |  | 												info: assetInfo | 
					
						
							|  |  |  | 											} = compilation.getPathWithInfo( | 
					
						
							|  |  |  | 												entry.filenameTemplate, | 
					
						
							|  |  |  | 												entry.pathOptions | 
					
						
							|  |  |  | 											)); | 
					
						
							|  |  |  | 										} | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 										const source = entry.render(); | 
					
						
							|  |  |  | 										compilation.additionalChunkAssets.push(filename); | 
					
						
							| 
									
										
										
										
											2019-09-13 17:12:26 +08:00
										 |  |  | 										compilation.emitAsset(filename, source, { | 
					
						
							|  |  |  | 											hotModuleReplacement: true, | 
					
						
							|  |  |  | 											...assetInfo | 
					
						
							|  |  |  | 										}); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 									} | 
					
						
							|  |  |  | 									hotUpdateMainContent.c.push(chunkId); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 							} else { | 
					
						
							| 
									
										
										
										
											2020-01-15 17:43:58 +08:00
										 |  |  | 								const chunkId = `${+key}` === key ? +key : key; | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 								hotUpdateMainContent.r.push(chunkId); | 
					
						
							|  |  |  | 								for (const id of records.chunkModuleIds[chunkId]) | 
					
						
							|  |  |  | 									allRemovedModules.add(id); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 						hotUpdateMainContent.m = Array.from(allRemovedModules); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						const source = new RawSource(JSON.stringify(hotUpdateMainContent)); | 
					
						
							| 
									
										
										
										
											2019-09-11 17:13:46 +08:00
										 |  |  | 						const { | 
					
						
							|  |  |  | 							path: filename, | 
					
						
							|  |  |  | 							info: assetInfo | 
					
						
							| 
									
										
										
										
											2020-02-17 17:27:46 +08:00
										 |  |  | 						} = compilation.getPathWithInfo( | 
					
						
							|  |  |  | 							compilation.outputOptions.hotUpdateMainFilename, | 
					
						
							|  |  |  | 							{ | 
					
						
							|  |  |  | 								hash: records.hash | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											2019-09-13 17:12:26 +08:00
										 |  |  | 						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( | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 					.for("javascript/auto") | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 					.tap("HotModuleReplacementPlugin", parser => { | 
					
						
							|  |  |  | 						applyWebpackHash(parser); | 
					
						
							|  |  |  | 						applyModuleHot(parser); | 
					
						
							|  |  |  | 						applyImportMetaHot(parser); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				normalModuleFactory.hooks.parser | 
					
						
							|  |  |  | 					.for("javascript/dynamic") | 
					
						
							| 
									
										
										
										
											2020-06-23 05:53:13 +08:00
										 |  |  | 					.tap("HotModuleReplacementPlugin", parser => { | 
					
						
							|  |  |  | 						applyWebpackHash(parser); | 
					
						
							|  |  |  | 						applyModuleHot(parser); | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 				normalModuleFactory.hooks.parser | 
					
						
							|  |  |  | 					.for("javascript/esm") | 
					
						
							|  |  |  | 					.tap("HotModuleReplacementPlugin", parser => { | 
					
						
							|  |  |  | 						applyWebpackHash(parser); | 
					
						
							|  |  |  | 						applyImportMetaHot(parser); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-01-03 19:27:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | 				NormalModule.getCompilationHooks(compilation).loader.tap( | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					"HotModuleReplacementPlugin", | 
					
						
							|  |  |  | 					context => { | 
					
						
							|  |  |  | 						context.hot = true; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-06-18 02:57:32 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-31 00:54:54 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = HotModuleReplacementPlugin; |