| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning"); | 
					
						
							| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | class WarnCaseSensitiveModulesPlugin { | 
					
						
							|  |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2017-12-06 22:01:25 +08:00
										 |  |  | 		compiler.hooks.compilation.tap("WarnCaseSensitiveModulesPlugin", (compilation) => { | 
					
						
							|  |  |  | 			compilation.hooks.seal.tap("WarnCaseSensitiveModulesPlugin", () => { | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 				const moduleWithoutCase = new Map(); | 
					
						
							| 
									
										
										
										
											2017-01-06 19:56:00 +08:00
										 |  |  | 				compilation.modules.forEach(module => { | 
					
						
							| 
									
										
										
										
											2017-01-05 19:12:15 +08:00
										 |  |  | 					const identifier = module.identifier().toLowerCase(); | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 					const array = moduleWithoutCase.get(identifier); | 
					
						
							|  |  |  | 					if(array) { | 
					
						
							|  |  |  | 						array.push(module); | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 						moduleWithoutCase.set(identifier, [module]); | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-01-05 19:12:15 +08:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 				for(const pair of moduleWithoutCase) { | 
					
						
							|  |  |  | 					const array = pair[1]; | 
					
						
							|  |  |  | 					if(array.length > 1) | 
					
						
							|  |  |  | 						compilation.warnings.push(new CaseSensitiveModulesWarning(array)); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = WarnCaseSensitiveModulesPlugin; |