| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2017-01-24 03:31:53 +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-06 01:00:36 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-11 12:27:09 +08:00
										 |  |  | const asyncLib = require("neo-async"); | 
					
						
							| 
									
										
										
										
											2018-03-22 19:05:58 +08:00
										 |  |  | const { | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 	HookMap, | 
					
						
							| 
									
										
										
										
											2018-03-22 19:05:58 +08:00
										 |  |  | 	SyncHook, | 
					
						
							|  |  |  | 	SyncBailHook, | 
					
						
							|  |  |  | 	SyncWaterfallHook, | 
					
						
							|  |  |  | 	AsyncSeriesHook | 
					
						
							|  |  |  | } = require("tapable"); | 
					
						
							| 
									
										
										
										
											2018-11-13 21:45:26 +08:00
										 |  |  | const util = require("util"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const { CachedSource } = require("webpack-sources"); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | const Chunk = require("./Chunk"); | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | const ChunkGraph = require("./ChunkGraph"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const ChunkGroup = require("./ChunkGroup"); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | const ChunkRenderError = require("./ChunkRenderError"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const ChunkTemplate = require("./ChunkTemplate"); | 
					
						
							|  |  |  | const DependencyTemplates = require("./DependencyTemplates"); | 
					
						
							|  |  |  | const Entrypoint = require("./Entrypoint"); | 
					
						
							| 
									
										
										
										
											2019-07-24 16:51:04 +08:00
										 |  |  | const ErrorHelpers = require("./ErrorHelpers"); | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | const FileSystemInfo = require("./FileSystemInfo"); | 
					
						
							| 
									
										
										
										
											2019-07-25 14:07:55 +08:00
										 |  |  | const { connectChunkGroupAndChunk } = require("./GraphHelpers"); | 
					
						
							| 
									
										
										
										
											2019-05-10 17:06:25 +08:00
										 |  |  | const { makeWebpackError } = require("./HookWebpackError"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const MainTemplate = require("./MainTemplate"); | 
					
						
							|  |  |  | const ModuleDependencyError = require("./ModuleDependencyError"); | 
					
						
							|  |  |  | const ModuleDependencyWarning = require("./ModuleDependencyWarning"); | 
					
						
							| 
									
										
										
										
											2018-07-17 22:41:07 +08:00
										 |  |  | const ModuleGraph = require("./ModuleGraph"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const ModuleNotFoundError = require("./ModuleNotFoundError"); | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | const ModuleProfile = require("./ModuleProfile"); | 
					
						
							| 
									
										
										
										
											2018-10-18 04:54:07 +08:00
										 |  |  | const ModuleRestoreError = require("./ModuleRestoreError"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const ModuleTemplate = require("./ModuleTemplate"); | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | const RuntimeGlobals = require("./RuntimeGlobals"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const RuntimeTemplate = require("./RuntimeTemplate"); | 
					
						
							|  |  |  | const Stats = require("./Stats"); | 
					
						
							| 
									
										
										
										
											2018-12-03 00:00:16 +08:00
										 |  |  | const WebpackError = require("./WebpackError"); | 
					
						
							| 
									
										
										
										
											2019-07-25 14:07:55 +08:00
										 |  |  | const buildChunkGraph = require("./buildChunkGraph"); | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | const { Logger, LogType } = require("./logging/Logger"); | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | const StatsFactory = require("./stats/StatsFactory"); | 
					
						
							|  |  |  | const StatsPrinter = require("./stats/StatsPrinter"); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | const AsyncQueue = require("./util/AsyncQueue"); | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | const { | 
					
						
							| 
									
										
										
										
											2018-12-20 15:51:54 +08:00
										 |  |  | 	compareLocations, | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 	concatComparators, | 
					
						
							|  |  |  | 	compareSelect, | 
					
						
							| 
									
										
										
										
											2018-10-21 17:11:21 +08:00
										 |  |  | 	compareIds, | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 	compareStringsNumeric | 
					
						
							|  |  |  | } = require("./util/comparators"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const createHash = require("./util/createHash"); | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | const { arrayToSetDeprecation } = require("./util/deprecation"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | /** @typedef {import("webpack-sources").Source} Source */ | 
					
						
							| 
									
										
										
										
											2018-12-18 04:35:39 +08:00
										 |  |  | /** @typedef {import("../declarations/WebpackOptions").OutputOptions} OutputOptions */ | 
					
						
							| 
									
										
										
										
											2018-05-12 00:12:30 +08:00
										 |  |  | /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */ | 
					
						
							| 
									
										
										
										
											2019-06-14 17:44:54 +08:00
										 |  |  | /** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("./Compiler")} Compiler */ | 
					
						
							|  |  |  | /** @typedef {import("./DependenciesBlock")} DependenciesBlock */ | 
					
						
							| 
									
										
										
										
											2018-06-30 01:02:35 +08:00
										 |  |  | /** @typedef {import("./Dependency")} Dependency */ | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | 
					
						
							| 
									
										
										
										
											2018-07-23 23:33:29 +08:00
										 |  |  | /** @typedef {import("./DependencyTemplate")} DependencyTemplate */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | /** @typedef {import("./ModuleFactory")} ModuleFactory */ | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | /** @typedef {import("./RuntimeModule")} RuntimeModule */ | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | /** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("./WebpackError")} WebpackError */ | 
					
						
							|  |  |  | /** @typedef {import("./dependencies/DependencyReference")} DependencyReference */ | 
					
						
							|  |  |  | /** @typedef {import("./dependencies/DllEntryDependency")} DllEntryDependency */ | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | /** @typedef {import("./dependencies/EntryDependency")} EntryDependency */ | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | /** @typedef {import("./stats/StatsFactory")} StatsFactory */ | 
					
						
							|  |  |  | /** @typedef {import("./stats/StatsPrinter")} StatsPrinter */ | 
					
						
							| 
									
										
										
										
											2019-07-17 22:02:33 +08:00
										 |  |  | /** @typedef {import("./util/Hash")} Hash */ | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-10 18:34:59 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @callback Callback | 
					
						
							|  |  |  |  * @param {WebpackError=} err | 
					
						
							|  |  |  |  * @returns {void} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @callback ModuleCallback | 
					
						
							|  |  |  |  * @param {WebpackError=} err | 
					
						
							|  |  |  |  * @param {Module=} result | 
					
						
							|  |  |  |  * @returns {void} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @callback DepBlockVarDependenciesCallback | 
					
						
							|  |  |  |  * @param {Dependency} dependency | 
					
						
							|  |  |  |  * @returns {any} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} Plugin | 
					
						
							|  |  |  |  * @property {() => void} apply | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | /** @typedef {new (...args: any[]) => Dependency} DepConstructor */ | 
					
						
							| 
									
										
										
										
											2018-12-10 18:34:59 +08:00
										 |  |  | /** @typedef {Record<string, Source>} CompilationAssets */ | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} AvailableModulesChunkGroupMapping | 
					
						
							|  |  |  |  * @property {ChunkGroup} chunkGroup | 
					
						
							|  |  |  |  * @property {Set<Module>} availableModules | 
					
						
							| 
									
										
										
										
											2018-10-05 07:10:12 +08:00
										 |  |  |  * @property {boolean} needCopy | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 05:01:47 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} DependenciesBlockLike | 
					
						
							|  |  |  |  * @property {Dependency[]} dependencies | 
					
						
							|  |  |  |  * @property {AsyncDependenciesBlock[]} blocks | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} ChunkPathData | 
					
						
							|  |  |  |  * @property {string|number} id | 
					
						
							|  |  |  |  * @property {string=} name | 
					
						
							|  |  |  |  * @property {string} hash | 
					
						
							|  |  |  |  * @property {string} renderedHash | 
					
						
							|  |  |  |  * @property {function(number): string=} hashWithLength | 
					
						
							|  |  |  |  * @property {(Record<string, string>)=} contentHash | 
					
						
							|  |  |  |  * @property {(Record<string, (length: number) => string>)=} contentHashWithLength | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} LogEntry | 
					
						
							|  |  |  |  * @property {string} type | 
					
						
							|  |  |  |  * @property {any[]} args | 
					
						
							| 
									
										
										
										
											2019-07-23 15:28:06 +08:00
										 |  |  |  * @property {number} time | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  |  * @property {string[]=} trace | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} ModulePathData | 
					
						
							|  |  |  |  * @property {string|number} id | 
					
						
							|  |  |  |  * @property {string} hash | 
					
						
							|  |  |  |  * @property {string} renderedHash | 
					
						
							|  |  |  |  * @property {function(number): string=} hashWithLength | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} PathData | 
					
						
							|  |  |  |  * @property {ChunkGraph=} chunkGraph | 
					
						
							|  |  |  |  * @property {string=} hash | 
					
						
							|  |  |  |  * @property {function(number): string=} hashWithLength | 
					
						
							|  |  |  |  * @property {(Chunk|ChunkPathData)=} chunk | 
					
						
							|  |  |  |  * @property {(Module|ModulePathData)=} module | 
					
						
							|  |  |  |  * @property {string=} filename | 
					
						
							|  |  |  |  * @property {string=} basename | 
					
						
							|  |  |  |  * @property {string=} query | 
					
						
							|  |  |  |  * @property {string=} contentHashType | 
					
						
							|  |  |  |  * @property {string=} contentHash | 
					
						
							|  |  |  |  * @property {function(number): string=} contentHashWithLength | 
					
						
							|  |  |  |  * @property {boolean=} noChunkHash | 
					
						
							| 
									
										
										
										
											2019-07-17 22:02:33 +08:00
										 |  |  |  * @property {string=} url | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-14 20:14:05 +08:00
										 |  |  | // TODO webpack 6: remove
 | 
					
						
							| 
									
										
										
										
											2018-11-13 21:45:26 +08:00
										 |  |  | const deprecatedNormalModuleLoaderHook = util.deprecate(compilation => { | 
					
						
							|  |  |  | 	return require("./NormalModule").getCompilationHooks(compilation).loader; | 
					
						
							|  |  |  | }, "Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-21 17:11:21 +08:00
										 |  |  | const byId = compareSelect( | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Chunk} c chunk | 
					
						
							|  |  |  | 	 * @returns {number | string} id | 
					
						
							|  |  |  | 	 */ c => c.id, | 
					
						
							|  |  |  | 	compareIds | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2015-08-18 19:35:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-21 17:11:21 +08:00
										 |  |  | const byNameOrHash = concatComparators( | 
					
						
							|  |  |  | 	compareSelect( | 
					
						
							|  |  |  | 		/** | 
					
						
							|  |  |  | 		 * @param {Compilation} c compilation | 
					
						
							|  |  |  | 		 * @returns {string} name | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		c => c.name, | 
					
						
							|  |  |  | 		compareIds | 
					
						
							|  |  |  | 	), | 
					
						
							|  |  |  | 	compareSelect( | 
					
						
							|  |  |  | 		/** | 
					
						
							|  |  |  | 		 * @param {Compilation} c compilation | 
					
						
							|  |  |  | 		 * @returns {string} hash | 
					
						
							|  |  |  | 		 */ c => c.fullHash, | 
					
						
							|  |  |  | 		compareIds | 
					
						
							|  |  |  | 	) | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2018-04-03 23:23:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2018-06-23 22:24:36 +08:00
										 |  |  |  * @template T | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  |  * @param {Set<T>} set set to add items to | 
					
						
							|  |  |  |  * @param {Set<T>} otherSet set to add items from | 
					
						
							|  |  |  |  * @returns {void} | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-06-27 19:48:13 +08:00
										 |  |  | const addAllToSet = (set, otherSet) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	for (const item of otherSet) { | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 		set.add(item); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-27 19:48:13 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-26 14:27:44 +08:00
										 |  |  | class Compilation { | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Creates an instance of Compilation. | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the compiler which created the compilation | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	constructor(compiler) { | 
					
						
							| 
									
										
										
										
											2018-11-13 21:45:26 +08:00
										 |  |  | 		const getNormalModuleLoader = () => deprecatedNormalModuleLoaderHook(this); | 
					
						
							| 
									
										
										
										
											2018-07-30 20:25:40 +08:00
										 |  |  | 		this.hooks = Object.freeze({ | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Module]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			buildModule: new SyncHook(["module"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Module]>} */ | 
					
						
							| 
									
										
										
										
											2017-12-07 00:39:42 +08:00
										 |  |  | 			rebuildModule: new SyncHook(["module"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Module, WebpackError]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			failedModule: new SyncHook(["module", "error"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Module]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			succeedModule: new SyncHook(["module"]), | 
					
						
							| 
									
										
										
										
											2019-07-25 21:47:31 +08:00
										 |  |  | 			/** @type {SyncHook<[Module]>} */ | 
					
						
							|  |  |  | 			stillValidModule: new SyncHook(["module"]), | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Dependency, string]>} */ | 
					
						
							| 
									
										
										
										
											2018-10-29 20:49:31 +08:00
										 |  |  | 			addEntry: new SyncHook(["entry", "name"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Dependency, string, Error]>} */ | 
					
						
							| 
									
										
										
										
											2018-10-29 20:49:31 +08:00
										 |  |  | 			failedEntry: new SyncHook(["entry", "name", "error"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Dependency, string, Module]>} */ | 
					
						
							| 
									
										
										
										
											2018-10-29 20:49:31 +08:00
										 |  |  | 			succeedEntry: new SyncHook(["entry", "name", "module"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-10 17:06:25 +08:00
										 |  |  | 			/** @type {SyncWaterfallHook<[DependencyReference, Dependency]>} */ | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 			dependencyReference: new SyncWaterfallHook([ | 
					
						
							|  |  |  | 				"dependencyReference", | 
					
						
							| 
									
										
										
										
											2019-05-10 17:06:25 +08:00
										 |  |  | 				"dependency" | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 			]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {AsyncSeriesHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 			finishModules: new AsyncSeriesHook(["modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {AsyncSeriesHook<[Module]>} */ | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 			finishRebuildingModule: new AsyncSeriesHook(["module"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			unseal: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			seal: new SyncHook([]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2018-07-02 22:18:49 +08:00
										 |  |  | 			beforeChunks: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2018-07-02 22:18:49 +08:00
										 |  |  | 			afterChunks: new SyncHook(["chunks"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeDependencies: new SyncBailHook(["modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeDependencies: new SyncHook(["modules"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimize: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeModules: new SyncBailHook(["modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeModules: new SyncHook(["modules"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[Iterable<Chunk>, ChunkGroup[]]>} */ | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			optimizeChunks: new SyncBailHook(["chunks", "chunkGroups"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>, ChunkGroup[]]>} */ | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			afterOptimizeChunks: new SyncHook(["chunks", "chunkGroups"]), | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {AsyncSeriesHook<[Iterable<Chunk>, Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeTree: new AsyncSeriesHook(["chunks", "modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>, Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeTree: new SyncHook(["chunks", "modules"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[Iterable<Chunk>, Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeChunkModules: new SyncBailHook(["chunks", "modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>, Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeChunkModules: new SyncHook(["chunks", "modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[], boolean>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			shouldRecord: new SyncBailHook([]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Chunk, Set<string>]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 			additionalChunkRuntimeRequirements: new SyncHook([ | 
					
						
							|  |  |  | 				"chunk", | 
					
						
							|  |  |  | 				"runtimeRequirements" | 
					
						
							|  |  |  | 			]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {HookMap<SyncBailHook<[Chunk, Set<string>]>>} */ | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 			runtimeRequirementInChunk: new HookMap( | 
					
						
							|  |  |  | 				() => new SyncBailHook(["chunk", "runtimeRequirements"]) | 
					
						
							|  |  |  | 			), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Module, Set<string>]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 			additionalModuleRuntimeRequirements: new SyncHook([ | 
					
						
							|  |  |  | 				"module", | 
					
						
							|  |  |  | 				"runtimeRequirements" | 
					
						
							|  |  |  | 			]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {HookMap<SyncBailHook<[Module, Set<string>]>>} */ | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 			runtimeRequirementInModule: new HookMap( | 
					
						
							|  |  |  | 				() => new SyncBailHook(["module", "runtimeRequirements"]) | 
					
						
							|  |  |  | 			), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Chunk, Set<string>]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 			additionalTreeRuntimeRequirements: new SyncHook([ | 
					
						
							|  |  |  | 				"chunk", | 
					
						
							|  |  |  | 				"runtimeRequirements" | 
					
						
							|  |  |  | 			]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {HookMap<SyncBailHook<[Chunk, Set<string>]>>} */ | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 			runtimeRequirementInTree: new HookMap( | 
					
						
							|  |  |  | 				() => new SyncBailHook(["chunk", "runtimeRequirements"]) | 
					
						
							|  |  |  | 			), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[RuntimeModule, Chunk]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			runtimeModule: new SyncHook(["module", "chunk"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>, any]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			reviveModules: new SyncHook(["modules", "records"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			beforeModuleIds: new SyncHook(["modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			moduleIds: new SyncHook(["modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeModuleIds: new SyncHook(["modules"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeModuleIds: new SyncHook(["modules"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>, any]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			reviveChunks: new SyncHook(["chunks", "records"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			beforeChunkIds: new SyncHook(["chunks"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2018-09-05 20:22:10 +08:00
										 |  |  | 			chunkIds: new SyncHook(["chunks"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeChunkIds: new SyncHook(["chunks"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeChunkIds: new SyncHook(["chunks"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>, any]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			recordModules: new SyncHook(["modules", "records"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>, any]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			recordChunks: new SyncHook(["chunks", "records"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Module>]>} */ | 
					
						
							| 
									
										
										
										
											2019-01-28 17:40:32 +08:00
										 |  |  | 			optimizeCodeGeneration: new SyncHook(["modules"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			beforeModuleHash: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			afterModuleHash: new SyncHook([]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			beforeRuntimeRequirements: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			afterRuntimeRequirements: new SyncHook([]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			beforeHash: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Chunk]>} */ | 
					
						
							| 
									
										
										
										
											2018-03-23 02:52:11 +08:00
										 |  |  | 			contentHash: new SyncHook(["chunk"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterHash: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[any]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			recordHash: new SyncHook(["records"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Compilation, any]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			record: new SyncHook(["compilation", "records"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			beforeModuleAssets: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[], boolean>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			shouldGenerateChunkAssets: new SyncBailHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			beforeChunkAssets: new SyncHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			additionalChunkAssets: new SyncHook(["chunks"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {AsyncSeriesHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			additionalAssets: new AsyncSeriesHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {AsyncSeriesHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeChunkAssets: new AsyncSeriesHook(["chunks"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Iterable<Chunk>]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeChunkAssets: new SyncHook(["chunks"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {AsyncSeriesHook<[CompilationAssets]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			optimizeAssets: new AsyncSeriesHook(["assets"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[CompilationAssets]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterOptimizeAssets: new SyncHook(["assets"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[], boolean>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			needAdditionalSeal: new SyncBailHook([]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {AsyncSeriesHook<[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			afterSeal: new AsyncSeriesHook([]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Chunk, Hash]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			chunkHash: new SyncHook(["chunk", "chunkHash"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Module, string]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			moduleAsset: new SyncHook(["module", "filename"]), | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Chunk, string]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			chunkAsset: new SyncHook(["chunk", "filename"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncWaterfallHook<[string, TODO]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			assetPath: new SyncWaterfallHook(["filename", "data"]), // TODO MainTemplate
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncBailHook<[], boolean>} */ | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			needAdditionalPass: new SyncBailHook([]), | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-09 19:54:17 +08:00
										 |  |  | 			/** @type {SyncHook<[Compiler, string, number]>} */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			childCompiler: new SyncHook([ | 
					
						
							|  |  |  | 				"childCompiler", | 
					
						
							|  |  |  | 				"compilerName", | 
					
						
							|  |  |  | 				"compilerIndex" | 
					
						
							| 
									
										
										
										
											2018-11-13 21:45:26 +08:00
										 |  |  | 			]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-24 16:51:04 +08:00
										 |  |  | 			/** @type {SyncBailHook<[string, LogEntry], true>} */ | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 			log: new SyncBailHook(["origin", "logEntry"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 02:39:11 +08:00
										 |  |  | 			/** @type {HookMap<SyncHook<[Object, Object]>>} */ | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 			statsPreset: new HookMap(() => new SyncHook(["options", "context"])), | 
					
						
							| 
									
										
										
										
											2018-12-31 02:39:11 +08:00
										 |  |  | 			/** @type {SyncHook<[Object, Object]>} */ | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 			statsNormalize: new SyncHook(["options", "context"]), | 
					
						
							| 
									
										
										
										
											2018-12-31 02:39:11 +08:00
										 |  |  | 			/** @type {SyncHook<[StatsFactory, Object]>} */ | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 			statsFactory: new SyncHook(["statsFactory", "options"]), | 
					
						
							| 
									
										
										
										
											2018-12-31 02:39:11 +08:00
										 |  |  | 			/** @type {SyncHook<[StatsPrinter, Object]>} */ | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 			statsPrinter: new SyncHook(["statsPrinter", "options"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 21:45:26 +08:00
										 |  |  | 			get normalModuleLoader() { | 
					
						
							|  |  |  | 				return getNormalModuleLoader(); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-07-30 20:25:40 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {string=} */ | 
					
						
							| 
									
										
										
										
											2018-03-30 08:33:19 +08:00
										 |  |  | 		this.name = undefined; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Compiler} */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.compiler = compiler; | 
					
						
							| 
									
										
										
										
											2017-11-17 21:26:23 +08:00
										 |  |  | 		this.resolverFactory = compiler.resolverFactory; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.inputFileSystem = compiler.inputFileSystem; | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 		this.fileSystemInfo = new FileSystemInfo(this.inputFileSystem); | 
					
						
							| 
									
										
										
										
											2018-09-28 03:28:07 +08:00
										 |  |  | 		if (compiler.fileTimestamps) { | 
					
						
							|  |  |  | 			this.fileSystemInfo.addFileTimestamps(compiler.fileTimestamps); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (compiler.contextTimestamps) { | 
					
						
							|  |  |  | 			this.fileSystemInfo.addContextTimestamps(compiler.contextTimestamps); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-12-01 17:44:22 +08:00
										 |  |  | 		this.requestShortener = compiler.requestShortener; | 
					
						
							| 
									
										
										
										
											2018-09-26 16:28:16 +08:00
										 |  |  | 		this.compilerPath = compiler.compilerPath; | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 		this.cache = compiler.cache; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-19 19:05:22 +08:00
										 |  |  | 		const options = compiler.options; | 
					
						
							|  |  |  | 		this.options = options; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.outputOptions = options && options.output; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 		/** @type {boolean} */ | 
					
						
							|  |  |  | 		this.bail = (options && options.bail) || false; | 
					
						
							|  |  |  | 		/** @type {boolean} */ | 
					
						
							|  |  |  | 		this.profile = (options && options.profile) || false; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		this.mainTemplate = new MainTemplate(this.outputOptions); | 
					
						
							|  |  |  | 		this.chunkTemplate = new ChunkTemplate(this.outputOptions); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		this.runtimeTemplate = new RuntimeTemplate( | 
					
						
							|  |  |  | 			this.outputOptions, | 
					
						
							|  |  |  | 			this.requestShortener | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-07-16 19:16:27 +08:00
										 |  |  | 		/** @type {{asset: ModuleTemplate, javascript: ModuleTemplate, webassembly: ModuleTemplate}} */ | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 		this.moduleTemplates = { | 
					
						
							| 
									
										
										
										
											2019-07-16 19:16:27 +08:00
										 |  |  | 			asset: new ModuleTemplate(this.runtimeTemplate, "asset"), | 
					
						
							| 
									
										
										
										
											2018-04-28 00:53:07 +08:00
										 |  |  | 			javascript: new ModuleTemplate(this.runtimeTemplate, "javascript"), | 
					
						
							|  |  |  | 			webassembly: new ModuleTemplate(this.runtimeTemplate, "webassembly") | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 22:41:07 +08:00
										 |  |  | 		this.moduleGraph = new ModuleGraph(); | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 		this.chunkGraph = undefined; | 
					
						
							| 
									
										
										
										
											2018-07-17 22:41:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 		/** @type {AsyncQueue<TODO, TODO, Module>} */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		this.factorizeQueue = new AsyncQueue({ | 
					
						
							|  |  |  | 			name: "factorize", | 
					
						
							|  |  |  | 			parallelism: options.parallelism || 100, | 
					
						
							|  |  |  | 			processor: this._factorizeModule.bind(this) | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 		/** @type {AsyncQueue<Module, string, Module>} */ | 
					
						
							|  |  |  | 		this.addModuleQueue = new AsyncQueue({ | 
					
						
							|  |  |  | 			name: "addModule", | 
					
						
							|  |  |  | 			parallelism: options.parallelism || 100, | 
					
						
							|  |  |  | 			getKey: module => module.identifier(), | 
					
						
							|  |  |  | 			processor: this._addModule.bind(this) | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		/** @type {AsyncQueue<Module, Module, Module>} */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		this.buildQueue = new AsyncQueue({ | 
					
						
							|  |  |  | 			name: "build", | 
					
						
							|  |  |  | 			parallelism: options.parallelism || 100, | 
					
						
							|  |  |  | 			processor: this._buildModule.bind(this) | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 		/** @type {AsyncQueue<Module, Module, Module>} */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		this.rebuildQueue = new AsyncQueue({ | 
					
						
							|  |  |  | 			name: "rebuild", | 
					
						
							|  |  |  | 			parallelism: options.parallelism || 100, | 
					
						
							|  |  |  | 			processor: this._rebuildModule.bind(this) | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 		/** @type {AsyncQueue<Module, Module, Module>} */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		this.processDependenciesQueue = new AsyncQueue({ | 
					
						
							|  |  |  | 			name: "processDependencies", | 
					
						
							|  |  |  | 			parallelism: options.parallelism || 100, | 
					
						
							|  |  |  | 			processor: this._processModuleDependencies.bind(this) | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-08-11 22:11:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 		/** @type {Map<string, EntryDependency[]>} */ | 
					
						
							|  |  |  | 		this.entryDependencies = new Map(); | 
					
						
							|  |  |  | 		/** @type {Map<string, Entrypoint>} */ | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this.entrypoints = new Map(); | 
					
						
							| 
									
										
										
										
											2018-09-06 22:59:11 +08:00
										 |  |  | 		/** @type {Set<Chunk>} */ | 
					
						
							|  |  |  | 		this.chunks = new Set(); | 
					
						
							|  |  |  | 		arrayToSetDeprecation(this.chunks, "Compilation.chunks"); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {ChunkGroup[]} */ | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this.chunkGroups = []; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Map<string, ChunkGroup>} */ | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this.namedChunkGroups = new Map(); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Map<string, Chunk>} */ | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this.namedChunks = new Map(); | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | 		/** @type {Set<Module>} */ | 
					
						
							|  |  |  | 		this.modules = new Set(); | 
					
						
							|  |  |  | 		arrayToSetDeprecation(this.modules, "Compilation.modules"); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @private @type {Map<string, Module>} */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this._modules = new Map(); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.records = null; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {string[]} */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.additionalChunkAssets = []; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {CompilationAssets} */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.assets = {}; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {WebpackError[]} */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.errors = []; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {WebpackError[]} */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.warnings = []; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Compilation[]} */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.children = []; | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 		/** @type {Map<string, LogEntry[]>} */ | 
					
						
							|  |  |  | 		this.logging = new Map(); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Map<DepConstructor, ModuleFactory>} */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.dependencyFactories = new Map(); | 
					
						
							| 
									
										
										
										
											2018-07-12 23:12:00 +08:00
										 |  |  | 		/** @type {DependencyTemplates} */ | 
					
						
							|  |  |  | 		this.dependencyTemplates = new DependencyTemplates(); | 
					
						
							| 
									
										
										
										
											2017-04-13 19:43:51 +08:00
										 |  |  | 		this.childrenCounters = {}; | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 		/** @type {Set<number|string>} */ | 
					
						
							| 
									
										
										
										
											2018-01-05 14:41:09 +08:00
										 |  |  | 		this.usedChunkIds = null; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Set<number>} */ | 
					
						
							| 
									
										
										
										
											2018-01-05 14:41:09 +08:00
										 |  |  | 		this.usedModuleIds = null; | 
					
						
							| 
									
										
										
										
											2018-07-20 19:35:01 +08:00
										 |  |  | 		/** @type {boolean} */ | 
					
						
							|  |  |  | 		this.needAdditionalPass = false; | 
					
						
							| 
									
										
										
										
											2018-08-22 21:33:16 +08:00
										 |  |  | 		/** @type {WeakSet<Module>} */ | 
					
						
							|  |  |  | 		this.builtModules = new WeakSet(); | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 		/** @private @type {Map<Module, Callback[]>} */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this._rebuildingModules = new Map(); | 
					
						
							| 
									
										
										
										
											2019-01-19 03:38:34 +08:00
										 |  |  | 		/** @type {Set<string>} */ | 
					
						
							|  |  |  | 		this.emittedAssets = new Set(); | 
					
						
							| 
									
										
										
										
											2019-01-19 19:08:49 +08:00
										 |  |  | 		/** @type {Set<string>} */ | 
					
						
							|  |  |  | 		this.fileDependencies = new Set(); | 
					
						
							|  |  |  | 		/** @type {Set<string>} */ | 
					
						
							|  |  |  | 		this.contextDependencies = new Set(); | 
					
						
							|  |  |  | 		/** @type {Set<string>} */ | 
					
						
							|  |  |  | 		this.missingDependencies = new Set(); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-12-22 23:10:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 19:52:06 +08:00
										 |  |  | 	getStats() { | 
					
						
							|  |  |  | 		return new Stats(this); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-12-22 23:10:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 	createStatsOptions(optionsOrPreset, context = {}) { | 
					
						
							|  |  |  | 		if ( | 
					
						
							|  |  |  | 			typeof optionsOrPreset === "boolean" || | 
					
						
							|  |  |  | 			typeof optionsOrPreset === "string" | 
					
						
							|  |  |  | 		) { | 
					
						
							|  |  |  | 			optionsOrPreset = { preset: optionsOrPreset }; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (typeof optionsOrPreset === "object" && optionsOrPreset !== null) { | 
					
						
							| 
									
										
										
										
											2019-06-19 19:16:05 +08:00
										 |  |  | 			const options = { ...optionsOrPreset }; | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 			if (options.preset !== undefined) { | 
					
						
							| 
									
										
										
										
											2019-05-11 03:50:13 +08:00
										 |  |  | 				this.hooks.statsPreset.for(options.preset).call(options, context); | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			this.hooks.statsNormalize.call(options, context); | 
					
						
							|  |  |  | 			return options; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			const options = {}; | 
					
						
							|  |  |  | 			this.hooks.statsNormalize.call(options, context); | 
					
						
							|  |  |  | 			return options; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	createStatsFactory(options) { | 
					
						
							|  |  |  | 		const statsFactory = new StatsFactory(); | 
					
						
							|  |  |  | 		this.hooks.statsFactory.call(statsFactory, options); | 
					
						
							|  |  |  | 		return statsFactory; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	createStatsPrinter(options) { | 
					
						
							|  |  |  | 		const statsPrinter = new StatsPrinter(); | 
					
						
							|  |  |  | 		this.hooks.statsPrinter.call(statsPrinter, options); | 
					
						
							|  |  |  | 		return statsPrinter; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {string | (function(): string)} name name of the logger, or function called once to get the logger name | 
					
						
							|  |  |  | 	 * @returns {Logger} a logger with that name | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	getLogger(name) { | 
					
						
							|  |  |  | 		if (!name) { | 
					
						
							|  |  |  | 			throw new TypeError("Compilation.getLogger(name) called without a name"); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-07-23 15:28:06 +08:00
										 |  |  | 		/** @type {LogEntry[] | undefined} */ | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 		let logEntries; | 
					
						
							|  |  |  | 		return new Logger((type, args) => { | 
					
						
							|  |  |  | 			if (typeof name === "function") { | 
					
						
							|  |  |  | 				name = name(); | 
					
						
							|  |  |  | 				if (!name) { | 
					
						
							|  |  |  | 					throw new TypeError( | 
					
						
							|  |  |  | 						"Compilation.getLogger(name) called with a function not returning a name" | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			let trace; | 
					
						
							|  |  |  | 			switch (type) { | 
					
						
							|  |  |  | 				case LogType.warn: | 
					
						
							|  |  |  | 				case LogType.error: | 
					
						
							|  |  |  | 				case LogType.trace: | 
					
						
							|  |  |  | 					trace = ErrorHelpers.cutOffLoaderExecution(new Error("Trace").stack) | 
					
						
							|  |  |  | 						.split("\n") | 
					
						
							|  |  |  | 						.slice(3); | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-07-23 15:28:06 +08:00
										 |  |  | 			/** @type {LogEntry} */ | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 			const logEntry = { | 
					
						
							|  |  |  | 				time: Date.now(), | 
					
						
							|  |  |  | 				type, | 
					
						
							|  |  |  | 				args, | 
					
						
							|  |  |  | 				trace | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 			if (this.hooks.log.call(name, logEntry) === undefined) { | 
					
						
							| 
									
										
										
										
											2019-07-22 14:19:30 +08:00
										 |  |  | 				if (logEntry.type === LogType.profileEnd) { | 
					
						
							|  |  |  | 					// eslint-disable-next-line node/no-unsupported-features/node-builtins
 | 
					
						
							|  |  |  | 					if (typeof console.profileEnd === "function") { | 
					
						
							|  |  |  | 						// eslint-disable-next-line node/no-unsupported-features/node-builtins
 | 
					
						
							| 
									
										
										
										
											2019-07-23 15:28:06 +08:00
										 |  |  | 						console.profileEnd(`[${name}] ${logEntry.args[0]}`); | 
					
						
							| 
									
										
										
										
											2019-07-22 14:19:30 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 				if (logEntries === undefined) { | 
					
						
							|  |  |  | 					logEntries = this.logging.get(name); | 
					
						
							|  |  |  | 					if (logEntries === undefined) { | 
					
						
							|  |  |  | 						logEntries = []; | 
					
						
							|  |  |  | 						this.logging.set(name, logEntries); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				logEntries.push(logEntry); | 
					
						
							| 
									
										
										
										
											2019-07-22 14:19:30 +08:00
										 |  |  | 				if (logEntry.type === LogType.profile) { | 
					
						
							|  |  |  | 					// eslint-disable-next-line node/no-unsupported-features/node-builtins
 | 
					
						
							|  |  |  | 					if (typeof console.profile === "function") { | 
					
						
							|  |  |  | 						// eslint-disable-next-line node/no-unsupported-features/node-builtins
 | 
					
						
							| 
									
										
										
										
											2019-07-23 15:28:06 +08:00
										 |  |  | 						console.profile(`[${name}] ${logEntry.args[0]}`); | 
					
						
							| 
									
										
										
										
											2019-07-22 14:19:30 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
											
												add logging API
Plugins:
Compiler.getInfrastructureLogger(name)
Compilation.getLogger(name)
Loader:
this.getLogger([name])
API equal to console API with these methods:
error, warn, info, log, debug,
time, timeLog, timeEnd,
group, groupCollapsed, groupEnd,
profile, profileEnd,
clear
											
										 
											2019-07-18 23:13:40 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module module to be added that was created | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 	 * @param {ModuleCallback} callback returns the module in the compilation, | 
					
						
							|  |  |  | 	 * it could be the passed one (if new), or an already existing in the compilation | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	addModule(module, callback) { | 
					
						
							|  |  |  | 		this.addModuleQueue.add(module, callback); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module module to be added that was created | 
					
						
							|  |  |  | 	 * @param {ModuleCallback} callback returns the module in the compilation, | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * it could be the passed one (if new), or an already existing in the compilation | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 	_addModule(module, callback) { | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		const identifier = module.identifier(); | 
					
						
							| 
									
										
										
										
											2017-12-07 00:22:10 +08:00
										 |  |  | 		const alreadyAddedModule = this._modules.get(identifier); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (alreadyAddedModule) { | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 			return callback(null, alreadyAddedModule); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-02-01 01:00:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 		const currentProfile = this.profile | 
					
						
							|  |  |  | 			? this.moduleGraph.getProfile(module) | 
					
						
							|  |  |  | 			: undefined; | 
					
						
							|  |  |  | 		if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 			currentProfile.markRestoringStart(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 16:46:48 +08:00
										 |  |  | 		const cacheName = `${this.compilerPath}/module/${identifier}`; | 
					
						
							|  |  |  | 		this.cache.get(cacheName, null, (err, cacheModule) => { | 
					
						
							| 
									
										
										
										
											2018-10-18 04:54:07 +08:00
										 |  |  | 			if (err) return callback(new ModuleRestoreError(module, err)); | 
					
						
							| 
									
										
										
										
											2018-03-28 22:19:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 			if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 				currentProfile.markRestoringEnd(); | 
					
						
							|  |  |  | 				currentProfile.markIntegrationStart(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 			if (cacheModule) { | 
					
						
							|  |  |  | 				cacheModule.updateCacheModule(module); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				module = cacheModule; | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 			this._modules.set(identifier, module); | 
					
						
							|  |  |  | 			this.modules.add(module); | 
					
						
							|  |  |  | 			ModuleGraph.setModuleGraphForModule(module, this.moduleGraph); | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 			if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 				currentProfile.markIntegrationEnd(); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 			callback(null, module); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Fetches a module from a compilation by its identifier | 
					
						
							|  |  |  | 	 * @param {Module} module the module provided | 
					
						
							|  |  |  | 	 * @returns {Module} the module requested | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	getModule(module) { | 
					
						
							|  |  |  | 		const identifier = module.identifier(); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		return this._modules.get(identifier); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Attempts to search for a module by its identifier | 
					
						
							|  |  |  | 	 * @param {string} identifier identifier (usually path) for module | 
					
						
							|  |  |  | 	 * @returns {Module|undefined} attempt to search for module and return it, else undefined | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	findModule(identifier) { | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		return this._modules.get(identifier); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * Schedules a build of the module object | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {Module} module module to be built | 
					
						
							|  |  |  | 	 * @param {ModuleCallback} callback the callback | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	buildModule(module, callback) { | 
					
						
							|  |  |  | 		this.buildQueue.add(module, callback); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Builds the module object | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {Module} module module to be built | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {ModuleCallback} callback the callback | 
					
						
							| 
									
										
										
										
											2018-12-10 18:34:59 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	_buildModule(module, callback) { | 
					
						
							|  |  |  | 		const currentProfile = this.profile | 
					
						
							|  |  |  | 			? this.moduleGraph.getProfile(module) | 
					
						
							|  |  |  | 			: undefined; | 
					
						
							|  |  |  | 		if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 			currentProfile.markBuildingStart(); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | 		module.needBuild( | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 				fileSystemInfo: this.fileSystemInfo | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 			(err, needBuild) => { | 
					
						
							|  |  |  | 				if (err) return callback(err); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (!needBuild) { | 
					
						
							|  |  |  | 					if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 						currentProfile.markBuildingEnd(); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2019-07-25 21:47:31 +08:00
										 |  |  | 					this.hooks.stillValidModule.call(module); | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | 					return callback(); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				this.hooks.buildModule.call(module); | 
					
						
							|  |  |  | 				this.builtModules.add(module); | 
					
						
							|  |  |  | 				module.build( | 
					
						
							|  |  |  | 					this.options, | 
					
						
							|  |  |  | 					this, | 
					
						
							|  |  |  | 					this.resolverFactory.get("normal", module.resolveOptions), | 
					
						
							|  |  |  | 					this.inputFileSystem, | 
					
						
							|  |  |  | 					err => { | 
					
						
							|  |  |  | 						if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 							currentProfile.markBuildingEnd(); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						if (err) { | 
					
						
							|  |  |  | 							this.hooks.failedModule.call(module, err); | 
					
						
							|  |  |  | 							return callback(err); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 						if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 							currentProfile.markStoringStart(); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-10-11 16:46:48 +08:00
										 |  |  | 						this.cache.store( | 
					
						
							|  |  |  | 							`${this.compilerPath}/module/${module.identifier()}`, | 
					
						
							|  |  |  | 							null, | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 							module, | 
					
						
							|  |  |  | 							err => { | 
					
						
							|  |  |  | 								if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 									currentProfile.markStoringEnd(); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								if (err) { | 
					
						
							|  |  |  | 									this.hooks.failedModule.call(module, err); | 
					
						
							|  |  |  | 									return callback(err); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								this.hooks.succeedModule.call(module); | 
					
						
							|  |  |  | 								return callback(); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											2018-09-26 15:14:44 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-08 20:15:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module to be processed for deps | 
					
						
							| 
									
										
										
										
											2018-05-07 05:01:47 +08:00
										 |  |  | 	 * @param {ModuleCallback} callback callback to be triggered | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	processModuleDependencies(module, callback) { | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		this.processDependenciesQueue.add(module, callback); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module to be processed for deps | 
					
						
							|  |  |  | 	 * @param {ModuleCallback} callback callback to be triggered | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	_processModuleDependencies(module, callback) { | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 		const dependencies = new Map(); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 		let currentBlock = module; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-26 19:35:29 +08:00
										 |  |  | 		let factoryCacheKey; | 
					
						
							|  |  |  | 		let factoryCacheValue; | 
					
						
							|  |  |  | 		let listCacheKey; | 
					
						
							|  |  |  | 		let listCacheValue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 		const processDependency = dep => { | 
					
						
							|  |  |  | 			this.moduleGraph.setParents(dep, currentBlock, module); | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 			const resourceIdent = dep.getResourceIdentifier(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (resourceIdent) { | 
					
						
							| 
									
										
										
										
											2019-07-26 19:35:29 +08:00
										 |  |  | 				const constructor = dep.constructor; | 
					
						
							|  |  |  | 				let innerMap; | 
					
						
							|  |  |  | 				if (factoryCacheKey === constructor) { | 
					
						
							|  |  |  | 					innerMap = factoryCacheValue; | 
					
						
							|  |  |  | 					if (listCacheKey === resourceIdent) { | 
					
						
							|  |  |  | 						listCacheValue.push(dep); | 
					
						
							|  |  |  | 						return; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					const factory = this.dependencyFactories.get(dep.constructor); | 
					
						
							|  |  |  | 					if (factory === undefined) { | 
					
						
							|  |  |  | 						throw new Error( | 
					
						
							|  |  |  | 							`No module factory available for dependency type: ${dep.constructor.name}` | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					innerMap = dependencies.get(factory); | 
					
						
							|  |  |  | 					if (innerMap === undefined) { | 
					
						
							|  |  |  | 						dependencies.set(factory, (innerMap = new Map())); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					factoryCacheKey = constructor; | 
					
						
							|  |  |  | 					factoryCacheValue = innerMap; | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 				let list = innerMap.get(resourceIdent); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (list === undefined) innerMap.set(resourceIdent, (list = [])); | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 				list.push(dep); | 
					
						
							| 
									
										
										
										
											2019-07-26 19:35:29 +08:00
										 |  |  | 				listCacheKey = resourceIdent; | 
					
						
							|  |  |  | 				listCacheValue = list; | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 		const processDependenciesBlock = block => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (block.dependencies) { | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 				currentBlock = block; | 
					
						
							| 
									
										
										
										
											2019-07-10 02:49:10 +08:00
										 |  |  | 				for (const dep of block.dependencies) processDependency(dep); | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (block.blocks) { | 
					
						
							| 
									
										
										
										
											2019-07-10 02:49:10 +08:00
										 |  |  | 				for (const b of block.blocks) processDependenciesBlock(b); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-19 16:06:40 +08:00
										 |  |  | 		try { | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 			processDependenciesBlock(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		} catch (e) { | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 			return callback(e); | 
					
						
							| 
									
										
										
										
											2017-11-19 16:06:40 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		const sortedDependencies = []; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-26 19:35:29 +08:00
										 |  |  | 		for (const [factory, innerMap] of dependencies) { | 
					
						
							|  |  |  | 			for (const dependencies of innerMap.values()) { | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 				sortedDependencies.push({ | 
					
						
							| 
									
										
										
										
											2019-07-26 19:35:29 +08:00
										 |  |  | 					factory, | 
					
						
							|  |  |  | 					dependencies, | 
					
						
							|  |  |  | 					originModule: module | 
					
						
							| 
									
										
										
										
											2017-11-19 07:22:38 +08:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-05 18:19:30 +08:00
										 |  |  | 		if (sortedDependencies.length === 0) { | 
					
						
							|  |  |  | 			callback(); | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		process.nextTick(() => { | 
					
						
							|  |  |  | 			// This is nested so we need to allow one additional task
 | 
					
						
							|  |  |  | 			this.processDependenciesQueue.increaseParallelism(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			asyncLib.forEach( | 
					
						
							|  |  |  | 				sortedDependencies, | 
					
						
							|  |  |  | 				(item, callback) => { | 
					
						
							| 
									
										
										
										
											2019-07-26 19:35:29 +08:00
										 |  |  | 					this.handleModuleCreation(item, err => { | 
					
						
							|  |  |  | 						// In V8, the Error objects keep a reference to the functions on the stack. These warnings &
 | 
					
						
							|  |  |  | 						// errors are created inside closures that keep a reference to the Compilation, so errors are
 | 
					
						
							|  |  |  | 						// leaking the Compilation object.
 | 
					
						
							|  |  |  | 						if (err && this.bail) { | 
					
						
							|  |  |  | 							// eslint-disable-next-line no-self-assign
 | 
					
						
							|  |  |  | 							err.stack = err.stack; | 
					
						
							|  |  |  | 							return callback(err); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2019-07-26 19:35:29 +08:00
										 |  |  | 						callback(); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2019-01-05 18:19:30 +08:00
										 |  |  | 				}, | 
					
						
							|  |  |  | 				err => { | 
					
						
							|  |  |  | 					this.processDependenciesQueue.decreaseParallelism(); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-05 18:19:30 +08:00
										 |  |  | 					return callback(err); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-05-08 19:28:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @typedef {Object} HandleModuleCreationOptions | 
					
						
							|  |  |  | 	 * @property {ModuleFactory} factory | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	 * @property {Dependency[]} dependencies | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @property {Module | null} originModule | 
					
						
							|  |  |  | 	 * @property {string=} context | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {HandleModuleCreationOptions} options options object | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	 * @param {ModuleCallback} callback callback | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	handleModuleCreation( | 
					
						
							|  |  |  | 		{ factory, dependencies, originModule, context }, | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 		callback | 
					
						
							|  |  |  | 	) { | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		const moduleGraph = this.moduleGraph; | 
					
						
							| 
									
										
										
										
											2018-08-22 20:54:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		const currentProfile = this.profile ? new ModuleProfile() : undefined; | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		this.factorizeModule( | 
					
						
							|  |  |  | 			{ currentProfile, factory, dependencies, originModule, context }, | 
					
						
							|  |  |  | 			(err, newModule) => { | 
					
						
							|  |  |  | 				if (err) { | 
					
						
							|  |  |  | 					if (dependencies.every(d => d.optional)) { | 
					
						
							|  |  |  | 						this.warnings.push(err); | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						this.errors.push(err); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					return callback(err); | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 				if (!newModule) { | 
					
						
							|  |  |  | 					return callback(); | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 				if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 					moduleGraph.setProfile(newModule, currentProfile); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 				this.addModule(newModule, (err, module) => { | 
					
						
							|  |  |  | 					if (err) { | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 						if (!err.module) { | 
					
						
							|  |  |  | 							err.module = module; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						this.errors.push(err); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						return callback(err); | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 					for (let i = 0; i < dependencies.length; i++) { | 
					
						
							|  |  |  | 						const dependency = dependencies[i]; | 
					
						
							|  |  |  | 						moduleGraph.setResolvedModule(originModule, dependency, module); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 					if (moduleGraph.getIssuer(module) === undefined) { | 
					
						
							|  |  |  | 						moduleGraph.setIssuer( | 
					
						
							|  |  |  | 							module, | 
					
						
							|  |  |  | 							originModule !== undefined ? originModule : null | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					if (module !== newModule) { | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 						if (currentProfile !== undefined) { | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 							const otherProfile = moduleGraph.getProfile(module); | 
					
						
							|  |  |  | 							if (otherProfile !== undefined) { | 
					
						
							|  |  |  | 								currentProfile.mergeInto(otherProfile); | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								moduleGraph.setProfile(module, currentProfile); | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 					this.buildModule(module, err => { | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 						if (err) { | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 							if (!err.module) { | 
					
						
							|  |  |  | 								err.module = module; | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							this.errors.push(err); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 							return callback(err); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-09-26 16:27:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						// This avoids deadlocks for circular dependencies
 | 
					
						
							|  |  |  | 						if (this.processDependenciesQueue.isProcessing(module)) { | 
					
						
							|  |  |  | 							return callback(); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						this.processModuleDependencies(module, err => { | 
					
						
							|  |  |  | 							if (err) { | 
					
						
							|  |  |  | 								return callback(err); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							callback(null, module); | 
					
						
							|  |  |  | 						}); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @typedef {Object} FactorizeModuleOptions | 
					
						
							|  |  |  | 	 * @property {ModuleProfile} currentProfile | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	 * @property {ModuleFactory} factory | 
					
						
							|  |  |  | 	 * @property {Dependency[]} dependencies | 
					
						
							|  |  |  | 	 * @property {Module | null} originModule | 
					
						
							|  |  |  | 	 * @property {string=} context | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {FactorizeModuleOptions} options options object | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	 * @param {ModuleCallback} callback callback | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	factorizeModule(options, callback) { | 
					
						
							|  |  |  | 		this.factorizeQueue.add(options, callback); | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {FactorizeModuleOptions} options options object | 
					
						
							|  |  |  | 	 * @param {ModuleCallback} callback callback | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	_factorizeModule( | 
					
						
							|  |  |  | 		{ currentProfile, factory, dependencies, originModule, context }, | 
					
						
							|  |  |  | 		callback | 
					
						
							|  |  |  | 	) { | 
					
						
							|  |  |  | 		if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 			currentProfile.markFactoryStart(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		factory.create( | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				contextInfo: { | 
					
						
							|  |  |  | 					issuer: originModule ? originModule.nameForCondition() : "", | 
					
						
							|  |  |  | 					compiler: this.compiler.name | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				resolveOptions: originModule ? originModule.resolveOptions : undefined, | 
					
						
							|  |  |  | 				context: context | 
					
						
							|  |  |  | 					? context | 
					
						
							|  |  |  | 					: originModule | 
					
						
							| 
									
										
										
										
											2019-02-06 22:37:11 +08:00
										 |  |  | 					? originModule.context | 
					
						
							|  |  |  | 					: this.compiler.context, | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 				dependencies: dependencies | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 			(err, result) => { | 
					
						
							|  |  |  | 				if (result) { | 
					
						
							|  |  |  | 					const { | 
					
						
							|  |  |  | 						fileDependencies, | 
					
						
							|  |  |  | 						contextDependencies, | 
					
						
							|  |  |  | 						missingDependencies | 
					
						
							|  |  |  | 					} = result; | 
					
						
							|  |  |  | 					if (fileDependencies) { | 
					
						
							|  |  |  | 						addAllToSet(this.fileDependencies, fileDependencies); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					if (contextDependencies) { | 
					
						
							|  |  |  | 						addAllToSet(this.contextDependencies, contextDependencies); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					if (missingDependencies) { | 
					
						
							|  |  |  | 						addAllToSet(this.missingDependencies, missingDependencies); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (err) { | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 					const notFoundError = new ModuleNotFoundError( | 
					
						
							|  |  |  | 						originModule, | 
					
						
							|  |  |  | 						err, | 
					
						
							|  |  |  | 						dependencies.map(d => d.loc).filter(Boolean)[0] | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					return callback(notFoundError); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 				if (!result) { | 
					
						
							|  |  |  | 					return callback(); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				const newModule = result.module; | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 				if (!newModule) { | 
					
						
							|  |  |  | 					return callback(); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				if (currentProfile !== undefined) { | 
					
						
							|  |  |  | 					currentProfile.markFactoryEnd(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 				callback(null, newModule); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {string} context context string path | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency dependency used to create Module chain | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {ModuleCallback} callback callback for when module chain is complete | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 	 * @returns {void} will throw if dependency instance is not a valid Dependency | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-22 21:19:05 +08:00
										 |  |  | 	addModuleChain(context, dependency, callback) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if ( | 
					
						
							|  |  |  | 			typeof dependency !== "object" || | 
					
						
							|  |  |  | 			dependency === null || | 
					
						
							|  |  |  | 			!dependency.constructor | 
					
						
							|  |  |  | 		) { | 
					
						
							| 
									
										
										
										
											2018-12-03 00:00:16 +08:00
										 |  |  | 			return callback( | 
					
						
							|  |  |  | 				new WebpackError("Parameter 'dependency' must be a Dependency") | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-06-25 22:23:40 +08:00
										 |  |  | 		const Dep = /** @type {DepConstructor} */ (dependency.constructor); | 
					
						
							|  |  |  | 		const moduleFactory = this.dependencyFactories.get(Dep); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!moduleFactory) { | 
					
						
							| 
									
										
										
										
											2018-12-03 00:00:16 +08:00
										 |  |  | 			return callback( | 
					
						
							|  |  |  | 				new WebpackError( | 
					
						
							| 
									
										
										
										
											2019-06-13 16:51:12 +08:00
										 |  |  | 					`No dependency factory available for this dependency type: ${dependency.constructor.name}` | 
					
						
							| 
									
										
										
										
											2018-12-03 00:00:16 +08:00
										 |  |  | 				) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			); | 
					
						
							| 
									
										
										
										
											2013-05-13 19:34:00 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 		this.handleModuleCreation( | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				factory: moduleFactory, | 
					
						
							|  |  |  | 				dependencies: [dependency], | 
					
						
							|  |  |  | 				originModule: null, | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 				context | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 			err => { | 
					
						
							| 
									
										
										
										
											2019-01-14 22:52:27 +08:00
										 |  |  | 				if (err && this.bail) { | 
					
						
							| 
									
										
										
										
											2018-11-23 18:04:03 +08:00
										 |  |  | 					callback(err); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 					this.buildQueue.stop(); | 
					
						
							|  |  |  | 					this.rebuildQueue.stop(); | 
					
						
							|  |  |  | 					this.processDependenciesQueue.stop(); | 
					
						
							|  |  |  | 					this.factorizeQueue.stop(); | 
					
						
							| 
									
										
										
										
											2019-01-14 22:52:27 +08:00
										 |  |  | 				} else { | 
					
						
							|  |  |  | 					callback(); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-09-07 21:51:27 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {string} context context path for entry | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 	 * @param {EntryDependency} entry entry dependency being created | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @param {string} name name of entry | 
					
						
							|  |  |  | 	 * @param {ModuleCallback} callback callback function | 
					
						
							|  |  |  | 	 * @returns {void} returns | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	addEntry(context, entry, name, callback) { | 
					
						
							| 
									
										
										
										
											2018-10-29 20:49:31 +08:00
										 |  |  | 		this.hooks.addEntry.call(entry, name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 		let entriesArray = this.entryDependencies.get(name); | 
					
						
							|  |  |  | 		if (entriesArray === undefined) { | 
					
						
							|  |  |  | 			entriesArray = []; | 
					
						
							|  |  |  | 			this.entryDependencies.set(name, entriesArray); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 		entriesArray.push(entry); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-05 17:19:09 +08:00
										 |  |  | 		this.addModuleChain(context, entry, (err, module) => { | 
					
						
							|  |  |  | 			if (err) { | 
					
						
							|  |  |  | 				this.hooks.failedEntry.call(entry, name, err); | 
					
						
							|  |  |  | 				return callback(err); | 
					
						
							| 
									
										
										
										
											2015-05-11 00:43:47 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-11-05 17:19:09 +08:00
										 |  |  | 			this.hooks.succeedEntry.call(entry, name, module); | 
					
						
							|  |  |  | 			return callback(null, module); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 05:01:47 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module module to be rebuilt | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {ModuleCallback} callback callback when module finishes rebuilding | 
					
						
							| 
									
										
										
										
											2018-05-07 05:01:47 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	rebuildModule(module, callback) { | 
					
						
							|  |  |  | 		this.rebuildQueue.add(module, callback); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module module to be rebuilt | 
					
						
							|  |  |  | 	 * @param {ModuleCallback} callback callback when module finishes rebuilding | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	_rebuildModule(module, callback) { | 
					
						
							| 
									
										
										
										
											2017-12-07 00:39:42 +08:00
										 |  |  | 		this.hooks.rebuildModule.call(module); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		const oldDependencies = module.dependencies.slice(); | 
					
						
							|  |  |  | 		const oldBlocks = module.blocks.slice(); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 		module.invalidateBuild(); | 
					
						
							|  |  |  | 		this.buildQueue.invalidate(module); | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 		this.buildModule(module, err => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (err) { | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 				return this.hooks.finishRebuildingModule.callAsync(module, err2 => { | 
					
						
							| 
									
										
										
										
											2019-05-10 17:06:25 +08:00
										 |  |  | 					if (err2) { | 
					
						
							|  |  |  | 						callback( | 
					
						
							|  |  |  | 							makeWebpackError(err2, "Compilation.hooks.finishRebuildingModule") | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 						return; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					callback(err); | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2017-12-07 00:39:42 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2013-05-13 19:34:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			this.processModuleDependencies(module, err => { | 
					
						
							|  |  |  | 				if (err) return callback(err); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 				this.removeReasonsOfDependencyBlock(module, { | 
					
						
							|  |  |  | 					dependencies: oldDependencies, | 
					
						
							|  |  |  | 					blocks: oldBlocks | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2019-05-10 17:06:25 +08:00
										 |  |  | 				this.hooks.finishRebuildingModule.callAsync(module, err2 => { | 
					
						
							|  |  |  | 					if (err2) { | 
					
						
							|  |  |  | 						callback( | 
					
						
							|  |  |  | 							makeWebpackError(err2, "Compilation.hooks.finishRebuildingModule") | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 						return; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					callback(null, module); | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-05-13 19:34:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 	finish(callback) { | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 		const modules = this.modules; | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 		this.hooks.finishModules.callAsync(modules, err => { | 
					
						
							|  |  |  | 			if (err) return callback(err); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// extract warnings and errors from modules
 | 
					
						
							|  |  |  | 			for (const module of modules) { | 
					
						
							|  |  |  | 				this.reportDependencyErrorsAndWarnings(module, [module]); | 
					
						
							|  |  |  | 				if (module.isOptional(this.moduleGraph)) { | 
					
						
							|  |  |  | 					for (const error of module.errors) { | 
					
						
							|  |  |  | 						if (!error.module) { | 
					
						
							|  |  |  | 							error.module = module; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						this.warnings.push(error); | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 				} else { | 
					
						
							|  |  |  | 					for (const error of module.errors) { | 
					
						
							|  |  |  | 						if (!error.module) { | 
					
						
							|  |  |  | 							error.module = module; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						this.errors.push(error); | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 				for (const warning of module.warnings) { | 
					
						
							|  |  |  | 					if (!warning.module) { | 
					
						
							|  |  |  | 						warning.module = module; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					this.warnings.push(warning); | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-12-30 21:54:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			callback(); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-05-13 19:34:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	unseal() { | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 		this.hooks.unseal.call(); | 
					
						
							| 
									
										
										
										
											2018-09-06 22:59:11 +08:00
										 |  |  | 		this.chunks.clear(); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this.chunkGroups.length = 0; | 
					
						
							|  |  |  | 		this.namedChunks.clear(); | 
					
						
							|  |  |  | 		this.namedChunkGroups.clear(); | 
					
						
							| 
									
										
										
										
											2018-09-05 20:22:10 +08:00
										 |  |  | 		this.entrypoints.clear(); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.additionalChunkAssets.length = 0; | 
					
						
							|  |  |  | 		this.assets = {}; | 
					
						
							| 
									
										
										
										
											2018-08-21 22:12:00 +08:00
										 |  |  | 		this.moduleGraph.removeAllModuleAttributes(); | 
					
						
							| 
									
										
										
										
											2014-07-29 06:13:25 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-08 20:15:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-12-10 18:34:59 +08:00
										 |  |  | 	 * @param {Callback} callback signals when the call finishes | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	seal(callback) { | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 		const chunkGraph = new ChunkGraph(this.moduleGraph); | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 		this.chunkGraph = chunkGraph; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 		for (const module of this.modules) { | 
					
						
							|  |  |  | 			ChunkGraph.setChunkGraphForModule(module, chunkGraph); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 		this.hooks.seal.call(); | 
					
						
							| 
									
										
										
										
											2017-08-08 15:40:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 04:30:27 +08:00
										 |  |  | 		while (this.hooks.optimizeDependencies.call(this.modules)) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			/* empty */ | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 		this.hooks.afterOptimizeDependencies.call(this.modules); | 
					
						
							| 
									
										
										
										
											2017-08-08 15:40:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-02 22:18:49 +08:00
										 |  |  | 		this.hooks.beforeChunks.call(); | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 		for (const [name, dependencies] of this.entryDependencies) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			const chunk = this.addChunk(name); | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 			chunk.name = name; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			const entrypoint = new Entrypoint(name); | 
					
						
							|  |  |  | 			entrypoint.setRuntimeChunk(chunk); | 
					
						
							|  |  |  | 			this.namedChunkGroups.set(name, entrypoint); | 
					
						
							|  |  |  | 			this.entrypoints.set(name, entrypoint); | 
					
						
							|  |  |  | 			this.chunkGroups.push(entrypoint); | 
					
						
							| 
									
										
										
										
											2018-07-27 04:43:20 +08:00
										 |  |  | 			connectChunkGroupAndChunk(entrypoint, chunk); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 			for (const dep of dependencies) { | 
					
						
							|  |  |  | 				entrypoint.addOrigin(null, { name }, dep.request); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 				const module = this.moduleGraph.getModule(dep); | 
					
						
							|  |  |  | 				if (module) { | 
					
						
							|  |  |  | 					chunkGraph.connectChunkAndModule(chunk, module); | 
					
						
							|  |  |  | 					chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint); | 
					
						
							|  |  |  | 					this.assignDepth(module); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-07-25 14:07:55 +08:00
										 |  |  | 		buildChunkGraph( | 
					
						
							|  |  |  | 			this, | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 			/** @type {Entrypoint[]} */ (this.chunkGroups.slice()) | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-07-02 22:18:49 +08:00
										 |  |  | 		this.hooks.afterChunks.call(this.chunks); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 		this.hooks.optimize.call(); | 
					
						
							| 
									
										
										
										
											2014-07-19 20:32:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 04:30:27 +08:00
										 |  |  | 		while (this.hooks.optimizeModules.call(this.modules)) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			/* empty */ | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 		this.hooks.afterOptimizeModules.call(this.modules); | 
					
						
							| 
									
										
										
										
											2014-01-29 17:13:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 04:30:27 +08:00
										 |  |  | 		while (this.hooks.optimizeChunks.call(this.chunks, this.chunkGroups)) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			/* empty */ | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this.hooks.afterOptimizeChunks.call(this.chunks, this.chunkGroups); | 
					
						
							| 
									
										
										
										
											2015-04-21 01:39:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 		this.hooks.optimizeTree.callAsync(this.chunks, this.modules, err => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (err) { | 
					
						
							| 
									
										
										
										
											2019-05-11 03:37:35 +08:00
										 |  |  | 				return callback( | 
					
						
							|  |  |  | 					makeWebpackError(err, "Compilation.hooks.optimizeTree") | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-09-03 20:16:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.afterOptimizeTree.call(this.chunks, this.modules); | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 04:30:27 +08:00
										 |  |  | 			while (this.hooks.optimizeChunkModules.call(this.chunks, this.modules)) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				/* empty */ | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.afterOptimizeChunkModules.call(this.chunks, this.modules); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			const shouldRecord = this.hooks.shouldRecord.call() !== false; | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.reviveModules.call(this.modules, this.records); | 
					
						
							|  |  |  | 			this.hooks.beforeModuleIds.call(this.modules); | 
					
						
							|  |  |  | 			this.hooks.moduleIds.call(this.modules); | 
					
						
							|  |  |  | 			this.hooks.optimizeModuleIds.call(this.modules); | 
					
						
							|  |  |  | 			this.hooks.afterOptimizeModuleIds.call(this.modules); | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.reviveChunks.call(this.chunks, this.records); | 
					
						
							|  |  |  | 			this.hooks.beforeChunkIds.call(this.chunks); | 
					
						
							| 
									
										
										
										
											2018-09-05 20:22:10 +08:00
										 |  |  | 			this.hooks.chunkIds.call(this.chunks); | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.optimizeChunkIds.call(this.chunks); | 
					
						
							|  |  |  | 			this.hooks.afterOptimizeChunkIds.call(this.chunks); | 
					
						
							| 
									
										
										
										
											2014-01-29 17:13:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 			this.sortItemsWithChunkIds(); | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			if (shouldRecord) { | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 				this.hooks.recordModules.call(this.modules, this.records); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				this.hooks.recordChunks.call(this.chunks, this.records); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-28 17:40:32 +08:00
										 |  |  | 			this.hooks.optimizeCodeGeneration.call(this.modules); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			this.hooks.beforeModuleHash.call(); | 
					
						
							|  |  |  | 			this.createModuleHashes(); | 
					
						
							|  |  |  | 			this.hooks.afterModuleHash.call(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			this.hooks.beforeRuntimeRequirements.call(); | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 			this.processRuntimeRequirements(this.entrypoints.values()); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			this.hooks.afterRuntimeRequirements.call(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.beforeHash.call(); | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 			this.createHash(); | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.afterHash.call(); | 
					
						
							| 
									
										
										
										
											2014-01-29 17:13:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			if (shouldRecord) { | 
					
						
							|  |  |  | 				this.hooks.recordHash.call(this.records); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-17 23:30:25 +08:00
										 |  |  | 			this.clearAssets(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 			this.hooks.beforeModuleAssets.call(); | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 			this.createModuleAssets(); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 			const cont = () => { | 
					
						
							|  |  |  | 				this.hooks.additionalChunkAssets.call(this.chunks); | 
					
						
							|  |  |  | 				this.summarizeDependencies(); | 
					
						
							|  |  |  | 				if (shouldRecord) { | 
					
						
							|  |  |  | 					this.hooks.record.call(this, this.records); | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				this.hooks.additionalAssets.callAsync(err => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					if (err) { | 
					
						
							| 
									
										
										
										
											2019-05-11 03:37:35 +08:00
										 |  |  | 						return callback( | 
					
						
							|  |  |  | 							makeWebpackError(err, "Compilation.hooks.additionalAssets") | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 					this.hooks.optimizeChunkAssets.callAsync(this.chunks, err => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						if (err) { | 
					
						
							| 
									
										
										
										
											2019-05-11 03:37:35 +08:00
										 |  |  | 							return callback( | 
					
						
							|  |  |  | 								makeWebpackError(err, "Compilation.hooks.optimizeChunkAssets") | 
					
						
							|  |  |  | 							); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 						this.hooks.afterOptimizeChunkAssets.call(this.chunks); | 
					
						
							|  |  |  | 						this.hooks.optimizeAssets.callAsync(this.assets, err => { | 
					
						
							|  |  |  | 							if (err) { | 
					
						
							| 
									
										
										
										
											2019-05-11 03:37:35 +08:00
										 |  |  | 								return callback( | 
					
						
							|  |  |  | 									makeWebpackError(err, "Compilation.hooks.optimizeAssets") | 
					
						
							|  |  |  | 								); | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 							} | 
					
						
							|  |  |  | 							this.hooks.afterOptimizeAssets.call(this.assets); | 
					
						
							|  |  |  | 							if (this.hooks.needAdditionalSeal.call()) { | 
					
						
							|  |  |  | 								this.unseal(); | 
					
						
							|  |  |  | 								return this.seal(callback); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							return this.hooks.afterSeal.callAsync(callback); | 
					
						
							|  |  |  | 						}); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2016-10-18 02:26:22 +08:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 			}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (this.hooks.shouldGenerateChunkAssets.call() !== false) { | 
					
						
							|  |  |  | 				this.hooks.beforeChunkAssets.call(); | 
					
						
							|  |  |  | 				this.createChunkAssets(err => { | 
					
						
							|  |  |  | 					if (err) { | 
					
						
							|  |  |  | 						return callback(err); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					cont(); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				cont(); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-10-18 02:26:22 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module moulde to report from | 
					
						
							|  |  |  | 	 * @param {DependenciesBlock[]} blocks blocks to report from | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-10 00:11:34 +08:00
										 |  |  | 	reportDependencyErrorsAndWarnings(module, blocks) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) { | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 			const block = blocks[indexBlock]; | 
					
						
							|  |  |  | 			const dependencies = block.dependencies; | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			for (let indexDep = 0; indexDep < dependencies.length; indexDep++) { | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 				const d = dependencies[indexDep]; | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 				const warnings = d.getWarnings(this.moduleGraph); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (warnings) { | 
					
						
							|  |  |  | 					for (let indexWar = 0; indexWar < warnings.length; indexWar++) { | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 						const w = warnings[indexWar]; | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 						const warning = new ModuleDependencyWarning(module, w, d.loc); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 						this.warnings.push(warning); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 				const errors = d.getErrors(this.moduleGraph); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (errors) { | 
					
						
							|  |  |  | 					for (let indexErr = 0; indexErr < errors.length; indexErr++) { | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 						const e = errors[indexErr]; | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 						const error = new ModuleDependencyError(module, e, d.loc); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 						this.errors.push(error); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-01-10 00:11:34 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-10 00:11:34 +08:00
										 |  |  | 			this.reportDependencyErrorsAndWarnings(module, block.blocks); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 	 * @param {Iterable<Entrypoint>} entrypoints the entrypoints | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	processRuntimeRequirements(entrypoints) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 		const { | 
					
						
							|  |  |  | 			chunkGraph, | 
					
						
							|  |  |  | 			moduleGraph, | 
					
						
							|  |  |  | 			runtimeTemplate, | 
					
						
							|  |  |  | 			dependencyTemplates | 
					
						
							|  |  |  | 		} = this; | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 		const additionalModuleRuntimeRequirements = /** @type {TODO} */ (this.hooks | 
					
						
							|  |  |  | 			.additionalModuleRuntimeRequirements); | 
					
						
							|  |  |  | 		const runtimeRequirementInModule = this.hooks.runtimeRequirementInModule; | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 		for (const module of this.modules) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			if (chunkGraph.getNumberOfModuleChunks(module) > 0) { | 
					
						
							|  |  |  | 				const runtimeRequirements = module.getRuntimeRequirements({ | 
					
						
							|  |  |  | 					dependencyTemplates, | 
					
						
							|  |  |  | 					runtimeTemplate, | 
					
						
							|  |  |  | 					moduleGraph, | 
					
						
							|  |  |  | 					chunkGraph | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 				let set; | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 				if (runtimeRequirements) { | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 					set = new Set(runtimeRequirements); | 
					
						
							|  |  |  | 				} else if (additionalModuleRuntimeRequirements.isUsed()) { | 
					
						
							|  |  |  | 					set = new Set(); | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					continue; | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 				additionalModuleRuntimeRequirements.call(module, set); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				for (const r of set) { | 
					
						
							|  |  |  | 					const hook = runtimeRequirementInModule.get(r); | 
					
						
							|  |  |  | 					if (hook !== undefined) hook.call(module, set); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				chunkGraph.addModuleRuntimeRequirements(module, set); | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (const chunk of this.chunks) { | 
					
						
							|  |  |  | 			const set = new Set(); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			for (const module of chunkGraph.getChunkModulesIterable(chunk)) { | 
					
						
							| 
									
										
										
										
											2018-11-17 01:11:51 +08:00
										 |  |  | 				const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements( | 
					
						
							|  |  |  | 					module | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 				for (const r of runtimeRequirements) set.add(r); | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			this.hooks.additionalChunkRuntimeRequirements.call(chunk, set); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			for (const r of set) { | 
					
						
							|  |  |  | 				this.hooks.runtimeRequirementInChunk.for(r).call(chunk, set); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-17 01:11:51 +08:00
										 |  |  | 			chunkGraph.addChunkRuntimeRequirements(chunk, set); | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-02 20:18:57 +08:00
										 |  |  | 		const treeEntries = new Set( | 
					
						
							|  |  |  | 			Array.from(entrypoints).map(ep => ep.getRuntimeChunk()) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (const chunk of treeEntries) { | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 			const allReferencedChunks = new Set(); | 
					
						
							|  |  |  | 			const queue = new Set(chunk.groupsIterable); | 
					
						
							|  |  |  | 			for (const chunkGroup of queue) { | 
					
						
							|  |  |  | 				for (const chunk of chunkGroup.chunks) { | 
					
						
							|  |  |  | 					allReferencedChunks.add(chunk); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				for (const child of chunkGroup.childrenIterable) { | 
					
						
							|  |  |  | 					queue.add(child); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			const set = new Set(); | 
					
						
							|  |  |  | 			for (const chunk of allReferencedChunks) { | 
					
						
							| 
									
										
										
										
											2018-11-17 01:11:51 +08:00
										 |  |  | 				const runtimeRequirements = chunkGraph.getChunkRuntimeRequirements( | 
					
						
							|  |  |  | 					chunk | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 				for (const r of runtimeRequirements) set.add(r); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			this.hooks.additionalTreeRuntimeRequirements.call(chunk, set); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			for (const r of set) { | 
					
						
							|  |  |  | 				this.hooks.runtimeRequirementInTree.for(r).call(chunk, set); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-11-23 16:37:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			chunkGraph.addTreeRuntimeRequirements(chunk, set); | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Chunk} chunk target chunk | 
					
						
							|  |  |  | 	 * @param {RuntimeModule} module runtime module | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	addRuntimeModule(chunk, module) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 		// Deprecated ModuleGraph association
 | 
					
						
							|  |  |  | 		ModuleGraph.setModuleGraphForModule(module, this.moduleGraph); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// add it to the list
 | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 		this.modules.add(module); | 
					
						
							| 
									
										
										
										
											2018-11-23 17:02:47 +08:00
										 |  |  | 		this._modules.set(module.identifier(), module); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// connect to the chunk graph
 | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 		this.chunkGraph.connectChunkAndModule(chunk, module); | 
					
						
							|  |  |  | 		this.chunkGraph.connectChunkAndRuntimeModule(chunk, module); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Setup internals
 | 
					
						
							| 
									
										
										
										
											2019-02-06 22:37:11 +08:00
										 |  |  | 		const exportsInfo = this.moduleGraph.getExportsInfo(module); | 
					
						
							|  |  |  | 		exportsInfo.setHasProvideInfo(); | 
					
						
							|  |  |  | 		exportsInfo.setUsedForSideEffectsOnly(); | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 		this.chunkGraph.addModuleRuntimeRequirements(module, [ | 
					
						
							|  |  |  | 			RuntimeGlobals.require | 
					
						
							|  |  |  | 		]); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-29 21:13:02 +08:00
										 |  |  | 		// runtime modules don't need ids
 | 
					
						
							|  |  |  | 		this.chunkGraph.setModuleId(module, ""); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 		// Call hook
 | 
					
						
							|  |  |  | 		this.hooks.runtimeModule.call(module, chunk); | 
					
						
							| 
									
										
										
										
											2018-11-06 02:03:12 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-12 00:12:30 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2019-06-14 17:44:54 +08:00
										 |  |  | 	 * @param {string|ChunkGroupOptions} groupOptions options for the chunk group | 
					
						
							| 
									
										
										
										
											2018-05-12 00:12:30 +08:00
										 |  |  | 	 * @param {Module} module the module the references the chunk group | 
					
						
							| 
									
										
										
										
											2018-06-27 20:58:10 +08:00
										 |  |  | 	 * @param {DependencyLocation} loc the location from with the chunk group is referenced (inside of module) | 
					
						
							| 
									
										
										
										
											2018-05-12 00:12:30 +08:00
										 |  |  | 	 * @param {string} request the request from which the the chunk group is referenced | 
					
						
							|  |  |  | 	 * @returns {ChunkGroup} the new or existing chunk group | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 	addChunkInGroup(groupOptions, module, loc, request) { | 
					
						
							|  |  |  | 		if (typeof groupOptions === "string") { | 
					
						
							|  |  |  | 			groupOptions = { name: groupOptions }; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		const name = groupOptions.name; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (name) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			const chunkGroup = this.namedChunkGroups.get(name); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (chunkGroup !== undefined) { | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 				chunkGroup.addOptions(groupOptions); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (module) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 					chunkGroup.addOrigin(module, loc, request); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 				return chunkGroup; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 		const chunkGroup = new ChunkGroup(groupOptions); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (module) chunkGroup.addOrigin(module, loc, request); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		const chunk = this.addChunk(name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-27 04:43:20 +08:00
										 |  |  | 		connectChunkGroupAndChunk(chunkGroup, chunk); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		this.chunkGroups.push(chunkGroup); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (name) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			this.namedChunkGroups.set(name, chunkGroup); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return chunkGroup; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * This method first looks to see if a name is provided for a new chunk, | 
					
						
							|  |  |  | 	 * and first looks to see if any named chunks already exist and reuse that chunk instead. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {string=} name optional chunk name to be provided | 
					
						
							|  |  |  | 	 * @returns {Chunk} create a chunk (invoked during seal event) | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	addChunk(name) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (name) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			const chunk = this.namedChunks.get(name); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (chunk !== undefined) { | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 				return chunk; | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-01-24 20:32:58 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		const chunk = new Chunk(name); | 
					
						
							| 
									
										
										
										
											2018-09-06 22:59:11 +08:00
										 |  |  | 		this.chunks.add(chunk); | 
					
						
							| 
									
										
										
										
											2018-08-21 22:15:48 +08:00
										 |  |  | 		ChunkGraph.setChunkGraphForChunk(chunk, this.chunkGraph); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (name) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			this.namedChunks.set(name, chunk); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		return chunk; | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module module to assign depth | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	assignDepth(module) { | 
					
						
							| 
									
										
										
										
											2018-08-22 01:16:02 +08:00
										 |  |  | 		const moduleGraph = this.moduleGraph; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-24 21:31:18 +08:00
										 |  |  | 		const queue = new Set([module]); | 
					
						
							|  |  |  | 		let depth; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 01:16:02 +08:00
										 |  |  | 		moduleGraph.setDepth(module, 0); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** | 
					
						
							|  |  |  | 		 * @param {Module} module module for processeing | 
					
						
							|  |  |  | 		 * @returns {void} | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2018-02-24 21:31:18 +08:00
										 |  |  | 		const enqueueJob = module => { | 
					
						
							| 
									
										
										
										
											2018-08-22 01:16:02 +08:00
										 |  |  | 			if (!moduleGraph.setDepthIfLower(module, depth)) return; | 
					
						
							| 
									
										
										
										
											2018-02-24 21:31:18 +08:00
										 |  |  | 			queue.add(module); | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** | 
					
						
							|  |  |  | 		 * @param {Dependency} dependency dependency to assign depth to | 
					
						
							|  |  |  | 		 * @returns {void} | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		const assignDepthToDependency = dependency => { | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 			const module = this.moduleGraph.getModule(dependency); | 
					
						
							|  |  |  | 			if (module) { | 
					
						
							|  |  |  | 				enqueueJob(module); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** | 
					
						
							|  |  |  | 		 * @param {DependenciesBlock} block block to assign depth to | 
					
						
							|  |  |  | 		 * @returns {void} | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2018-02-24 21:31:18 +08:00
										 |  |  | 		const assignDepthToDependencyBlock = block => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (block.dependencies) { | 
					
						
							| 
									
										
										
										
											2019-07-10 02:49:10 +08:00
										 |  |  | 				for (const dep of block.dependencies) assignDepthToDependency(dep); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (block.blocks) { | 
					
						
							| 
									
										
										
										
											2019-07-10 02:49:10 +08:00
										 |  |  | 				for (const b of block.blocks) assignDepthToDependencyBlock(b); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2016-12-14 19:03:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (module of queue) { | 
					
						
							| 
									
										
										
										
											2018-02-24 21:31:18 +08:00
										 |  |  | 			queue.delete(module); | 
					
						
							| 
									
										
										
										
											2018-08-22 01:16:02 +08:00
										 |  |  | 			depth = moduleGraph.getDepth(module) + 1; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-24 21:31:18 +08:00
										 |  |  | 			assignDepthToDependencyBlock(module); | 
					
						
							| 
									
										
										
										
											2016-12-14 19:03:24 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency the dependency | 
					
						
							|  |  |  | 	 * @returns {DependencyReference} a reference for the dependency | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2019-01-23 17:29:35 +08:00
										 |  |  | 	getDependencyReference(dependency) { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 		const ref = dependency.getReference(this.moduleGraph); | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 		if (!ref) return null; | 
					
						
							| 
									
										
										
										
											2019-01-23 17:29:35 +08:00
										 |  |  | 		return this.hooks.dependencyReference.call(ref, dependency); | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {Module} module module relationship for removal | 
					
						
							| 
									
										
										
										
											2018-05-07 05:01:47 +08:00
										 |  |  | 	 * @param {DependenciesBlockLike} block //TODO: good description
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 	removeReasonsOfDependencyBlock(module, block) { | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 		const chunkGraph = this.chunkGraph; | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		const iteratorDependency = d => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (!d.module) { | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 				return; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (d.module.removeReason(module, d)) { | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 				for (const chunk of chunkGraph.getModuleChunksIterable(d.module)) { | 
					
						
							| 
									
										
										
										
											2018-01-24 03:08:32 +08:00
										 |  |  | 					this.patchChunksAfterReasonRemoval(d.module, chunk); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (block.blocks) { | 
					
						
							| 
									
										
										
										
											2019-07-10 02:49:10 +08:00
										 |  |  | 			for (const b of block.blocks) { | 
					
						
							|  |  |  | 				this.removeReasonsOfDependencyBlock(module, b); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (block.dependencies) { | 
					
						
							| 
									
										
										
										
											2019-07-10 02:49:10 +08:00
										 |  |  | 			for (const dep of block.dependencies) iteratorDependency(dep); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} module module to patch tie | 
					
						
							|  |  |  | 	 * @param {Chunk} chunk chunk to patch tie | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 	patchChunksAfterReasonRemoval(module, chunk) { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 		if (!module.hasReasons(this.moduleGraph)) { | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 			this.removeReasonsOfDependencyBlock(module, module); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-08-14 17:18:22 +08:00
										 |  |  | 		if (!module.hasReasonForChunk(chunk, this.moduleGraph, this.chunkGraph)) { | 
					
						
							|  |  |  | 			if (this.chunkGraph.isModuleInChunk(module, chunk)) { | 
					
						
							|  |  |  | 				this.chunkGraph.disconnectChunkAndModule(chunk, module); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 				this.removeChunkFromDependencies(module, chunk); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {DependenciesBlock} block block tie for Chunk | 
					
						
							|  |  |  | 	 * @param {Chunk} chunk chunk to remove from dep | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 	removeChunkFromDependencies(block, chunk) { | 
					
						
							|  |  |  | 		const iteratorDependency = d => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (!d.module) { | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 				return; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 			this.patchChunksAfterReasonRemoval(d.module, chunk); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-02 22:09:09 +08:00
										 |  |  | 		const blocks = block.blocks; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) { | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 			const asyncBlock = blocks[indexBlock]; | 
					
						
							| 
									
										
										
										
											2018-08-23 02:17:49 +08:00
										 |  |  | 			const chunkGroup = this.chunkGraph.getBlockChunkGroup(asyncBlock); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 			// Grab all chunks from the first Block's AsyncDepBlock
 | 
					
						
							| 
									
										
										
										
											2018-08-23 02:17:49 +08:00
										 |  |  | 			const chunks = chunkGroup.chunks; | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 			// For each chunk in chunkGroup
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			for (let indexChunk = 0; indexChunk < chunks.length; indexChunk++) { | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 				const iteratedChunk = chunks[indexChunk]; | 
					
						
							| 
									
										
										
										
											2018-08-23 02:17:49 +08:00
										 |  |  | 				chunkGroup.removeChunk(iteratedChunk); | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 				// Recurse
 | 
					
						
							|  |  |  | 				this.removeChunkFromDependencies(block, iteratedChunk); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (block.dependencies) { | 
					
						
							| 
									
										
										
										
											2019-07-10 02:49:10 +08:00
										 |  |  | 			for (const dep of block.dependencies) iteratorDependency(dep); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-11-02 19:17:05 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-08 20:15:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	sortItemsWithChunkIds() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of this.chunkGroups) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			chunkGroup.sortItems(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 		const byMessage = compareSelect( | 
					
						
							|  |  |  | 			err => `${err.message}`, | 
					
						
							|  |  |  | 			compareStringsNumeric | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		const byModule = compareSelect( | 
					
						
							|  |  |  | 			err => (err.module && err.module.identifier()) || "", | 
					
						
							|  |  |  | 			compareStringsNumeric | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		const byLocation = compareSelect(err => err.loc, compareLocations); | 
					
						
							|  |  |  | 		const compareErrors = concatComparators(byModule, byLocation, byMessage); | 
					
						
							| 
									
										
										
										
											2017-08-11 20:35:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 20:11:48 +08:00
										 |  |  | 		this.errors.sort(compareErrors); | 
					
						
							|  |  |  | 		this.warnings.sort(compareErrors); | 
					
						
							| 
									
										
										
										
											2018-04-03 23:23:41 +08:00
										 |  |  | 		this.children.sort(byNameOrHash); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	summarizeDependencies() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for ( | 
					
						
							|  |  |  | 			let indexChildren = 0; | 
					
						
							|  |  |  | 			indexChildren < this.children.length; | 
					
						
							|  |  |  | 			indexChildren++ | 
					
						
							|  |  |  | 		) { | 
					
						
							| 
									
										
										
										
											2017-12-28 21:38:03 +08:00
										 |  |  | 			const child = this.children[indexChildren]; | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 			addAllToSet(this.fileDependencies, child.fileDependencies); | 
					
						
							|  |  |  | 			addAllToSet(this.contextDependencies, child.contextDependencies); | 
					
						
							|  |  |  | 			addAllToSet(this.missingDependencies, child.missingDependencies); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | 		for (const module of this.modules) { | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 			const fileDependencies = module.buildInfo.fileDependencies; | 
					
						
							|  |  |  | 			const contextDependencies = module.buildInfo.contextDependencies; | 
					
						
							| 
									
										
										
										
											2019-01-09 20:23:26 +08:00
										 |  |  | 			const missingDependencies = module.buildInfo.missingDependencies; | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 			if (fileDependencies) { | 
					
						
							|  |  |  | 				addAllToSet(this.fileDependencies, fileDependencies); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 			if (contextDependencies) { | 
					
						
							|  |  |  | 				addAllToSet(this.contextDependencies, contextDependencies); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-01-09 20:23:26 +08:00
										 |  |  | 			if (missingDependencies) { | 
					
						
							|  |  |  | 				addAllToSet(this.missingDependencies, missingDependencies); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 	createModuleHashes() { | 
					
						
							|  |  |  | 		const chunkGraph = this.chunkGraph; | 
					
						
							|  |  |  | 		const { hashFunction, hashDigest, hashDigestLength } = this.outputOptions; | 
					
						
							|  |  |  | 		for (const module of this.modules) { | 
					
						
							|  |  |  | 			const moduleHash = createHash(hashFunction); | 
					
						
							|  |  |  | 			module.updateHash(moduleHash, chunkGraph); | 
					
						
							| 
									
										
										
										
											2019-07-17 22:02:33 +08:00
										 |  |  | 			const moduleHashDigest = /** @type {string} */ (moduleHash.digest( | 
					
						
							|  |  |  | 				hashDigest | 
					
						
							|  |  |  | 			)); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			chunkGraph.setModuleHashes( | 
					
						
							|  |  |  | 				module, | 
					
						
							|  |  |  | 				moduleHashDigest, | 
					
						
							|  |  |  | 				moduleHashDigest.substr(0, hashDigestLength) | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	createHash() { | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  | 		const chunkGraph = this.chunkGraph; | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		const outputOptions = this.outputOptions; | 
					
						
							|  |  |  | 		const hashFunction = outputOptions.hashFunction; | 
					
						
							|  |  |  | 		const hashDigest = outputOptions.hashDigest; | 
					
						
							|  |  |  | 		const hashDigestLength = outputOptions.hashDigestLength; | 
					
						
							| 
									
										
										
										
											2017-11-23 17:59:29 +08:00
										 |  |  | 		const hash = createHash(hashFunction); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 		if (outputOptions.hashSalt) { | 
					
						
							|  |  |  | 			hash.update(outputOptions.hashSalt); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.mainTemplate.updateHash(hash); | 
					
						
							|  |  |  | 		this.chunkTemplate.updateHash(hash); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 		for (const key of Object.keys(this.moduleTemplates).sort()) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			this.moduleTemplates[key].updateHash(hash); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		for (const child of this.children) { | 
					
						
							|  |  |  | 			hash.update(child.hash); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		for (const warning of this.warnings) { | 
					
						
							|  |  |  | 			hash.update(`${warning.message}`); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		for (const error of this.errors) { | 
					
						
							|  |  |  | 			hash.update(`${error.message}`); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-10 20:20:54 +08:00
										 |  |  | 		// clone needed as sort below is inplace mutation
 | 
					
						
							| 
									
										
										
										
											2018-09-06 22:59:11 +08:00
										 |  |  | 		const chunks = Array.from(this.chunks); | 
					
						
							| 
									
										
										
										
											2017-01-10 20:20:54 +08:00
										 |  |  | 		/** | 
					
						
							|  |  |  | 		 * sort here will bring all "falsy" values to the beginning | 
					
						
							|  |  |  | 		 * this is needed as the "hasRuntime()" chunks are dependent on the | 
					
						
							|  |  |  | 		 * hashes of the non-runtime chunks. | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		chunks.sort((a, b) => { | 
					
						
							|  |  |  | 			const aEntry = a.hasRuntime(); | 
					
						
							|  |  |  | 			const bEntry = b.hasRuntime(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (aEntry && !bEntry) return 1; | 
					
						
							|  |  |  | 			if (!aEntry && bEntry) return -1; | 
					
						
							| 
									
										
										
										
											2018-04-03 23:23:41 +08:00
										 |  |  | 			return byId(a, b); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (let i = 0; i < chunks.length; i++) { | 
					
						
							| 
									
										
										
										
											2017-02-05 08:18:40 +08:00
										 |  |  | 			const chunk = chunks[i]; | 
					
						
							| 
									
										
										
										
											2018-11-20 19:55:17 +08:00
										 |  |  | 			// Last minute module hash generation for modules that depend on chunk hashes
 | 
					
						
							|  |  |  | 			for (const module of chunkGraph.getChunkModulesIterable(chunk)) { | 
					
						
							|  |  |  | 				if (!chunkGraph.getModuleHash(module)) { | 
					
						
							|  |  |  | 					const moduleHash = createHash(hashFunction); | 
					
						
							|  |  |  | 					module.updateHash(moduleHash, chunkGraph); | 
					
						
							| 
									
										
										
										
											2019-07-17 22:02:33 +08:00
										 |  |  | 					const moduleHashDigest = /** @type {string} */ (moduleHash.digest( | 
					
						
							|  |  |  | 						hashDigest | 
					
						
							|  |  |  | 					)); | 
					
						
							| 
									
										
										
										
											2018-11-20 19:55:17 +08:00
										 |  |  | 					chunkGraph.setModuleHashes( | 
					
						
							|  |  |  | 						module, | 
					
						
							|  |  |  | 						moduleHashDigest, | 
					
						
							|  |  |  | 						moduleHashDigest.substr(0, hashDigestLength) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-23 17:59:29 +08:00
										 |  |  | 			const chunkHash = createHash(hashFunction); | 
					
						
							| 
									
										
										
										
											2018-09-21 23:39:15 +08:00
										 |  |  | 			try { | 
					
						
							|  |  |  | 				if (outputOptions.hashSalt) { | 
					
						
							|  |  |  | 					chunkHash.update(outputOptions.hashSalt); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-09-25 22:07:42 +08:00
										 |  |  | 				chunk.updateHash(chunkHash, chunkGraph); | 
					
						
							| 
									
										
										
										
											2018-09-21 23:39:15 +08:00
										 |  |  | 				const template = chunk.hasRuntime() | 
					
						
							|  |  |  | 					? this.mainTemplate | 
					
						
							|  |  |  | 					: this.chunkTemplate; | 
					
						
							| 
									
										
										
										
											2018-09-25 22:07:42 +08:00
										 |  |  | 				template.updateHashForChunk(chunkHash, chunk, { | 
					
						
							|  |  |  | 					chunkGraph, | 
					
						
							|  |  |  | 					moduleGraph: this.moduleGraph, | 
					
						
							|  |  |  | 					runtimeTemplate: this.runtimeTemplate | 
					
						
							|  |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2018-09-21 23:39:15 +08:00
										 |  |  | 				this.hooks.chunkHash.call(chunk, chunkHash); | 
					
						
							| 
									
										
										
										
											2019-07-10 17:42:34 +08:00
										 |  |  | 				chunk.hash = /** @type {string} */ (chunkHash.digest(hashDigest)); | 
					
						
							| 
									
										
										
										
											2018-09-21 23:39:15 +08:00
										 |  |  | 				hash.update(chunk.hash); | 
					
						
							|  |  |  | 				chunk.renderedHash = chunk.hash.substr(0, hashDigestLength); | 
					
						
							|  |  |  | 				this.hooks.contentHash.call(chunk); | 
					
						
							|  |  |  | 			} catch (err) { | 
					
						
							|  |  |  | 				this.errors.push(new ChunkRenderError(chunk, "", err)); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-06-25 05:17:12 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-07-10 17:42:34 +08:00
										 |  |  | 		this.fullHash = /** @type {string} */ (hash.digest(hashDigest)); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.hash = this.fullHash.substr(0, hashDigestLength); | 
					
						
							| 
									
										
										
										
											2013-02-13 20:00:01 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 	 * @param {string} update extra information | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	modifyHash(update) { | 
					
						
							|  |  |  | 		const outputOptions = this.outputOptions; | 
					
						
							|  |  |  | 		const hashFunction = outputOptions.hashFunction; | 
					
						
							|  |  |  | 		const hashDigest = outputOptions.hashDigest; | 
					
						
							|  |  |  | 		const hashDigestLength = outputOptions.hashDigestLength; | 
					
						
							| 
									
										
										
										
											2017-11-23 17:59:29 +08:00
										 |  |  | 		const hash = createHash(hashFunction); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		hash.update(this.fullHash); | 
					
						
							|  |  |  | 		hash.update(update); | 
					
						
							| 
									
										
										
										
											2019-07-10 17:42:34 +08:00
										 |  |  | 		this.fullHash = /** @type {string} */ (hash.digest(hashDigest)); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		this.hash = this.fullHash.substr(0, hashDigestLength); | 
					
						
							| 
									
										
										
										
											2016-10-29 17:11:44 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-17 23:30:25 +08:00
										 |  |  | 	clearAssets() { | 
					
						
							|  |  |  | 		for (const chunk of this.chunks) { | 
					
						
							|  |  |  | 			chunk.files.clear(); | 
					
						
							|  |  |  | 			chunk.auxiliaryFiles.clear(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	createModuleAssets() { | 
					
						
							| 
									
										
										
										
											2019-07-17 23:30:25 +08:00
										 |  |  | 		const { chunkGraph } = this; | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | 		for (const module of this.modules) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (module.buildInfo.assets) { | 
					
						
							|  |  |  | 				for (const assetName of Object.keys(module.buildInfo.assets)) { | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  | 					const fileName = this.getPath(assetName, { | 
					
						
							|  |  |  | 						chunkGraph: this.chunkGraph, | 
					
						
							|  |  |  | 						module | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2019-07-17 23:30:25 +08:00
										 |  |  | 					for (const chunk of chunkGraph.getModuleChunksIterable(module)) { | 
					
						
							|  |  |  | 						chunk.auxiliaryFiles.add(fileName); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 					this.assets[fileName] = module.buildInfo.assets[assetName]; | 
					
						
							| 
									
										
										
										
											2017-11-27 22:27:30 +08:00
										 |  |  | 					this.hooks.moduleAsset.call(module, fileName); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-10 18:34:59 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Callback} callback signals when the call finishes | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 	createChunkAssets(callback) { | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 		const outputOptions = this.outputOptions; | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 		const cachedSourceMap = new WeakMap(); | 
					
						
							| 
									
										
										
										
											2018-06-29 16:03:21 +08:00
										 |  |  | 		/** @type {Map<string, {hash: string, source: Source, chunk: Chunk}>} */ | 
					
						
							|  |  |  | 		const alreadyWrittenFiles = new Map(); | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		asyncLib.forEach( | 
					
						
							|  |  |  | 			this.chunks, | 
					
						
							| 
									
										
										
										
											2019-06-14 16:45:56 +08:00
										 |  |  | 			(chunk, callback) => { | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 				/** @type {RenderManifestEntry[]} */ | 
					
						
							|  |  |  | 				let manifest; | 
					
						
							|  |  |  | 				try { | 
					
						
							|  |  |  | 					const template = chunk.hasRuntime() | 
					
						
							|  |  |  | 						? this.mainTemplate | 
					
						
							|  |  |  | 						: this.chunkTemplate; | 
					
						
							|  |  |  | 					manifest = template.getRenderManifest({ | 
					
						
							|  |  |  | 						chunk, | 
					
						
							|  |  |  | 						hash: this.hash, | 
					
						
							|  |  |  | 						fullHash: this.fullHash, | 
					
						
							|  |  |  | 						outputOptions, | 
					
						
							|  |  |  | 						moduleTemplates: this.moduleTemplates, | 
					
						
							|  |  |  | 						dependencyTemplates: this.dependencyTemplates, | 
					
						
							|  |  |  | 						chunkGraph: this.chunkGraph, | 
					
						
							|  |  |  | 						moduleGraph: this.moduleGraph, | 
					
						
							|  |  |  | 						runtimeTemplate: this.runtimeTemplate | 
					
						
							|  |  |  | 					}); // [{ render(), filenameTemplate, pathOptions, identifier, hash }]
 | 
					
						
							|  |  |  | 				} catch (err) { | 
					
						
							|  |  |  | 					this.errors.push(new ChunkRenderError(chunk, "", err)); | 
					
						
							|  |  |  | 					return callback(); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				asyncLib.forEach( | 
					
						
							|  |  |  | 					manifest, | 
					
						
							| 
									
										
										
										
											2019-06-14 16:45:56 +08:00
										 |  |  | 					(fileManifest, callback) => { | 
					
						
							| 
									
										
										
										
											2018-10-11 16:46:48 +08:00
										 |  |  | 						const ident = fileManifest.identifier; | 
					
						
							|  |  |  | 						const cacheName = `${this.compilerPath}/asset/${ident}`; | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 						const usedHash = fileManifest.hash; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 16:46:48 +08:00
										 |  |  | 						this.cache.get(cacheName, usedHash, (err, sourceFromCache) => { | 
					
						
							| 
									
										
										
										
											2019-07-23 14:45:14 +08:00
										 |  |  | 							/** @type {string | function(PathData): string} */ | 
					
						
							|  |  |  | 							let filenameTemplate; | 
					
						
							|  |  |  | 							/** @type {string} */ | 
					
						
							|  |  |  | 							let file; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							let inTry = true; | 
					
						
							|  |  |  | 							const errorAndCallback = err => { | 
					
						
							|  |  |  | 								const filename = | 
					
						
							|  |  |  | 									file || | 
					
						
							|  |  |  | 									(typeof filenameTemplate === "string" | 
					
						
							|  |  |  | 										? filenameTemplate | 
					
						
							|  |  |  | 										: ""); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								this.errors.push(new ChunkRenderError(chunk, filename, err)); | 
					
						
							|  |  |  | 								inTry = false; | 
					
						
							|  |  |  | 								return callback(); | 
					
						
							|  |  |  | 							}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 							try { | 
					
						
							|  |  |  | 								filenameTemplate = fileManifest.filenameTemplate; | 
					
						
							|  |  |  | 								file = this.getPath(filenameTemplate, fileManifest.pathOptions); | 
					
						
							| 
									
										
										
										
											2019-07-19 06:08:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 								if (err) { | 
					
						
							| 
									
										
										
										
											2019-07-23 14:45:14 +08:00
										 |  |  | 									return errorAndCallback(err); | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								let source = sourceFromCache; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								// check if the same filename was already written by another chunk
 | 
					
						
							|  |  |  | 								const alreadyWritten = alreadyWrittenFiles.get(file); | 
					
						
							|  |  |  | 								if (alreadyWritten !== undefined) { | 
					
						
							|  |  |  | 									if (alreadyWritten.hash !== usedHash) { | 
					
						
							| 
									
										
										
										
											2019-07-23 14:45:14 +08:00
										 |  |  | 										inTry = false; | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 										return callback( | 
					
						
							| 
									
										
										
										
											2019-06-14 16:45:56 +08:00
										 |  |  | 											new WebpackError( | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 												`Conflict: Multiple chunks emit assets to the same filename ${file}` + | 
					
						
							|  |  |  | 													` (chunks ${alreadyWritten.chunk.id} and ${chunk.id})` | 
					
						
							|  |  |  | 											) | 
					
						
							|  |  |  | 										); | 
					
						
							|  |  |  | 									} else { | 
					
						
							|  |  |  | 										source = alreadyWritten.source; | 
					
						
							|  |  |  | 									} | 
					
						
							|  |  |  | 								} else if (!source) { | 
					
						
							|  |  |  | 									// render the asset
 | 
					
						
							|  |  |  | 									source = fileManifest.render(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 									// Ensure that source is a cached source to avoid additional cost because of repeated access
 | 
					
						
							|  |  |  | 									if (!(source instanceof CachedSource)) { | 
					
						
							|  |  |  | 										const cacheEntry = cachedSourceMap.get(source); | 
					
						
							|  |  |  | 										if (cacheEntry) { | 
					
						
							|  |  |  | 											source = cacheEntry; | 
					
						
							|  |  |  | 										} else { | 
					
						
							|  |  |  | 											const cachedSource = new CachedSource(source); | 
					
						
							|  |  |  | 											cachedSourceMap.set(source, cachedSource); | 
					
						
							|  |  |  | 											source = cachedSource; | 
					
						
							|  |  |  | 										} | 
					
						
							|  |  |  | 									} | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								if (this.assets[file] && this.assets[file] !== source) { | 
					
						
							| 
									
										
										
										
											2019-07-23 14:45:14 +08:00
										 |  |  | 									inTry = false; | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 									return callback( | 
					
						
							| 
									
										
										
										
											2019-06-14 16:45:56 +08:00
										 |  |  | 										new WebpackError( | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 											`Conflict: Rendering chunk ${chunk.id} ` + | 
					
						
							|  |  |  | 												`emits to the filename ${file} ` + | 
					
						
							|  |  |  | 												"which was already written to by something else " + | 
					
						
							|  |  |  | 												"(but not another chunk)" | 
					
						
							|  |  |  | 										) | 
					
						
							|  |  |  | 									); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								this.assets[file] = source; | 
					
						
							| 
									
										
										
										
											2019-07-17 23:30:25 +08:00
										 |  |  | 								if (fileManifest.auxiliary) { | 
					
						
							|  |  |  | 									chunk.auxiliaryFiles.add(file); | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									chunk.files.add(file); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 								this.hooks.chunkAsset.call(chunk, file); | 
					
						
							|  |  |  | 								alreadyWrittenFiles.set(file, { | 
					
						
							| 
									
										
										
										
											2018-06-29 16:03:21 +08:00
										 |  |  | 									hash: usedHash, | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 									source, | 
					
						
							|  |  |  | 									chunk | 
					
						
							|  |  |  | 								}); | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 								if (source !== sourceFromCache) { | 
					
						
							| 
									
										
										
										
											2019-07-23 14:45:14 +08:00
										 |  |  | 									this.cache.store(cacheName, usedHash, source, err => { | 
					
						
							|  |  |  | 										if (err) return errorAndCallback(err); | 
					
						
							|  |  |  | 										return callback(); | 
					
						
							|  |  |  | 									}); | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 								} else { | 
					
						
							| 
									
										
										
										
											2019-07-23 14:45:14 +08:00
										 |  |  | 									inTry = false; | 
					
						
							| 
									
										
										
										
											2018-10-09 20:30:59 +08:00
										 |  |  | 									callback(); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 							} catch (err) { | 
					
						
							| 
									
										
										
										
											2019-07-23 14:45:14 +08:00
										 |  |  | 								if (!inTry) throw err; | 
					
						
							|  |  |  | 								errorAndCallback(err); | 
					
						
							| 
									
										
										
										
											2017-12-01 17:43:14 +08:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 						}); | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					callback | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-09-27 13:22:19 +08:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 			callback | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-09-25 22:07:42 +08:00
										 |  |  | 	 * @param {string | function(PathData): string} filename used to get asset path with hash | 
					
						
							| 
									
										
										
										
											2018-08-23 01:23:48 +08:00
										 |  |  | 	 * @param {PathData} data context data | 
					
						
							| 
									
										
										
										
											2018-05-15 18:20:17 +08:00
										 |  |  | 	 * @returns {string} interpolated path | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	getPath(filename, data) { | 
					
						
							| 
									
										
										
										
											2018-10-30 19:02:39 +08:00
										 |  |  | 		if (!data.hash) { | 
					
						
							| 
									
										
										
										
											2019-06-19 19:16:05 +08:00
										 |  |  | 			data = { | 
					
						
							|  |  |  | 				hash: this.hash, | 
					
						
							|  |  |  | 				...data | 
					
						
							|  |  |  | 			}; | 
					
						
							| 
									
										
										
										
											2018-10-30 19:02:39 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-29 01:43:01 +08:00
										 |  |  | 		return this.mainTemplate.getAssetPath(filename, data); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * This function allows you to run another instance of webpack inside of webpack however as | 
					
						
							|  |  |  | 	 * a child with different settings and configurations (if desired) applied. It copies all hooks, plugins | 
					
						
							|  |  |  | 	 * from parent (or top level compiler) and creates a child Compilation | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {string} name name of the child compiler | 
					
						
							| 
									
										
										
										
											2018-12-18 04:35:39 +08:00
										 |  |  | 	 * @param {OutputOptions} outputOptions // Need to convert config schema to types for this
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 	 * @param {Plugin[]} plugins webpack plugins that will be applied | 
					
						
							|  |  |  | 	 * @returns {Compiler} creates a child Compiler instance | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-04-13 19:43:51 +08:00
										 |  |  | 	createChildCompiler(name, outputOptions, plugins) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		const idx = this.childrenCounters[name] || 0; | 
					
						
							| 
									
										
										
										
											2017-04-13 19:43:51 +08:00
										 |  |  | 		this.childrenCounters[name] = idx + 1; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		return this.compiler.createChildCompiler( | 
					
						
							|  |  |  | 			this, | 
					
						
							|  |  |  | 			name, | 
					
						
							|  |  |  | 			idx, | 
					
						
							|  |  |  | 			outputOptions, | 
					
						
							|  |  |  | 			plugins | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	checkConstraints() { | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 		const chunkGraph = this.chunkGraph; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		/** @type {Set<number|string>} */ | 
					
						
							| 
									
										
										
										
											2018-01-05 14:41:09 +08:00
										 |  |  | 		const usedIds = new Set(); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | 		for (const module of this.modules) { | 
					
						
							| 
									
										
										
										
											2018-11-28 20:07:40 +08:00
										 |  |  | 			if (module.type === "runtime") continue; | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | 			const moduleId = chunkGraph.getModuleId(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (moduleId === null) continue; | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			if (usedIds.has(moduleId)) { | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 				throw new Error(`checkConstraints: duplicate module id ${moduleId}`); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-05 14:41:09 +08:00
										 |  |  | 			usedIds.add(moduleId); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 22:59:11 +08:00
										 |  |  | 		for (const chunk of this.chunks) { | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 			for (const module of chunkGraph.getChunkModulesIterable(chunk)) { | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | 				if (!this.modules.has(module)) { | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						"checkConstraints: module in chunk but not in compilation " + | 
					
						
							|  |  |  | 							` ${chunk.debugId} ${module.debugId}` | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			for (const module of chunkGraph.getChunkEntryModulesIterable(chunk)) { | 
					
						
							| 
									
										
										
										
											2018-09-05 22:12:48 +08:00
										 |  |  | 				if (!this.modules.has(module)) { | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						"checkConstraints: entry module in chunk but not in compilation " + | 
					
						
							|  |  |  | 							` ${chunk.debugId} ${module.debugId}` | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of this.chunkGroups) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			chunkGroup.checkConstraints(); | 
					
						
							| 
									
										
										
										
											2017-01-24 02:52:20 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-06 01:00:36 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = Compilation; |