mirror of https://github.com/webpack/webpack.git
				
				
				
			fix broken FlagDependencyExportsPlugin mem caching
This commit is contained in:
		
							parent
							
								
									4582982670
								
							
						
					
					
						commit
						fabe0d0977
					
				|  | @ -28,7 +28,6 @@ class FlagDependencyExportsPlugin { | |||
| 			compilation => { | ||||
| 				const moduleGraph = compilation.moduleGraph; | ||||
| 				const cache = compilation.getCache("FlagDependencyExportsPlugin"); | ||||
| 				const { moduleMemCaches } = compilation; | ||||
| 				compilation.hooks.finishModules.tapAsync( | ||||
| 					"FlagDependencyExportsPlugin", | ||||
| 					(modules, callback) => { | ||||
|  | @ -42,6 +41,8 @@ class FlagDependencyExportsPlugin { | |||
| 						let statNotCached = 0; | ||||
| 						let statQueueItemsProcessed = 0; | ||||
| 
 | ||||
| 						const { moduleMemCaches } = compilation; | ||||
| 
 | ||||
| 						/** @type {Queue<Module>} */ | ||||
| 						const queue = new Queue(); | ||||
| 
 | ||||
|  | @ -68,12 +69,10 @@ class FlagDependencyExportsPlugin { | |||
| 									return callback(); | ||||
| 								} | ||||
| 								const memCache = moduleMemCaches && moduleMemCaches.get(module); | ||||
| 								const memCacheValue = memCache && memCache.get(this, module); | ||||
| 								const memCacheValue = memCache && memCache.get(module, this); | ||||
| 								if (memCacheValue !== undefined) { | ||||
| 									statRestoredFromMemCache++; | ||||
| 									moduleGraph | ||||
| 										.getExportsInfo(module) | ||||
| 										.restoreProvided(memCacheValue); | ||||
| 									exportsInfo.restoreProvided(memCacheValue); | ||||
| 									return callback(); | ||||
| 								} | ||||
| 								cache.get( | ||||
|  | @ -84,9 +83,7 @@ class FlagDependencyExportsPlugin { | |||
| 
 | ||||
| 										if (result !== undefined) { | ||||
| 											statRestoredFromCache++; | ||||
| 											moduleGraph | ||||
| 												.getExportsInfo(module) | ||||
| 												.restoreProvided(result); | ||||
| 											exportsInfo.restoreProvided(result); | ||||
| 										} else { | ||||
| 											statNotCached++; | ||||
| 											// Without cached info enqueue module for determining the exports
 | ||||
|  | @ -102,9 +99,7 @@ class FlagDependencyExportsPlugin { | |||
| 								if (err) return callback(err); | ||||
| 
 | ||||
| 								/** @type {Set<Module>} */ | ||||
| 								const modulesToStorePersistent = new Set(); | ||||
| 								/** @type {Set<Module>} */ | ||||
| 								const modulesToStoreTransient = new Set(); | ||||
| 								const modulesToStore = new Set(); | ||||
| 
 | ||||
| 								/** @type {Map<Module, Set<Module>>} */ | ||||
| 								const dependencies = new Map(); | ||||
|  | @ -338,9 +333,7 @@ class FlagDependencyExportsPlugin { | |||
| 									} | ||||
| 
 | ||||
| 									if (cacheable) { | ||||
| 										modulesToStorePersistent.add(module); | ||||
| 									} else { | ||||
| 										modulesToStoreTransient.add(module); | ||||
| 										modulesToStore.add(module); | ||||
| 									} | ||||
| 
 | ||||
| 									if (changed) { | ||||
|  | @ -366,7 +359,7 @@ class FlagDependencyExportsPlugin { | |||
| 
 | ||||
| 								logger.time("store provided exports into cache"); | ||||
| 								asyncLib.each( | ||||
| 									modulesToStorePersistent, | ||||
| 									modulesToStore, | ||||
| 									(module, callback) => { | ||||
| 										if (typeof module.buildInfo.hash !== "string") { | ||||
| 											// not cacheable
 | ||||
|  | @ -378,7 +371,7 @@ class FlagDependencyExportsPlugin { | |||
| 										const memCache = | ||||
| 											moduleMemCaches && moduleMemCaches.get(module); | ||||
| 										if (memCache) { | ||||
| 											memCache.set(this, module, cachedData); | ||||
| 											memCache.set(module, this, cachedData); | ||||
| 										} | ||||
| 										cache.store( | ||||
| 											module.identifier(), | ||||
|  | @ -389,17 +382,6 @@ class FlagDependencyExportsPlugin { | |||
| 									}, | ||||
| 									err => { | ||||
| 										logger.timeEnd("store provided exports into cache"); | ||||
| 										if (moduleMemCaches) { | ||||
| 											for (const module of modulesToStoreTransient) { | ||||
| 												const memCache = moduleMemCaches.get(module); | ||||
| 												if (memCache) { | ||||
| 													const cachedData = moduleGraph | ||||
| 														.getExportsInfo(module) | ||||
| 														.getRestoreProvidedData(); | ||||
| 													memCache.set(this, module, cachedData); | ||||
| 												} | ||||
| 											} | ||||
| 										} | ||||
| 										callback(err); | ||||
| 									} | ||||
| 								); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue