| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-01-10 03:25:04 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | const WebpackError = require("./WebpackError"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = class CaseSensitiveModulesWarning extends WebpackError { | 
					
						
							| 
									
										
										
										
											2017-01-10 03:25:04 +08:00
										 |  |  | 	constructor(modules) { | 
					
						
							|  |  |  | 		super(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | 		this.name = "CaseSensitiveModulesWarning"; | 
					
						
							| 
									
										
										
										
											2017-02-05 07:07:52 +08:00
										 |  |  | 		const sortedModules = this._sort(modules); | 
					
						
							|  |  |  | 		const modulesList = this._moduleMessages(sortedModules); | 
					
						
							| 
									
										
										
										
											2018-02-17 19:09:35 +08:00
										 |  |  | 		this.message = `There are multiple modules with names that only differ in casing.
 | 
					
						
							|  |  |  | This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. | 
					
						
							|  |  |  | Use equal casing. Compare these module identifiers: | 
					
						
							|  |  |  | ${modulesList}`;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-10 03:25:04 +08:00
										 |  |  | 		this.origin = this.module = sortedModules[0]; | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Error.captureStackTrace(this, this.constructor); | 
					
						
							| 
									
										
										
										
											2017-01-10 03:25:04 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	_sort(modules) { | 
					
						
							|  |  |  | 		return modules.slice().sort((a, b) => { | 
					
						
							|  |  |  | 			a = a.identifier(); | 
					
						
							|  |  |  | 			b = b.identifier(); | 
					
						
							| 
									
										
										
										
											2017-02-02 15:57:33 +08:00
										 |  |  | 			/* istanbul ignore next */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (a < b) return -1; | 
					
						
							| 
									
										
										
										
											2017-02-02 15:57:33 +08:00
										 |  |  | 			/* istanbul ignore next */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (a > b) return 1; | 
					
						
							| 
									
										
										
										
											2017-02-02 15:57:33 +08:00
										 |  |  | 			/* istanbul ignore next */ | 
					
						
							| 
									
										
										
										
											2017-01-10 03:25:04 +08:00
										 |  |  | 			return 0; | 
					
						
							| 
									
										
										
										
											2016-06-05 02:02:44 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-10 03:25:04 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	_moduleMessages(modules) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		return modules | 
					
						
							|  |  |  | 			.map(m => { | 
					
						
							|  |  |  | 				let message = `* ${m.identifier()}`; | 
					
						
							|  |  |  | 				const validReasons = m.reasons.filter(reason => reason.module); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (validReasons.length > 0) { | 
					
						
							|  |  |  | 					message += `\n    Used by ${validReasons.length} module(s), i. e.`; | 
					
						
							|  |  |  | 					message += `\n    ${validReasons[0].module.identifier()}`; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				return message; | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 			.join("\n"); | 
					
						
							| 
									
										
										
										
											2017-01-10 03:25:04 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-11 17:51:58 +08:00
										 |  |  | }; |