| 
									
										
										
										
											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-01-08 14:15:46 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2018-04-04 15:17:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const DependencyReference = require("./dependencies/DependencyReference"); | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | /** @typedef {import("webpack-sources").Source} Source */ | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							|  |  |  | /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | /** @typedef {import("./WebpackError")} WebpackError */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("./util/createHash").Hash} Hash */ | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | /** @typedef {Object} SourcePosition | 
					
						
							| 
									
										
										
										
											2018-06-22 02:58:54 +08:00
										 |  |  |  *  @property {number} line | 
					
						
							| 
									
										
										
										
											2018-07-10 23:18:45 +08:00
										 |  |  |  *  @property {number=} column | 
					
						
							| 
									
										
										
										
											2018-06-22 02:58:54 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | /** @typedef {Object} RealDependencyLocation | 
					
						
							|  |  |  |  *  @property {SourcePosition} start | 
					
						
							| 
									
										
										
										
											2018-07-10 23:18:45 +08:00
										 |  |  |  *  @property {SourcePosition=} end | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  |  *  @property {number=} index | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** @typedef {Object} SynteticDependencyLocation | 
					
						
							|  |  |  |  *  @property {string} name | 
					
						
							| 
									
										
										
										
											2018-07-10 23:18:45 +08:00
										 |  |  |  *  @property {number=} index | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | /** @typedef {SynteticDependencyLocation|RealDependencyLocation} DependencyLocation */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} ExportsSpec | 
					
						
							|  |  |  |  * @property {string[] | true | null} exports exported names, true for unknown exports or null for no exports | 
					
						
							|  |  |  |  * @property {Module[]=} dependencies module on which the result depends on | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | class Dependency { | 
					
						
							|  |  |  | 	constructor() { | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Module|null} */ | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 		this.module = null; | 
					
						
							| 
									
										
										
										
											2018-06-08 19:21:06 +08:00
										 |  |  | 		// TODO remove in webpack 5
 | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | 		/** @type {boolean} */ | 
					
						
							| 
									
										
										
										
											2017-08-08 15:28:34 +08:00
										 |  |  | 		this.weak = false; | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | 		/** @type {boolean} */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this.optional = false; | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | 		/** @type {DependencyLocation} */ | 
					
						
							| 
									
										
										
										
											2018-03-28 13:27:05 +08:00
										 |  |  | 		this.loc = undefined; | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string} a display name for the type of dependency | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	get type() { | 
					
						
							|  |  |  | 		return "unknown"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string | null} an identifier to merge equal requests | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 	getResourceIdentifier() { | 
					
						
							|  |  |  | 		return null; | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Returns the referenced module and export | 
					
						
							|  |  |  | 	 * @returns {DependencyReference} reference | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 	getReference() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!this.module) return null; | 
					
						
							| 
									
										
										
										
											2018-07-23 03:01:05 +08:00
										 |  |  | 		return new DependencyReference(() => this.module, true, this.weak); | 
					
						
							| 
									
										
										
										
											2015-10-22 03:05:01 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-06-24 07:51:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Returns the exported names | 
					
						
							|  |  |  | 	 * @returns {ExportsSpec | undefined} export names | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 	getExports() { | 
					
						
							|  |  |  | 		return null; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-09-06 05:41:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Returns warnings | 
					
						
							|  |  |  | 	 * @returns {WebpackError[]} warnings | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 	getWarnings() { | 
					
						
							|  |  |  | 		return null; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-10-22 03:05:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Returns errors | 
					
						
							|  |  |  | 	 * @returns {WebpackError[]} errors | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-10 00:11:34 +08:00
										 |  |  | 	getErrors() { | 
					
						
							|  |  |  | 		return null; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Update the hash | 
					
						
							|  |  |  | 	 * @param {Hash} hash hash to be updated | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 	updateHash(hash) { | 
					
						
							|  |  |  | 		hash.update((this.module && this.module.id) + ""); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 15:33:48 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Disconnect the dependency from the graph | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | 	disconnect() { | 
					
						
							|  |  |  | 		this.module = null; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-07-09 14:48:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 14:15:46 +08:00
										 |  |  | module.exports = Dependency; |