| 
									
										
										
										
											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-09 04:07:41 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-09 04:07:41 +08:00
										 |  |  | const DependenciesBlock = require("./DependenciesBlock"); | 
					
						
							| 
									
										
										
										
											2018-10-18 17:57:14 +08:00
										 |  |  | const makeSerializable = require("./util/makeSerializable"); | 
					
						
							| 
									
										
										
										
											2017-01-09 04:07:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | /** @typedef {import("./ChunkGraph")} ChunkGraph */ | 
					
						
							| 
									
										
										
										
											2019-06-14 17:44:54 +08:00
										 |  |  | /** @typedef {import("./ChunkGroup")} ChunkGroup */ | 
					
						
							|  |  |  | /** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */ | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | 
					
						
							| 
									
										
										
										
											2020-07-28 00:09:48 +08:00
										 |  |  | /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */ | 
					
						
							| 
									
										
										
										
											2020-09-08 00:02:14 +08:00
										 |  |  | /** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */ | 
					
						
							| 
									
										
										
										
											2019-06-14 17:44:54 +08:00
										 |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							| 
									
										
										
										
											2023-04-12 02:57:43 +08:00
										 |  |  | /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | 
					
						
							|  |  |  | /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | 
					
						
							| 
									
										
										
										
											2019-07-17 22:02:33 +08:00
										 |  |  | /** @typedef {import("./util/Hash")} Hash */ | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | class AsyncDependenciesBlock extends DependenciesBlock { | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2023-06-17 06:33:17 +08:00
										 |  |  | 	 * @param {(ChunkGroupOptions & { entryOptions?: EntryOptions }) | null} groupOptions options for the group | 
					
						
							|  |  |  | 	 * @param {(DependencyLocation | null)=} loc the line of code | 
					
						
							| 
									
										
										
										
											2023-06-17 02:49:43 +08:00
										 |  |  | 	 * @param {(string | null)=} request the request | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-10-18 04:58:30 +08:00
										 |  |  | 	constructor(groupOptions, loc, request) { | 
					
						
							| 
									
										
										
										
											2017-01-09 04:07:41 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 		if (typeof groupOptions === "string") { | 
					
						
							|  |  |  | 			groupOptions = { name: groupOptions }; | 
					
						
							|  |  |  | 		} else if (!groupOptions) { | 
					
						
							|  |  |  | 			groupOptions = { name: undefined }; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		this.groupOptions = groupOptions; | 
					
						
							| 
									
										
										
										
											2017-01-09 04:07:41 +08:00
										 |  |  | 		this.loc = loc; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this.request = request; | 
					
						
							| 
									
										
										
										
											2021-09-24 16:10:13 +08:00
										 |  |  | 		this._stringifiedGroupOptions = undefined; | 
					
						
							| 
									
										
										
										
											2017-01-09 22:09:29 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2023-05-26 02:31:28 +08:00
										 |  |  | 	 * @returns {string | undefined} The name of the chunk | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 	get chunkName() { | 
					
						
							|  |  |  | 		return this.groupOptions.name; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2023-05-26 02:31:28 +08:00
										 |  |  | 	 * @param {string | undefined} value The new chunk name | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 	set chunkName(value) { | 
					
						
							| 
									
										
										
										
											2021-09-24 16:10:13 +08:00
										 |  |  | 		if (this.groupOptions.name !== value) { | 
					
						
							|  |  |  | 			this.groupOptions.name = value; | 
					
						
							|  |  |  | 			this._stringifiedGroupOptions = undefined; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-07-23 23:25:38 +08:00
										 |  |  | 	 * @param {Hash} hash the hash used to track dependencies | 
					
						
							| 
									
										
										
										
											2020-07-28 00:09:48 +08:00
										 |  |  | 	 * @param {UpdateHashContext} context context | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2020-07-28 00:09:48 +08:00
										 |  |  | 	updateHash(hash, context) { | 
					
						
							|  |  |  | 		const { chunkGraph } = context; | 
					
						
							| 
									
										
										
										
											2021-09-24 16:10:13 +08:00
										 |  |  | 		if (this._stringifiedGroupOptions === undefined) { | 
					
						
							|  |  |  | 			this._stringifiedGroupOptions = JSON.stringify(this.groupOptions); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 		const chunkGroup = chunkGraph.getBlockChunkGroup(this); | 
					
						
							| 
									
										
										
										
											2021-09-26 08:15:41 +08:00
										 |  |  | 		hash.update( | 
					
						
							|  |  |  | 			`${this._stringifiedGroupOptions}${chunkGroup ? chunkGroup.id : ""}` | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2020-07-28 00:09:48 +08:00
										 |  |  | 		super.updateHash(hash, context); | 
					
						
							| 
									
										
										
										
											2017-01-09 04:07:41 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-18 17:57:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 02:57:43 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ObjectSerializerContext} context context | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-10-18 17:57:14 +08:00
										 |  |  | 	serialize(context) { | 
					
						
							|  |  |  | 		const { write } = context; | 
					
						
							|  |  |  | 		write(this.groupOptions); | 
					
						
							|  |  |  | 		write(this.loc); | 
					
						
							|  |  |  | 		write(this.request); | 
					
						
							|  |  |  | 		super.serialize(context); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 02:57:43 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ObjectDeserializerContext} context context | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-10-18 17:57:14 +08:00
										 |  |  | 	deserialize(context) { | 
					
						
							|  |  |  | 		const { read } = context; | 
					
						
							|  |  |  | 		this.groupOptions = read(); | 
					
						
							|  |  |  | 		this.loc = read(); | 
					
						
							|  |  |  | 		this.request = read(); | 
					
						
							|  |  |  | 		super.deserialize(context); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-18 17:57:14 +08:00
										 |  |  | makeSerializable(AsyncDependenciesBlock, "webpack/lib/AsyncDependenciesBlock"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | Object.defineProperty(AsyncDependenciesBlock.prototype, "module", { | 
					
						
							|  |  |  | 	get() { | 
					
						
							|  |  |  | 		throw new Error( | 
					
						
							|  |  |  | 			"module property was removed from AsyncDependenciesBlock (it's not needed)" | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set() { | 
					
						
							|  |  |  | 		throw new Error( | 
					
						
							|  |  |  | 			"module property was removed from AsyncDependenciesBlock (it's not needed)" | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | module.exports = AsyncDependenciesBlock; |