| 
									
										
										
										
											2013-01-31 01:49:25 +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-04-04 05:22:23 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | const ChunkGraph = require("./ChunkGraph"); | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | const DependenciesBlock = require("./DependenciesBlock"); | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | const ModuleGraph = require("./ModuleGraph"); | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | const Template = require("./Template"); | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | const { compareChunksById } = require("./util/comparators"); | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | const makeSerializable = require("./util/makeSerializable"); | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("webpack-sources").Source} Source */ | 
					
						
							| 
									
										
										
										
											2018-04-21 07:51:40 +08:00
										 |  |  | /** @typedef {import("./Chunk")} Chunk */ | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | /** @typedef {import("./ChunkGroup")} ChunkGroup */ | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | /** @typedef {import("./Compilation")} Compilation */ | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | /** @typedef {import("./Dependency")} Dependency */ | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | /** @typedef {import("./FileSystemInfo")} FileSystemInfo */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("./RequestShortener")} RequestShortener */ | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | /** @typedef {import("./WebpackError")} WebpackError */ | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | /** @template T @typedef {import("./util/SortableSet")<T>} SortableSet<T> */ | 
					
						
							| 
									
										
										
										
											2018-07-21 00:17:51 +08:00
										 |  |  | /** @typedef {import("./util/createHash").Hash} Hash */ | 
					
						
							| 
									
										
										
										
											2018-04-12 15:18:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:57:03 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} SourceContext | 
					
						
							|  |  |  |  * @property {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  |  * @property {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  |  * @property {ModuleGraph} moduleGraph the module graph | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  |  * @property {ChunkGraph} chunkGraph the chunk graph | 
					
						
							| 
									
										
										
										
											2018-07-18 00:57:03 +08:00
										 |  |  |  * @property {string=} type the type of source that should be generated | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} LibIdentOptions | 
					
						
							|  |  |  |  * @property {string} context absolute context path to which lib ident is relative to | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} KnownBuildMeta | 
					
						
							|  |  |  |  * @property {(boolean | string[])=} providedExports | 
					
						
							|  |  |  |  * @property {("named" | "namespace")=} exportsType | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} NeedBuildContext | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  |  * @property {FileSystemInfo} fileSystemInfo | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | /** @typedef {KnownBuildMeta & Record<string, any>} BuildMeta */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-17 21:26:23 +08:00
										 |  |  | const EMPTY_RESOLVE_OPTIONS = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | let debugId = 1000; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | const getIndexMap = set => { | 
					
						
							|  |  |  | 	set.sort(); | 
					
						
							|  |  |  | 	const map = new Map(); | 
					
						
							|  |  |  | 	let idx = 0; | 
					
						
							|  |  |  | 	for (const item of set) { | 
					
						
							|  |  |  | 		map.set(item, idx++); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return map; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const getJoinedString = set => { | 
					
						
							|  |  |  | 	set.sort(); | 
					
						
							|  |  |  | 	return Array.from(set).join(","); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-03 22:00:32 +08:00
										 |  |  | const DEFAULT_TYPES = new Set(["javascript"]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-12 15:18:53 +08:00
										 |  |  | /** @typedef {(requestShortener: RequestShortener) => string} OptimizationBailoutFunction */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-19 20:13:44 +08:00
										 |  |  | class Module extends DependenciesBlock { | 
					
						
							| 
									
										
										
										
											2018-11-07 21:03:25 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {string} type the module type | 
					
						
							|  |  |  | 	 * @param {string=} context an optional context | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-01-31 04:40:44 +08:00
										 |  |  | 	constructor(type, context = null) { | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2018-11-07 21:03:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-12 15:18:53 +08:00
										 |  |  | 		/** @type {string} */ | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 		this.type = type; | 
					
						
							| 
									
										
										
										
											2018-04-12 15:18:53 +08:00
										 |  |  | 		/** @type {string} */ | 
					
						
							| 
									
										
										
										
											2018-01-31 04:40:44 +08:00
										 |  |  | 		this.context = context; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Unique Id
 | 
					
						
							| 
									
										
										
										
											2018-04-12 15:18:53 +08:00
										 |  |  | 		/** @type {number} */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this.debugId = debugId++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Info from Factory
 | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 		/** @type {TODO} */ | 
					
						
							| 
									
										
										
										
											2017-11-17 21:26:23 +08:00
										 |  |  | 		this.resolveOptions = EMPTY_RESOLVE_OPTIONS; | 
					
						
							| 
									
										
										
										
											2018-04-12 15:18:53 +08:00
										 |  |  | 		/** @type {object} */ | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 		this.factoryMeta = {}; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Info from Build
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {WebpackError[]} */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this.warnings = []; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {WebpackError[]} */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this.errors = []; | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 		/** @type {BuildMeta} */ | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 		this.buildMeta = undefined; | 
					
						
							| 
									
										
										
										
											2018-04-12 15:18:53 +08:00
										 |  |  | 		/** @type {object} */ | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 		this.buildInfo = undefined; | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 	// TODO remove in webpack 6
 | 
					
						
							|  |  |  | 	// BACKWARD-COMPAT START
 | 
					
						
							| 
									
										
										
										
											2018-08-28 17:56:48 +08:00
										 |  |  | 	get id() { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule(this, "Module.id").getModuleId( | 
					
						
							|  |  |  | 			this | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set id(value) { | 
					
						
							|  |  |  | 		ChunkGraph.getChunkGraphForModule(this, "Module.id").setModuleId( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			value | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string} the hash of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	get hash() { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule(this, "Module.hash").getModuleHash( | 
					
						
							|  |  |  | 			this | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string} the shortened hash of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	get renderedHash() { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.renderedHash" | 
					
						
							|  |  |  | 		).getRenderedModuleHash(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 	get profile() { | 
					
						
							|  |  |  | 		return ModuleGraph.getModuleGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.profile" | 
					
						
							|  |  |  | 		).getProfile(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set profile(value) { | 
					
						
							|  |  |  | 		ModuleGraph.getModuleGraphForModule(this, "Module.profile").setProfile( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			value | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 22:12:00 +08:00
										 |  |  | 	get index() { | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 		return ModuleGraph.getModuleGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.index" | 
					
						
							|  |  |  | 		).getPreOrderIndex(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set index(value) { | 
					
						
							|  |  |  | 		ModuleGraph.getModuleGraphForModule(this, "Module.index").setPreOrderIndex( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			value | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-08-21 22:12:00 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get index2() { | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 		return ModuleGraph.getModuleGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.index2" | 
					
						
							|  |  |  | 		).getPostOrderIndex(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set index2(value) { | 
					
						
							|  |  |  | 		ModuleGraph.getModuleGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.index2" | 
					
						
							|  |  |  | 		).setPostOrderIndex(this, value); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 01:16:02 +08:00
										 |  |  | 	get depth() { | 
					
						
							|  |  |  | 		return ModuleGraph.getModuleGraphForModule(this, "Module.depth").getDepth( | 
					
						
							|  |  |  | 			this | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set depth(value) { | 
					
						
							|  |  |  | 		ModuleGraph.getModuleGraphForModule(this, "Module.depth").setDepth( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			value | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 	get issuer() { | 
					
						
							|  |  |  | 		return ModuleGraph.getModuleGraphForModule(this, "Module.issuer").getIssuer( | 
					
						
							|  |  |  | 			this | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set issuer(value) { | 
					
						
							|  |  |  | 		ModuleGraph.getModuleGraphForModule(this, "Module.issuer").setIssuer( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			value | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get usedExports() { | 
					
						
							|  |  |  | 		return ModuleGraph.getModuleGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.usedExports" | 
					
						
							|  |  |  | 		).getUsedExports(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set usedExports(value) { | 
					
						
							|  |  |  | 		ModuleGraph.getModuleGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.usedExports" | 
					
						
							|  |  |  | 		).setUsedExports(this, value); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get optimizationBailout() { | 
					
						
							|  |  |  | 		return ModuleGraph.getModuleGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.optimizationBailout" | 
					
						
							|  |  |  | 		).getOptimizationBailout(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get optional() { | 
					
						
							|  |  |  | 		return this.isOptional( | 
					
						
							|  |  |  | 			ModuleGraph.getModuleGraphForModule(this, "Module.optional") | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	addChunk(chunk) { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.addChunk" | 
					
						
							|  |  |  | 		).connectChunkAndModule(chunk, this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	removeChunk(chunk) { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.removeChunk" | 
					
						
							|  |  |  | 		).disconnectChunkAndModule(chunk, this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	isInChunk(chunk) { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.isInChunk" | 
					
						
							|  |  |  | 		).isModuleInChunk(this, chunk); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	isEntryModule() { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.isEntryModule" | 
					
						
							|  |  |  | 		).isEntryModule(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	getChunks() { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.getChunks" | 
					
						
							|  |  |  | 		).getModuleChunks(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	getNumberOfChunks() { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.getNumberOfChunks" | 
					
						
							|  |  |  | 		).getNumberOfModuleChunks(this); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get chunksIterable() { | 
					
						
							|  |  |  | 		return ChunkGraph.getChunkGraphForModule( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			"Module.chunksIterable" | 
					
						
							|  |  |  | 		).getOrderedModuleChunksIterable(this, compareChunksById); | 
					
						
							| 
									
										
										
										
											2018-08-21 22:12:00 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 	// BACKWARD-COMPAT END
 | 
					
						
							| 
									
										
										
										
											2018-08-21 22:12:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @deprecated moved to .buildInfo.exportsArgument | 
					
						
							|  |  |  | 	 * @returns {string} name of the exports argument | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 	get exportsArgument() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		return (this.buildInfo && this.buildInfo.exportsArgument) || "exports"; | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @deprecated moved to .buildInfo.moduleArgument | 
					
						
							|  |  |  | 	 * @returns {string} name of the module argument | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 	get moduleArgument() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		return (this.buildInfo && this.buildInfo.moduleArgument) || "module"; | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	 * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	 * @returns {boolean} true, if the module is optional | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	isOptional(moduleGraph) { | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		const connections = moduleGraph.getIncomingConnections(this); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		return ( | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 			connections.length > 0 && | 
					
						
							|  |  |  | 			connections.every(r => r.dependency && r.dependency.optional) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-02 22:18:49 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 	 * @param {ChunkGraph} chunkGraph the chunk graph | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	 * @param {Chunk} chunk a chunk | 
					
						
							|  |  |  | 	 * @param {Chunk=} ignoreChunk chunk to be ignored | 
					
						
							|  |  |  | 	 * @returns {boolean} true, if the module is accessible from "chunk" when ignoring "ignoreChunk" | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 	isAccessibleInChunk(chunkGraph, chunk, ignoreChunk) { | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 		// Check if module is accessible in ALL chunk groups
 | 
					
						
							|  |  |  | 		for (const chunkGroup of chunk.groupsIterable) { | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 			if (!this.isAccessibleInChunkGroup(chunkGraph, chunkGroup)) return false; | 
					
						
							| 
									
										
										
										
											2014-09-08 04:54:38 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-05-17 06:31:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 	 * @param {ChunkGraph} chunkGraph the chunk graph | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	 * @param {ChunkGroup} chunkGroup a chunk group | 
					
						
							|  |  |  | 	 * @param {Chunk=} ignoreChunk chunk to be ignored | 
					
						
							|  |  |  | 	 * @returns {boolean} true, if the module is accessible from "chunkGroup" when ignoring "ignoreChunk" | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 	isAccessibleInChunkGroup(chunkGraph, chunkGroup, ignoreChunk) { | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 		const queue = new Set([chunkGroup]); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 		// Check if module is accessible from all items of the queue
 | 
					
						
							|  |  |  | 		queueFor: for (const cg of queue) { | 
					
						
							|  |  |  | 			// 1. If module is in one of the chunks of the group we can continue checking the next items
 | 
					
						
							|  |  |  | 			//    because it's accessible.
 | 
					
						
							|  |  |  | 			for (const chunk of cg.chunks) { | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 				if (chunk !== ignoreChunk && chunkGraph.isModuleInChunk(this, chunk)) | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 					continue queueFor; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			// 2. If the chunk group is initial, we can break here because it's not accessible.
 | 
					
						
							|  |  |  | 			if (chunkGroup.isInitial()) return false; | 
					
						
							|  |  |  | 			// 3. Enqueue all parents because it must be accessible from ALL parents
 | 
					
						
							|  |  |  | 			for (const parent of chunkGroup.parentsIterable) queue.add(parent); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 		// When we processed through the whole list and we didn't bailout, the module is accessible
 | 
					
						
							|  |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2017-11-25 00:22:58 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Chunk} chunk a chunk | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	 * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 	 * @param {ChunkGraph} chunkGraph the chunk graph | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	 * @returns {boolean} true, if the module has any reason why "chunk" should be included | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 	hasReasonForChunk(chunk, moduleGraph, chunkGraph) { | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 		// check for each reason if we need the chunk
 | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		for (const connection of moduleGraph.getIncomingConnections(this)) { | 
					
						
							|  |  |  | 			const fromModule = connection.originModule; | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 			for (const originChunk of chunkGraph.getModuleChunksIterable( | 
					
						
							|  |  |  | 				fromModule | 
					
						
							|  |  |  | 			)) { | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 				// return true if module this is not reachable from originChunk when ignoring cunk
 | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 				if (!this.isAccessibleInChunk(chunkGraph, originChunk, chunk)) | 
					
						
							|  |  |  | 					return true; | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-06-14 00:58:14 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-01-22 19:34:34 +08:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	 * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							|  |  |  | 	 * @returns {boolean} true if at least one other module depends on this module | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	hasReasons(moduleGraph) { | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		return moduleGraph.getIncomingConnections(this).length > 0; | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 	 * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:24 +08:00
										 |  |  | 	 * @returns {boolean} true, if the module is used | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	isModuleUsed(moduleGraph) { | 
					
						
							| 
									
										
										
										
											2018-08-16 19:55:41 +08:00
										 |  |  | 		return moduleGraph.getUsedExports(this) !== false; | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:24 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							|  |  |  | 	 * @param {string} exportName a name of an export | 
					
						
							|  |  |  | 	 * @returns {boolean} true, if the export is used | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	isExportUsed(moduleGraph, exportName) { | 
					
						
							| 
									
										
										
										
											2018-08-16 19:55:41 +08:00
										 |  |  | 		const usedExports = moduleGraph.getUsedExports(this); | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:24 +08:00
										 |  |  | 		if (usedExports === null || usedExports === true) return true; | 
					
						
							|  |  |  | 		if (usedExports === false) return false; | 
					
						
							|  |  |  | 		return usedExports.has(exportName); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							|  |  |  | 	 * @param {string} exportName a name of an export | 
					
						
							|  |  |  | 	 * @returns {string | false} false, when module or referenced export is unused. | 
					
						
							|  |  |  | 	 *                           string, the mangled export name when used. | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:24 +08:00
										 |  |  | 	getUsedName(moduleGraph, exportName) { | 
					
						
							| 
									
										
										
										
											2018-08-16 19:55:41 +08:00
										 |  |  | 		const usedExports = moduleGraph.getUsedExports(this); | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:24 +08:00
										 |  |  | 		if (usedExports === null || usedExports === true) return exportName; | 
					
						
							|  |  |  | 		if (usedExports === false) return false; | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 		if (!usedExports.has(exportName)) return false; | 
					
						
							| 
									
										
										
										
											2017-12-23 01:23:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Mangle export name if possible
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this.isProvided(exportName)) { | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			if (this.buildMeta.exportsType === "namespace") { | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:24 +08:00
										 |  |  | 				const idx = usedExports | 
					
						
							|  |  |  | 					.getFromUnorderedCache(getIndexMap) | 
					
						
							|  |  |  | 					.get(exportName); | 
					
						
							| 
									
										
										
										
											2017-12-23 01:23:20 +08:00
										 |  |  | 				return Template.numberToIdentifer(idx); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			if ( | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				this.buildMeta.exportsType === "named" && | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 				!usedExports.has("default") | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			) { | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:24 +08:00
										 |  |  | 				const idx = usedExports | 
					
						
							|  |  |  | 					.getFromUnorderedCache(getIndexMap) | 
					
						
							|  |  |  | 					.get(exportName); | 
					
						
							| 
									
										
										
										
											2017-12-23 01:23:20 +08:00
										 |  |  | 				return Template.numberToIdentifer(idx); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-12-23 01:23:20 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 		return exportName; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {string} exportName a name of an export | 
					
						
							|  |  |  | 	 * @returns {boolean | null} true, if the export is provided why the module. | 
					
						
							|  |  |  | 	 *                           null, if it's unknown. | 
					
						
							|  |  |  | 	 *                           false, if it's not provided. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	isProvided(exportName) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!Array.isArray(this.buildMeta.providedExports)) return null; | 
					
						
							| 
									
										
										
										
											2018-01-12 00:58:39 +08:00
										 |  |  | 		return this.buildMeta.providedExports.includes(exportName); | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string} for debugging | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	toString() { | 
					
						
							| 
									
										
										
										
											2018-08-28 17:50:33 +08:00
										 |  |  | 		return `Module[${this.debugId}: ${this.identifier()}]`; | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | 	 * @param {NeedBuildContext} context context info | 
					
						
							|  |  |  | 	 * @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | 	needBuild(context, callback) { | 
					
						
							|  |  |  | 		callback( | 
					
						
							|  |  |  | 			null, | 
					
						
							|  |  |  | 			!this.buildMeta || | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 				this.needRebuild === Module.prototype.needRebuild || | 
					
						
							|  |  |  | 				this.needRebuild( | 
					
						
							|  |  |  | 					context.fileSystemInfo.getDeprecatedFileTimestamps(), | 
					
						
							|  |  |  | 					context.fileSystemInfo.getDeprecatedContextTimestamps() | 
					
						
							|  |  |  | 				) | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @deprecated Use needBuild instead | 
					
						
							|  |  |  | 	 * @param {TODO} fileTimestamps timestamps of files | 
					
						
							|  |  |  | 	 * @param {TODO} contextTimestamps timestamps of directories | 
					
						
							|  |  |  | 	 * @returns {boolean} true, if the module needs a rebuild | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	needRebuild(fileTimestamps, contextTimestamps) { | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-21 00:17:51 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Hash} hash the hash used to track dependencies | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 	 * @param {ChunkGraph} chunkGraph the chunk graph | 
					
						
							| 
									
										
										
										
											2018-07-21 00:17:51 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 	updateHash(hash, chunkGraph) { | 
					
						
							| 
									
										
										
										
											2018-08-28 17:56:48 +08:00
										 |  |  | 		hash.update(`${chunkGraph.getModuleId(this)}`); | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 		const usedExports = chunkGraph.moduleGraph.getUsedExports(this); | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 		if (typeof usedExports === "boolean") { | 
					
						
							|  |  |  | 			hash.update(JSON.stringify(usedExports)); | 
					
						
							|  |  |  | 		} else if (!usedExports) { | 
					
						
							|  |  |  | 			hash.update("null"); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			hash.update(usedExports.getFromUnorderedCache(getJoinedString)); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 		super.updateHash(hash, chunkGraph); | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:38:34 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	invalidateBuild() { | 
					
						
							|  |  |  | 		// should be overriden to support this feature
 | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @abstract | 
					
						
							|  |  |  | 	 * @returns {string} a unique identifier of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	identifier() { | 
					
						
							|  |  |  | 		throw new Error("Module.identifier: Must be overriden"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @abstract | 
					
						
							|  |  |  | 	 * @param {RequestShortener} requestShortener the request shortener | 
					
						
							|  |  |  | 	 * @returns {string} a user readable identifier of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	readableIdentifier(requestShortener) { | 
					
						
							|  |  |  | 		throw new Error("Module.readableIdentifier: Must be overriden"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @abstract | 
					
						
							|  |  |  | 	 * @param {TODO} options TODO | 
					
						
							|  |  |  | 	 * @param {Compilation} compilation the compilation | 
					
						
							|  |  |  | 	 * @param {TODO} resolver TODO | 
					
						
							|  |  |  | 	 * @param {TODO} fs the file system | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {function(WebpackError=): void} callback callback function | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	build(options, compilation, resolver, fs, callback) { | 
					
						
							|  |  |  | 		throw new Error("Module.build: Must be overriden"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-03 22:00:32 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @abstract | 
					
						
							|  |  |  | 	 * @returns {Set<string>} types availiable (do not mutate) | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	getSourceTypes() { | 
					
						
							|  |  |  | 		return DEFAULT_TYPES; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @abstract | 
					
						
							| 
									
										
										
										
											2018-07-18 00:57:03 +08:00
										 |  |  | 	 * @param {SourceContext} sourceContext source context | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 * @returns {Source} generated source | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-18 00:57:03 +08:00
										 |  |  | 	source(sourceContext) { | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 		throw new Error("Module.source: Must be overriden"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @abstract | 
					
						
							| 
									
										
										
										
											2018-12-04 18:23:40 +08:00
										 |  |  | 	 * @param {string=} type the source type for which the size should be estimated | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 * @returns {number} the estimated size of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-12-04 18:23:40 +08:00
										 |  |  | 	size(type) { | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 		throw new Error("Module.size: Must be overriden"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-06 22:37:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {LibIdentOptions} options options | 
					
						
							|  |  |  | 	 * @returns {string | null} an identifier for library inclusion | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	libIdent(options) { | 
					
						
							|  |  |  | 		return null; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string | null} absolute path which should be used for condition matching (usually the resource path) | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	nameForCondition() { | 
					
						
							|  |  |  | 		return null; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-06 22:37:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Get a list of runtime requirements | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 	 * @param {SourceContext} context context for code generation | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 	 * @returns {Iterable<string> | null} required runtime modules | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 	getRuntimeRequirements(context) { | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 		return null; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Chunk} chunk the chunk which condition should be checked | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 	 * @param {Compilation} compilation the compilation | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 * @returns {boolean} true, if the chunk is ok for the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 	chunkCondition(chunk, compilation) { | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Assuming this module is in the cache. Update the (cached) module with | 
					
						
							|  |  |  | 	 * the fresh module from the factory. Usually updates internal references | 
					
						
							|  |  |  | 	 * and properties. | 
					
						
							|  |  |  | 	 * @param {Module} module fresh module | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	updateCacheModule(module) { | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 		this.type = module.type; | 
					
						
							|  |  |  | 		this.context = module.context; | 
					
						
							|  |  |  | 		this.factoryMeta = module.factoryMeta; | 
					
						
							|  |  |  | 		this.resolveOptions = module.resolveOptions; | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-25 18:20:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {Source | null} the original source for the module before webpack transformation | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	originalSource() { | 
					
						
							|  |  |  | 		return null; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	serialize(context) { | 
					
						
							|  |  |  | 		const { write } = context; | 
					
						
							|  |  |  | 		write(this.type); | 
					
						
							|  |  |  | 		write(this.context); | 
					
						
							|  |  |  | 		write(this.resolveOptions); | 
					
						
							|  |  |  | 		write(this.factoryMeta); | 
					
						
							|  |  |  | 		write(this.useSourceMap); | 
					
						
							|  |  |  | 		write(this.warnings); | 
					
						
							|  |  |  | 		write(this.errors); | 
					
						
							|  |  |  | 		write(this.buildMeta); | 
					
						
							|  |  |  | 		write(this.buildInfo); | 
					
						
							|  |  |  | 		super.serialize(context); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	deserialize(context) { | 
					
						
							|  |  |  | 		const { read } = context; | 
					
						
							|  |  |  | 		this.type = read(); | 
					
						
							|  |  |  | 		this.context = read(); | 
					
						
							|  |  |  | 		this.resolveOptions = read(); | 
					
						
							|  |  |  | 		this.factoryMeta = read(); | 
					
						
							|  |  |  | 		this.useSourceMap = read(); | 
					
						
							|  |  |  | 		this.warnings = read(); | 
					
						
							|  |  |  | 		this.errors = read(); | 
					
						
							|  |  |  | 		this.buildMeta = read(); | 
					
						
							|  |  |  | 		this.buildInfo = read(); | 
					
						
							|  |  |  | 		super.deserialize(context); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | makeSerializable(Module, "webpack/lib/Module"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-08 22:29:15 +08:00
										 |  |  | Object.defineProperty(Module.prototype, "hasEqualsChunks", { | 
					
						
							|  |  |  | 	get() { | 
					
						
							|  |  |  | 		throw new Error( | 
					
						
							|  |  |  | 			"Module.hasEqualsChunks was renamed (use hasEqualChunks instead)" | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:46 +08:00
										 |  |  | Object.defineProperty(Module.prototype, "isUsed", { | 
					
						
							|  |  |  | 	get() { | 
					
						
							|  |  |  | 		throw new Error( | 
					
						
							|  |  |  | 			"Module.isUsed was renamed (use getUsedName, isExportUsed or isModuleUsed instead)" | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Object.defineProperty(Module.prototype, "used", { | 
					
						
							|  |  |  | 	get() { | 
					
						
							| 
									
										
										
										
											2018-08-16 19:55:41 +08:00
										 |  |  | 		throw new Error( | 
					
						
							|  |  |  | 			"Module.used was refactored (use ModuleGraph.getUsedExports instead)" | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:46 +08:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 	set(value) { | 
					
						
							| 
									
										
										
										
											2018-08-16 19:55:41 +08:00
										 |  |  | 		throw new Error( | 
					
						
							|  |  |  | 			"Module.used was refactored (use ModuleGraph.setUsedExports instead)" | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:46 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Object.defineProperty(Module.prototype, "usedExports", { | 
					
						
							|  |  |  | 	get() { | 
					
						
							|  |  |  | 		throw new Error( | 
					
						
							| 
									
										
										
										
											2018-08-16 19:55:41 +08:00
										 |  |  | 			"Module.usedExports was refactored (use ModuleGraph.getUsedExports instead)" | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:46 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set(value) { | 
					
						
							|  |  |  | 		throw new Error( | 
					
						
							| 
									
										
										
										
											2018-08-16 19:55:41 +08:00
										 |  |  | 			"Module.usedExports was refactored (use ModuleGraph.setUsedExports instead)" | 
					
						
							| 
									
										
										
										
											2018-08-07 03:01:46 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-04 05:22:23 +08:00
										 |  |  | module.exports = Module; |