| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 15:47:43 +08:00
										 |  |  | const util = require("util"); | 
					
						
							| 
									
										
										
										
											2017-06-18 11:57:11 +08:00
										 |  |  | const SortableSet = require("./util/SortableSet"); | 
					
						
							| 
									
										
										
										
											2018-04-17 16:37:15 +08:00
										 |  |  | const intersect = require("./util/SetHelpers").intersect; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | const GraphHelpers = require("./GraphHelpers"); | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | let debugId = 1000; | 
					
						
							| 
									
										
										
										
											2018-02-17 19:09:35 +08:00
										 |  |  | const ERR_CHUNK_ENTRY = "Chunk.entry was removed. Use hasRuntime()"; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | const ERR_CHUNK_INITIAL = | 
					
						
							|  |  |  | 	"Chunk.initial was removed. Use canBeInitial/isOnlyInitial()"; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-19 20:13:44 +08:00
										 |  |  | const sortById = (a, b) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	if (a.id < b.id) return -1; | 
					
						
							|  |  |  | 	if (b.id < a.id) return 1; | 
					
						
							| 
									
										
										
										
											2017-06-19 20:13:44 +08:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const sortByIdentifier = (a, b) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	if (a.identifier() > b.identifier()) return 1; | 
					
						
							|  |  |  | 	if (a.identifier() < b.identifier()) return -1; | 
					
						
							| 
									
										
										
										
											2017-06-19 20:13:44 +08:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-06-18 11:57:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-03 17:17:08 +08:00
										 |  |  | const getModulesIdent = set => { | 
					
						
							|  |  |  | 	set.sort(); | 
					
						
							|  |  |  | 	let str = ""; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	for (const m of set) { | 
					
						
							| 
									
										
										
										
											2017-11-03 17:17:08 +08:00
										 |  |  | 		str += m.identifier() + "#"; | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-03 17:17:08 +08:00
										 |  |  | 	return str; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const getArray = set => Array.from(set); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const getModulesSize = set => { | 
					
						
							|  |  |  | 	let count = 0; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	for (const module of set) { | 
					
						
							| 
									
										
										
										
											2017-11-03 17:17:08 +08:00
										 |  |  | 		count += module.size(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return count; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-19 20:13:44 +08:00
										 |  |  | class Chunk { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	constructor(name) { | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 		this.id = null; | 
					
						
							|  |  |  | 		this.ids = null; | 
					
						
							|  |  |  | 		this.debugId = debugId++; | 
					
						
							|  |  |  | 		this.name = name; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this.entryModule = undefined; | 
					
						
							| 
									
										
										
										
											2017-06-19 20:13:44 +08:00
										 |  |  | 		this._modules = new SortableSet(undefined, sortByIdentifier); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this._groups = new SortableSet(undefined, sortById); | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 		this.files = []; | 
					
						
							|  |  |  | 		this.rendered = false; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this.hash = undefined; | 
					
						
							| 
									
										
										
										
											2018-03-23 02:52:11 +08:00
										 |  |  | 		this.contentHash = Object.create(null); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		this.renderedHash = undefined; | 
					
						
							|  |  |  | 		this.chunkReason = undefined; | 
					
						
							|  |  |  | 		this.extraAsync = false; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get entry() { | 
					
						
							| 
									
										
										
										
											2018-02-17 19:09:35 +08:00
										 |  |  | 		throw new Error(ERR_CHUNK_ENTRY); | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set entry(data) { | 
					
						
							| 
									
										
										
										
											2018-02-17 19:09:35 +08:00
										 |  |  | 		throw new Error(ERR_CHUNK_ENTRY); | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	get initial() { | 
					
						
							| 
									
										
										
										
											2018-02-17 19:09:35 +08:00
										 |  |  | 		throw new Error(ERR_CHUNK_INITIAL); | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	set initial(data) { | 
					
						
							| 
									
										
										
										
											2018-02-17 19:09:35 +08:00
										 |  |  | 		throw new Error(ERR_CHUNK_INITIAL); | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	hasRuntime() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of this._groups) { | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 			// We only need to check the first one
 | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			return chunkGroup.isInitial() && chunkGroup.getRuntimeChunk() === this; | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 	canBeInitial() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of this._groups) { | 
					
						
							|  |  |  | 			if (chunkGroup.isInitial()) return true; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 	isOnlyInitial() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this._groups.size <= 0) return false; | 
					
						
							|  |  |  | 		for (const chunkGroup of this._groups) { | 
					
						
							|  |  |  | 			if (!chunkGroup.isInitial()) return false; | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	hasEntryModule() { | 
					
						
							|  |  |  | 		return !!this.entryModule; | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 13:55:20 +08:00
										 |  |  | 	addModule(module) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!this._modules.has(module)) { | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 			this._modules.add(module); | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2017-01-26 13:55:20 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	removeModule(module) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this._modules.delete(module)) { | 
					
						
							| 
									
										
										
										
											2017-02-13 18:26:25 +08:00
										 |  |  | 			module.removeChunk(this); | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 	setModules(modules) { | 
					
						
							| 
									
										
										
										
											2017-06-19 20:13:44 +08:00
										 |  |  | 		this._modules = new SortableSet(modules, sortByIdentifier); | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	getNumberOfModules() { | 
					
						
							|  |  |  | 		return this._modules.size; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get modulesIterable() { | 
					
						
							|  |  |  | 		return this._modules; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	addGroup(chunkGroup) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this._groups.has(chunkGroup)) return false; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this._groups.add(chunkGroup); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	removeGroup(chunkGroup) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!this._groups.has(chunkGroup)) return false; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		this._groups.delete(chunkGroup); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	isInGroup(chunkGroup) { | 
					
						
							|  |  |  | 		return this._groups.has(chunkGroup); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	getNumberOfGroups() { | 
					
						
							| 
									
										
										
										
											2018-01-23 15:47:08 +08:00
										 |  |  | 		return this._groups.size; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get groupsIterable() { | 
					
						
							|  |  |  | 		return this._groups; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 	compareTo(otherChunk) { | 
					
						
							| 
									
										
										
										
											2017-06-18 11:57:11 +08:00
										 |  |  | 		this._modules.sort(); | 
					
						
							|  |  |  | 		otherChunk._modules.sort(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this._modules.size > otherChunk._modules.size) return -1; | 
					
						
							|  |  |  | 		if (this._modules.size < otherChunk._modules.size) return 1; | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 		const a = this._modules[Symbol.iterator](); | 
					
						
							|  |  |  | 		const b = otherChunk._modules[Symbol.iterator](); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:15:37 +08:00
										 |  |  | 		// eslint-disable-next-line
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		while (true) { | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 			const aItem = a.next(); | 
					
						
							|  |  |  | 			const bItem = b.next(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (aItem.done) return 0; | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 			const aModuleIdentifier = aItem.value.identifier(); | 
					
						
							|  |  |  | 			const bModuleIdentifier = bItem.value.identifier(); | 
					
						
							| 
									
										
										
										
											2018-04-17 15:35:57 +08:00
										 |  |  | 			if (aModuleIdentifier < bModuleIdentifier) return -1; | 
					
						
							|  |  |  | 			if (aModuleIdentifier > bModuleIdentifier) return 1; | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	containsModule(module) { | 
					
						
							|  |  |  | 		return this._modules.has(module); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	getModules() { | 
					
						
							| 
									
										
										
										
											2017-11-06 19:15:23 +08:00
										 |  |  | 		return this._modules.getFromCache(getArray); | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-01 22:10:27 +08:00
										 |  |  | 	getModulesIdent() { | 
					
						
							| 
									
										
										
										
											2017-11-06 19:15:23 +08:00
										 |  |  | 		return this._modules.getFromUnorderedCache(getModulesIdent); | 
					
						
							| 
									
										
										
										
											2017-06-01 22:10:27 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	remove(reason) { | 
					
						
							| 
									
										
										
										
											2017-01-26 12:47:31 +08:00
										 |  |  | 		// cleanup modules
 | 
					
						
							| 
									
										
										
										
											2017-05-20 20:46:21 +08:00
										 |  |  | 		// Array.from is used here to create a clone, because removeChunk modifies this._modules
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const module of Array.from(this._modules)) { | 
					
						
							| 
									
										
										
										
											2017-01-26 12:42:23 +08:00
										 |  |  | 			module.removeChunk(this); | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of this._groups) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			chunkGroup.removeChunk(this); | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 14:08:35 +08:00
										 |  |  | 	moveModule(module, otherChunk) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		GraphHelpers.disconnectChunkAndModule(this, module); | 
					
						
							|  |  |  | 		GraphHelpers.connectChunkAndModule(otherChunk, module); | 
					
						
							| 
									
										
										
										
											2017-01-26 14:08:35 +08:00
										 |  |  | 		module.rewriteChunkInReasons(this, [otherChunk]); | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 15:43:39 +08:00
										 |  |  | 	integrate(otherChunk, reason) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!this.canBeIntegrated(otherChunk)) { | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 			return false; | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 20:46:21 +08:00
										 |  |  | 		// Array.from is used here to create a clone, because moveModule modifies otherChunk._modules
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const module of Array.from(otherChunk._modules)) { | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | 			otherChunk.moveModule(module, this); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 		otherChunk._modules.clear(); | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of otherChunk._groups) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			chunkGroup.replaceChunk(otherChunk, this); | 
					
						
							|  |  |  | 			this.addGroup(chunkGroup); | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		otherChunk._groups.clear(); | 
					
						
							| 
									
										
										
										
											2017-01-26 14:56:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this.name && otherChunk.name) { | 
					
						
							|  |  |  | 			if (this.name.length !== otherChunk.name.length) | 
					
						
							|  |  |  | 				this.name = | 
					
						
							|  |  |  | 					this.name.length < otherChunk.name.length | 
					
						
							|  |  |  | 						? this.name | 
					
						
							|  |  |  | 						: otherChunk.name; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			else | 
					
						
							|  |  |  | 				this.name = this.name < otherChunk.name ? this.name : otherChunk.name; | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-26 15:08:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-04 01:12:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	split(newChunk) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of this._groups) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			chunkGroup.insertChunk(newChunk, this); | 
					
						
							|  |  |  | 			newChunk.addGroup(chunkGroup); | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	isEmpty() { | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 		return this._modules.size === 0; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	updateHash(hash) { | 
					
						
							|  |  |  | 		hash.update(`${this.id} `); | 
					
						
							|  |  |  | 		hash.update(this.ids ? this.ids.join(",") : ""); | 
					
						
							|  |  |  | 		hash.update(`${this.name || ""} `); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const m of this._modules) { | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 			hash.update(m.hash); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 15:47:45 +08:00
										 |  |  | 	canBeIntegrated(otherChunk) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		const isAvailable = (a, b) => { | 
					
						
							|  |  |  | 			const queue = new Set(b.groupsIterable); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			for (const chunkGroup of queue) { | 
					
						
							|  |  |  | 				if (a.isInGroup(chunkGroup)) continue; | 
					
						
							|  |  |  | 				if (chunkGroup.isInitial()) return false; | 
					
						
							|  |  |  | 				for (const parent of chunkGroup.parentsIterable) queue.add(parent); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this.hasRuntime() !== otherChunk.hasRuntime()) { | 
					
						
							|  |  |  | 			if (this.hasRuntime()) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 				return isAvailable(this, otherChunk); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			} else if (otherChunk.hasRuntime()) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 				return isAvailable(otherChunk, this); | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 				return false; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (this.hasEntryModule() || otherChunk.hasEntryModule()) return false; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 15:41:51 +08:00
										 |  |  | 	addMultiplierAndOverhead(size, options) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		const overhead = | 
					
						
							|  |  |  | 			typeof options.chunkOverhead === "number" ? options.chunkOverhead : 10000; | 
					
						
							|  |  |  | 		const multiplicator = this.canBeInitial() | 
					
						
							|  |  |  | 			? options.entryChunkMultiplicator || 10 | 
					
						
							|  |  |  | 			: 1; | 
					
						
							| 
									
										
										
										
											2017-01-26 15:41:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return size * multiplicator + overhead; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	modulesSize() { | 
					
						
							| 
									
										
										
										
											2017-11-06 19:15:23 +08:00
										 |  |  | 		return this._modules.getFromUnorderedCache(getModulesSize); | 
					
						
							| 
									
										
										
										
											2017-01-26 15:41:51 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	size(options) { | 
					
						
							|  |  |  | 		return this.addMultiplierAndOverhead(this.modulesSize(), options); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 15:47:45 +08:00
										 |  |  | 	integratedSize(otherChunk, options) { | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 		// Chunk if it's possible to integrate this chunk
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!this.canBeIntegrated(otherChunk)) { | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 21:24:33 +08:00
										 |  |  | 		let integratedModulesSize = this.modulesSize(); | 
					
						
							|  |  |  | 		// only count modules that do not exist in this chunk!
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const otherModule of otherChunk._modules) { | 
					
						
							|  |  |  | 			if (!this._modules.has(otherModule)) { | 
					
						
							| 
									
										
										
										
											2017-01-26 21:24:33 +08:00
										 |  |  | 				integratedModulesSize += otherModule.size(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return this.addMultiplierAndOverhead(integratedModulesSize, options); | 
					
						
							| 
									
										
										
										
											2014-02-04 01:12:19 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	sortModules(sortByFn) { | 
					
						
							|  |  |  | 		this._modules.sortWith(sortByFn || sortById); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sortItems(sortChunks) { | 
					
						
							|  |  |  | 		this.sortModules(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 	getAllAsyncChunks() { | 
					
						
							| 
									
										
										
										
											2018-04-17 16:37:15 +08:00
										 |  |  | 		const queue = new Set(); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		const chunks = new Set(); | 
					
						
							| 
									
										
										
										
											2017-12-01 16:46:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 16:37:15 +08:00
										 |  |  | 		const initialChunks = intersect( | 
					
						
							|  |  |  | 			Array.from(this.groupsIterable, g => new Set(g.chunks)) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (const chunkGroup of this.groupsIterable) { | 
					
						
							|  |  |  | 			for (const child of chunkGroup.childrenIterable) queue.add(child); | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of queue) { | 
					
						
							|  |  |  | 			for (const chunk of chunkGroup.chunks) { | 
					
						
							|  |  |  | 				if (!initialChunks.has(chunk)) chunks.add(chunk); | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			for (const child of chunkGroup.childrenIterable) queue.add(child); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 		return chunks; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	getChunkMaps(realHash) { | 
					
						
							|  |  |  | 		const chunkHashMap = Object.create(null); | 
					
						
							| 
									
										
										
										
											2018-03-23 02:52:11 +08:00
										 |  |  | 		const chunkContentHashMap = Object.create(null); | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 		const chunkNameMap = Object.create(null); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunk of this.getAllAsyncChunks()) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			chunkHashMap[chunk.id] = realHash ? chunk.hash : chunk.renderedHash; | 
					
						
							| 
									
										
										
										
											2018-03-23 02:52:11 +08:00
										 |  |  | 			for (const key of Object.keys(chunk.contentHash)) { | 
					
						
							|  |  |  | 				if (!chunkContentHashMap[key]) | 
					
						
							|  |  |  | 					chunkContentHashMap[key] = Object.create(null); | 
					
						
							|  |  |  | 				chunkContentHashMap[key][chunk.id] = chunk.contentHash[key]; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (chunk.name) chunkNameMap[chunk.id] = chunk.name; | 
					
						
							| 
									
										
										
										
											2017-12-01 16:46:51 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 		return { | 
					
						
							|  |  |  | 			hash: chunkHashMap, | 
					
						
							| 
									
										
										
										
											2018-03-23 02:52:11 +08:00
										 |  |  | 			contentHash: chunkContentHashMap, | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 			name: chunkNameMap | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2014-06-04 03:03:21 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-04 01:12:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 00:00:34 +08:00
										 |  |  | 	getChildIdsByOrders() { | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 		const lists = new Map(); | 
					
						
							|  |  |  | 		for (const group of this.groupsIterable) { | 
					
						
							|  |  |  | 			if (group.chunks[group.chunks.length - 1] === this) { | 
					
						
							|  |  |  | 				for (const childGroup of group.childrenIterable) { | 
					
						
							|  |  |  | 					// TODO webpack 5 remove this check for options
 | 
					
						
							|  |  |  | 					if (typeof childGroup.options === "object") { | 
					
						
							|  |  |  | 						for (const key of Object.keys(childGroup.options)) { | 
					
						
							| 
									
										
										
										
											2018-04-17 00:00:34 +08:00
										 |  |  | 							if (key.endsWith("Order")) { | 
					
						
							|  |  |  | 								const name = key.substr(0, key.length - "Order".length); | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 								let list = lists.get(name); | 
					
						
							|  |  |  | 								if (list === undefined) lists.set(name, (list = [])); | 
					
						
							|  |  |  | 								list.push({ | 
					
						
							| 
									
										
										
										
											2018-04-17 00:00:34 +08:00
										 |  |  | 									order: childGroup.options[key], | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 									group: childGroup | 
					
						
							|  |  |  | 								}); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		const result = Object.create(null); | 
					
						
							|  |  |  | 		for (const [name, list] of lists) { | 
					
						
							|  |  |  | 			list.sort((a, b) => { | 
					
						
							| 
									
										
										
										
											2018-04-17 00:00:34 +08:00
										 |  |  | 				const cmp = b.order - a.order; | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 				if (cmp !== 0) return cmp; | 
					
						
							|  |  |  | 				// TOOD webpack 5 remove this check of compareTo
 | 
					
						
							| 
									
										
										
										
											2018-04-17 15:36:26 +08:00
										 |  |  | 				if (a.group.compareTo) return a.group.compareTo(b.group); | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 				return 0; | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			result[name] = Array.from( | 
					
						
							|  |  |  | 				list.reduce((set, item) => { | 
					
						
							|  |  |  | 					for (const chunk of item.group.chunks) set.add(chunk.id); | 
					
						
							|  |  |  | 					return set; | 
					
						
							|  |  |  | 				}, new Set()) | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return result; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 00:00:34 +08:00
										 |  |  | 	getChildIdsByOrdersMap() { | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 		const chunkMaps = Object.create(null); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (const chunk of this.getAllAsyncChunks()) { | 
					
						
							| 
									
										
										
										
											2018-04-17 00:00:34 +08:00
										 |  |  | 			const data = chunk.getChildIdsByOrders(); | 
					
						
							| 
									
										
										
										
											2018-04-16 16:27:22 +08:00
										 |  |  | 			for (const key of Object.keys(data)) { | 
					
						
							|  |  |  | 				let chunkMap = chunkMaps[key]; | 
					
						
							|  |  |  | 				if (chunkMap === undefined) | 
					
						
							|  |  |  | 					chunkMaps[key] = chunkMap = Object.create(null); | 
					
						
							|  |  |  | 				chunkMap[chunk.id] = data[key]; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return chunkMaps; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-22 19:15:58 +08:00
										 |  |  | 	getChunkModuleMaps(filterFn) { | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 		const chunkModuleIdMap = Object.create(null); | 
					
						
							|  |  |  | 		const chunkModuleHashMap = Object.create(null); | 
					
						
							| 
									
										
										
										
											2017-12-01 16:46:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunk of this.getAllAsyncChunks()) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 			let array; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			for (const module of chunk.modulesIterable) { | 
					
						
							|  |  |  | 				if (filterFn(module)) { | 
					
						
							|  |  |  | 					if (array === undefined) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 						array = []; | 
					
						
							|  |  |  | 						chunkModuleIdMap[chunk.id] = array; | 
					
						
							| 
									
										
										
										
											2017-12-01 16:46:51 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 					array.push(module.id); | 
					
						
							|  |  |  | 					chunkModuleHashMap[module.id] = module.renderedHash; | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (array !== undefined) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 				array.sort(); | 
					
						
							| 
									
										
										
										
											2017-12-01 16:46:51 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 		return { | 
					
						
							|  |  |  | 			id: chunkModuleIdMap, | 
					
						
							|  |  |  | 			hash: chunkModuleHashMap | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	hasModuleInGraph(filterFn, filterChunkFn) { | 
					
						
							|  |  |  | 		const queue = new Set(this.groupsIterable); | 
					
						
							| 
									
										
										
										
											2017-11-21 19:57:40 +08:00
										 |  |  | 		const chunksProcessed = new Set(); | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const chunkGroup of queue) { | 
					
						
							|  |  |  | 			for (const chunk of chunkGroup.chunks) { | 
					
						
							|  |  |  | 				if (!chunksProcessed.has(chunk)) { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 					chunksProcessed.add(chunk); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					if (!filterChunkFn || filterChunkFn(chunk)) { | 
					
						
							|  |  |  | 						for (const module of chunk.modulesIterable) | 
					
						
							|  |  |  | 							if (filterFn(module)) return true; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-11-21 19:57:40 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			for (const child of chunkGroup.childrenIterable) queue.add(child); | 
					
						
							| 
									
										
										
										
											2017-11-21 19:57:40 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	toString() { | 
					
						
							| 
									
										
										
										
											2017-04-21 16:05:56 +08:00
										 |  |  | 		return `Chunk[${Array.from(this._modules).join()}]`; | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-13 17:03:14 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 03:08:32 +08:00
										 |  |  | // TODO remove in webpack 5
 | 
					
						
							|  |  |  | Object.defineProperty(Chunk.prototype, "forEachModule", { | 
					
						
							|  |  |  | 	configurable: false, | 
					
						
							|  |  |  | 	value: util.deprecate(function(fn) { | 
					
						
							|  |  |  | 		this._modules.forEach(fn); | 
					
						
							|  |  |  | 	}, "Chunk.forEachModule: Use for(const module of chunk.modulesIterable) instead") | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO remove in webpack 5
 | 
					
						
							|  |  |  | Object.defineProperty(Chunk.prototype, "mapModules", { | 
					
						
							|  |  |  | 	configurable: false, | 
					
						
							|  |  |  | 	value: util.deprecate(function(fn) { | 
					
						
							|  |  |  | 		return Array.from(this._modules, fn); | 
					
						
							|  |  |  | 	}, "Chunk.mapModules: Use Array.from(chunk.modulesIterable, fn) instead") | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 05:28:23 +08:00
										 |  |  | // TODO remove in webpack 5
 | 
					
						
							| 
									
										
										
										
											2017-06-24 09:03:48 +08:00
										 |  |  | Object.defineProperty(Chunk.prototype, "chunks", { | 
					
						
							|  |  |  | 	configurable: false, | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	get() { | 
					
						
							|  |  |  | 		throw new Error("Chunk.chunks: Use ChunkGroup.getChildren() instead"); | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2017-06-24 09:03:48 +08:00
										 |  |  | 	set() { | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 		throw new Error("Chunk.chunks: Use ChunkGroup.add/removeChild() instead"); | 
					
						
							| 
									
										
										
										
											2017-06-24 09:03:48 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 05:28:23 +08:00
										 |  |  | // TODO remove in webpack 5
 | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | Object.defineProperty(Chunk.prototype, "parents", { | 
					
						
							|  |  |  | 	configurable: false, | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	get() { | 
					
						
							|  |  |  | 		throw new Error("Chunk.parents: Use ChunkGroup.getParents() instead"); | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set() { | 
					
						
							|  |  |  | 		throw new Error("Chunk.parents: Use ChunkGroup.add/removeParent() instead"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 05:28:23 +08:00
										 |  |  | // TODO remove in webpack 5
 | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | Object.defineProperty(Chunk.prototype, "blocks", { | 
					
						
							|  |  |  | 	configurable: false, | 
					
						
							| 
									
										
										
										
											2018-01-20 00:06:59 +08:00
										 |  |  | 	get() { | 
					
						
							|  |  |  | 		throw new Error("Chunk.blocks: Use ChunkGroup.getBlocks() instead"); | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set() { | 
					
						
							|  |  |  | 		throw new Error("Chunk.blocks: Use ChunkGroup.add/removeBlock() instead"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-09-22 22:38:47 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 05:28:23 +08:00
										 |  |  | // TODO remove in webpack 5
 | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | Object.defineProperty(Chunk.prototype, "entrypoints", { | 
					
						
							|  |  |  | 	configurable: false, | 
					
						
							| 
									
										
										
										
											2018-01-20 18:28:45 +08:00
										 |  |  | 	get() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		throw new Error( | 
					
						
							|  |  |  | 			"Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead" | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-01-20 18:28:45 +08:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 	set() { | 
					
						
							|  |  |  | 		throw new Error("Chunk.entrypoints: Use Chunks.addGroup instead"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 00:17:49 +08:00
										 |  |  | module.exports = Chunk; |