| 
									
										
										
										
											2014-03-31 17:33:17 +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-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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-03 04:05:46 +08:00
										 |  |  | /** @typedef {import("./Compiler")} Compiler */ | 
					
						
							| 
									
										
										
										
											2021-04-09 21:41:27 +08:00
										 |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							| 
									
										
										
										
											2018-11-03 04:05:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | class WarnCaseSensitiveModulesPlugin { | 
					
						
							| 
									
										
										
										
											2018-11-03 04:05:46 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Apply the plugin | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the compiler instance | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap( | 
					
						
							|  |  |  | 			"WarnCaseSensitiveModulesPlugin", | 
					
						
							|  |  |  | 			compilation => { | 
					
						
							|  |  |  | 				compilation.hooks.seal.tap("WarnCaseSensitiveModulesPlugin", () => { | 
					
						
							| 
									
										
										
										
											2021-04-09 21:41:27 +08:00
										 |  |  | 					/** @type {Map<string, Map<string, Module>>} */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					const moduleWithoutCase = new Map(); | 
					
						
							|  |  |  | 					for (const module of compilation.modules) { | 
					
						
							| 
									
										
										
										
											2021-04-09 21:41:27 +08:00
										 |  |  | 						const identifier = module.identifier(); | 
					
						
							|  |  |  | 						const lowerIdentifier = identifier.toLowerCase(); | 
					
						
							|  |  |  | 						let map = moduleWithoutCase.get(lowerIdentifier); | 
					
						
							|  |  |  | 						if (map === undefined) { | 
					
						
							|  |  |  | 							map = new Map(); | 
					
						
							|  |  |  | 							moduleWithoutCase.set(lowerIdentifier, map); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2021-04-09 21:41:27 +08:00
										 |  |  | 						map.set(identifier, module); | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					for (const pair of moduleWithoutCase) { | 
					
						
							| 
									
										
										
										
											2021-04-09 21:41:27 +08:00
										 |  |  | 						const map = pair[1]; | 
					
						
							|  |  |  | 						if (map.size > 1) { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 							compilation.warnings.push( | 
					
						
							| 
									
										
										
										
											2021-04-09 21:41:27 +08:00
										 |  |  | 								new CaseSensitiveModulesWarning( | 
					
						
							|  |  |  | 									map.values(), | 
					
						
							|  |  |  | 									compilation.moduleGraph | 
					
						
							|  |  |  | 								) | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 							); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-01-04 15:32:10 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = WarnCaseSensitiveModulesPlugin; |