mirror of https://github.com/webpack/webpack.git
				
				
				
			avoid allocation of meta info for dependencies when unused
This commit is contained in:
		
							parent
							
								
									52abb681ff
								
							
						
					
					
						commit
						21c08d56ec
					
				|  | @ -655,6 +655,14 @@ class ModuleGraph { | ||||||
| 		return meta; | 		return meta; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * @param {any} thing any thing | ||||||
|  | 	 * @returns {Object} metadata | ||||||
|  | 	 */ | ||||||
|  | 	getMetaIfExisting(thing) { | ||||||
|  | 		return this._metaMap.get(thing); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	// TODO remove in webpack 6
 | 	// TODO remove in webpack 6
 | ||||||
| 	/** | 	/** | ||||||
| 	 * @param {Module} module the module | 	 * @param {Module} module the module | ||||||
|  |  | ||||||
|  | @ -66,7 +66,10 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { | ||||||
| 	 * @returns {string[]} the imported ids | 	 * @returns {string[]} the imported ids | ||||||
| 	 */ | 	 */ | ||||||
| 	getIds(moduleGraph) { | 	getIds(moduleGraph) { | ||||||
| 		return moduleGraph.getMeta(this)[idsSymbol] || this.ids; | 		const meta = moduleGraph.getMetaIfExisting(this); | ||||||
|  | 		if (meta === undefined) return this.ids; | ||||||
|  | 		const ids = meta[idsSymbol]; | ||||||
|  | 		return ids !== undefined ? ids : this.ids; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
|  |  | ||||||
|  | @ -5713,6 +5713,7 @@ declare class ModuleGraph { | ||||||
| 	isAsync(module: Module): boolean; | 	isAsync(module: Module): boolean; | ||||||
| 	setAsync(module: Module): void; | 	setAsync(module: Module): void; | ||||||
| 	getMeta(thing?: any): Object; | 	getMeta(thing?: any): Object; | ||||||
|  | 	getMetaIfExisting(thing?: any): Object; | ||||||
| 	static getModuleGraphForModule( | 	static getModuleGraphForModule( | ||||||
| 		module: Module, | 		module: Module, | ||||||
| 		deprecateMessage: string, | 		deprecateMessage: string, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue