| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | var async = require("async"); | 
					
						
							|  |  |  | var Tapable = require("tapable"); | 
					
						
							|  |  |  | var NormalModule = require("./NormalModule"); | 
					
						
							| 
									
										
										
										
											2014-03-02 03:07:42 +08:00
										 |  |  | var RawModule = require("./RawModule"); | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | var Parser = require("./Parser"); | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | var RuleSet = require("./RuleSet"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function loaderToIdent(data) { | 
					
						
							|  |  |  | 	if(!data.options) | 
					
						
							|  |  |  | 		return data.loader; | 
					
						
							|  |  |  | 	if(typeof data.options === "string") | 
					
						
							|  |  |  | 		return data.loader + "?" + data.options; | 
					
						
							|  |  |  | 	if(typeof data.options !== "object") | 
					
						
							|  |  |  | 		throw new Error("loader options must be string or object"); | 
					
						
							| 
									
										
										
										
											2017-01-18 05:26:38 +08:00
										 |  |  | 	if(data.ident) | 
					
						
							|  |  |  | 		return data.loader + "??" + data.ident; | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 	return data.loader + "?" + JSON.stringify(data.options); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-08 23:57:47 +08:00
										 |  |  | function identToLoaderRequest(resultString) { | 
					
						
							|  |  |  | 	var idx = resultString.indexOf("?"); | 
					
						
							|  |  |  | 	var options; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(idx >= 0) { | 
					
						
							|  |  |  | 		options = resultString.substr(idx + 1); | 
					
						
							|  |  |  | 		resultString = resultString.substr(0, idx); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return { | 
					
						
							|  |  |  | 			loader: resultString, | 
					
						
							|  |  |  | 			options: options | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		return { | 
					
						
							|  |  |  | 			loader: resultString | 
					
						
							| 
									
										
										
										
											2017-01-11 17:51:58 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2016-12-08 23:57:47 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | function NormalModuleFactory(context, resolvers, options) { | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	Tapable.call(this); | 
					
						
							|  |  |  | 	this.resolvers = resolvers; | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 	this.ruleSet = new RuleSet(options.rules || options.loaders); | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 	this.cachePredicate = typeof options.unsafeCache === "function" ? options.unsafeCache : Boolean.bind(null, options.unsafeCache); | 
					
						
							| 
									
										
										
										
											2013-02-04 20:59:43 +08:00
										 |  |  | 	this.context = context || ""; | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 	this.parserCache = {}; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 	this.plugin("factory", function() { | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 		var _this = this; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 		return function(result, callback) { | 
					
						
							| 
									
										
										
										
											2016-01-27 00:56:44 +08:00
										 |  |  | 			var resolver = _this.applyPluginsWaterfall0("resolver", null); | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// Ignored
 | 
					
						
							|  |  |  | 			if(!resolver) return callback(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			resolver(result, function onDoneResolving(err, data) { | 
					
						
							|  |  |  | 				if(err) return callback(err); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// Ignored
 | 
					
						
							|  |  |  | 				if(!data) return callback(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// direct module
 | 
					
						
							|  |  |  | 				if(typeof data.source === "function") | 
					
						
							|  |  |  | 					return callback(null, data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 				_this.applyPluginsAsyncWaterfall("after-resolve", data, function(err, result) { | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 					if(err) return callback(err); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// Ignored
 | 
					
						
							|  |  |  | 					if(!result) return callback(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 					var createdModule = _this.applyPluginsBailResult("create-module", result); | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 					if(!createdModule) { | 
					
						
							| 
									
										
										
										
											2016-02-10 02:32:50 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						if(!result.request) { | 
					
						
							|  |  |  | 							return callback(new Error("Empty dependency (no request)")); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 						createdModule = new NormalModule( | 
					
						
							|  |  |  | 							result.request, | 
					
						
							|  |  |  | 							result.userRequest, | 
					
						
							|  |  |  | 							result.rawRequest, | 
					
						
							|  |  |  | 							result.loaders, | 
					
						
							|  |  |  | 							result.resource, | 
					
						
							|  |  |  | 							result.parser | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2015-05-17 00:27:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-27 00:56:44 +08:00
										 |  |  | 					createdModule = _this.applyPluginsWaterfall0("module", createdModule); | 
					
						
							| 
									
										
										
										
											2015-05-17 00:27:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 					return callback(null, createdModule); | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 	this.plugin("resolver", function() { | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 		var _this = this; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 		return function(data, callback) { | 
					
						
							| 
									
										
										
										
											2016-01-26 01:28:56 +08:00
										 |  |  | 			var contextInfo = data.contextInfo; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 			var context = data.context; | 
					
						
							|  |  |  | 			var request = data.request; | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 			var resolveContextInfo = {}; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			var noAutoLoaders = /^-?!/.test(request); | 
					
						
							|  |  |  | 			var noPrePostAutoLoaders = /^!!/.test(request); | 
					
						
							|  |  |  | 			var noPostAutoLoaders = /^-!/.test(request); | 
					
						
							|  |  |  | 			var elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!"); | 
					
						
							|  |  |  | 			var resource = elements.pop(); | 
					
						
							| 
									
										
										
										
											2016-12-08 23:57:47 +08:00
										 |  |  | 			elements = elements.map(identToLoaderRequest); | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			async.parallel([ | 
					
						
							|  |  |  | 				function(callback) { | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 					_this.resolveRequestArray(resolveContextInfo, context, elements, _this.resolvers.loader, callback); | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 				}, | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 				function(callback) { | 
					
						
							|  |  |  | 					if(resource === "" || resource[0] === "?") | 
					
						
							|  |  |  | 						return callback(null, resource); | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 					_this.resolvers.normal.resolve(resolveContextInfo, context, resource, function(err, result) { | 
					
						
							| 
									
										
										
										
											2016-01-02 07:21:54 +08:00
										 |  |  | 						if(err) return callback(err); | 
					
						
							|  |  |  | 						callback(null, result); | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 			], function(err, results) { | 
					
						
							|  |  |  | 				if(err) return callback(err); | 
					
						
							|  |  |  | 				var loaders = results[0]; | 
					
						
							|  |  |  | 				resource = results[1]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-23 00:58:24 +08:00
										 |  |  | 				// translate option idents
 | 
					
						
							|  |  |  | 				try { | 
					
						
							|  |  |  | 					loaders.forEach(function(item) { | 
					
						
							|  |  |  | 						if(typeof item.options === "string" && /^\?/.test(item.options)) { | 
					
						
							|  |  |  | 							item.options = _this.ruleSet.findOptionsByIdent(item.options.substr(1)); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2017-01-11 17:51:58 +08:00
										 |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2016-11-23 00:58:24 +08:00
										 |  |  | 				} catch(e) { | 
					
						
							|  |  |  | 					return callback(e); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 				if(resource === false) | 
					
						
							|  |  |  | 					return callback(null, | 
					
						
							|  |  |  | 						new RawModule("/* (ignored) */", | 
					
						
							|  |  |  | 							"ignored " + context + " " + request, | 
					
						
							|  |  |  | 							request + " (ignored)")); // ignored
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 				var userRequest = loaders.map(loaderToIdent).concat([resource]).join("!"); | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 20:59:50 +08:00
										 |  |  | 				var resourcePath = resource; | 
					
						
							| 
									
										
										
										
											2016-11-23 00:58:24 +08:00
										 |  |  | 				var resourceQuery = ""; | 
					
						
							| 
									
										
										
										
											2015-05-16 20:59:50 +08:00
										 |  |  | 				var queryIndex = resourcePath.indexOf("?"); | 
					
						
							| 
									
										
										
										
											2016-11-23 00:58:24 +08:00
										 |  |  | 				if(queryIndex >= 0) { | 
					
						
							|  |  |  | 					resourceQuery = resourcePath.substr(queryIndex); | 
					
						
							| 
									
										
										
										
											2015-05-16 20:59:50 +08:00
										 |  |  | 					resourcePath = resourcePath.substr(0, queryIndex); | 
					
						
							| 
									
										
										
										
											2016-11-23 00:58:24 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2015-05-16 20:59:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 				var result = _this.ruleSet.exec({ | 
					
						
							|  |  |  | 					resource: resourcePath, | 
					
						
							| 
									
										
										
										
											2016-11-23 00:58:24 +08:00
										 |  |  | 					resourceQuery: resourceQuery, | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 					issuer: contextInfo.issuer | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 				var settings = {}; | 
					
						
							| 
									
										
										
										
											2016-09-21 01:39:07 +08:00
										 |  |  | 				var useLoadersPost = []; | 
					
						
							|  |  |  | 				var useLoaders = []; | 
					
						
							|  |  |  | 				var useLoadersPre = []; | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 				result.forEach(function(r) { | 
					
						
							|  |  |  | 					if(r.type === "use") { | 
					
						
							| 
									
										
										
										
											2016-09-21 01:39:07 +08:00
										 |  |  | 						if(r.enforce === "post" && !noPostAutoLoaders && !noPrePostAutoLoaders) | 
					
						
							|  |  |  | 							useLoadersPost.push(r.value); | 
					
						
							|  |  |  | 						else if(r.enforce === "pre" && !noPrePostAutoLoaders) | 
					
						
							|  |  |  | 							useLoadersPre.push(r.value); | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 						else if(!r.enforce && !noAutoLoaders && !noPrePostAutoLoaders) | 
					
						
							|  |  |  | 							useLoaders.push(r.value); | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						settings[r.type] = r.value; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 				async.parallel([ | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 					_this.resolveRequestArray.bind(_this, resolveContextInfo, _this.context, useLoadersPost, _this.resolvers.loader), | 
					
						
							|  |  |  | 					_this.resolveRequestArray.bind(_this, resolveContextInfo, _this.context, useLoaders, _this.resolvers.loader), | 
					
						
							|  |  |  | 					_this.resolveRequestArray.bind(_this, resolveContextInfo, _this.context, useLoadersPre, _this.resolvers.loader) | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 				], function(err, results) { | 
					
						
							|  |  |  | 					if(err) return callback(err); | 
					
						
							|  |  |  | 					loaders = results[0].concat(loaders).concat(results[1]).concat(results[2]); | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 					process.nextTick(onDoneResolving); | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 				function onDoneResolving() { | 
					
						
							|  |  |  | 					callback(null, { | 
					
						
							|  |  |  | 						context: context, | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 						request: loaders.map(loaderToIdent).concat([resource]).join("!"), | 
					
						
							| 
									
										
										
										
											2016-07-20 18:51:03 +08:00
										 |  |  | 						dependencies: data.dependencies, | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 						userRequest: userRequest, | 
					
						
							|  |  |  | 						rawRequest: request, | 
					
						
							|  |  |  | 						loaders: loaders, | 
					
						
							|  |  |  | 						resource: resource, | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 						parser: _this.getParser(settings.parser) | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 					}); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | module.exports = NormalModuleFactory; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NormalModuleFactory.prototype = Object.create(Tapable.prototype); | 
					
						
							| 
									
										
										
										
											2015-08-18 19:35:57 +08:00
										 |  |  | NormalModuleFactory.prototype.constructor = NormalModuleFactory; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-20 18:51:03 +08:00
										 |  |  | NormalModuleFactory.prototype.create = function(data, callback) { | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 	var _this = this; | 
					
						
							| 
									
										
										
										
											2016-07-20 18:51:03 +08:00
										 |  |  | 	var dependencies = data.dependencies; | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 	var cacheEntry = dependencies[0].__NormalModuleFactoryCache; | 
					
						
							|  |  |  | 	if(cacheEntry) return callback(null, cacheEntry); | 
					
						
							|  |  |  | 	var context = data.context || this.context; | 
					
						
							| 
									
										
										
										
											2016-07-20 18:51:03 +08:00
										 |  |  | 	var request = dependencies[0].request; | 
					
						
							|  |  |  | 	var contextInfo = data.contextInfo || {}; | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 	_this.applyPluginsAsyncWaterfall("before-resolve", { | 
					
						
							| 
									
										
										
										
											2016-07-20 18:51:03 +08:00
										 |  |  | 		contextInfo: contextInfo, | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		context: context, | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 		request: request, | 
					
						
							| 
									
										
										
										
											2016-07-20 18:51:03 +08:00
										 |  |  | 		dependencies: dependencies | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	}, function(err, result) { | 
					
						
							|  |  |  | 		if(err) return callback(err); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-06 01:19:04 +08:00
										 |  |  | 		// Ignored
 | 
					
						
							|  |  |  | 		if(!result) return callback(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-27 00:56:44 +08:00
										 |  |  | 		var factory = _this.applyPluginsWaterfall0("factory", null); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 		// Ignored
 | 
					
						
							|  |  |  | 		if(!factory) return callback(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 		factory(result, function(err, module) { | 
					
						
							|  |  |  | 			if(err) return callback(err); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if(module && _this.cachePredicate(module)) { | 
					
						
							|  |  |  | 				dependencies.forEach(function(d) { | 
					
						
							|  |  |  | 					d.__NormalModuleFactoryCache = module; | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			callback(null, module); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2013-11-06 01:19:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-11 06:31:03 +08:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-26 01:28:56 +08:00
										 |  |  | NormalModuleFactory.prototype.resolveRequestArray = function resolveRequestArray(contextInfo, context, array, resolver, callback) { | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	if(array.length === 0) return callback(null, []); | 
					
						
							|  |  |  | 	async.map(array, function(item, callback) { | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 		resolver.resolve(contextInfo, context, item.loader, function(err, result) { | 
					
						
							| 
									
										
										
										
											2016-11-15 04:25:26 +08:00
										 |  |  | 			if(err && /^[^/]*$/.test(item.loader) && !/-loader$/.test(item.loader)) { | 
					
						
							|  |  |  | 				return resolver.resolve(contextInfo, context, item.loader + "-loader", function(err2) { | 
					
						
							|  |  |  | 					if(!err2) { | 
					
						
							|  |  |  | 						err.message = err.message + "\n" + | 
					
						
							| 
									
										
										
										
											2016-11-16 08:05:43 +08:00
										 |  |  | 							"BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.\n" + | 
					
						
							| 
									
										
										
										
											2016-11-15 04:25:26 +08:00
										 |  |  | 							"                 You need to specify '" + item.loader + "-loader' instead of '" + item.loader + "'."; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					callback(err); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 			if(err) return callback(err); | 
					
						
							| 
									
										
										
										
											2016-12-08 16:39:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-14 19:03:24 +08:00
										 |  |  | 			var optionsOnly = item.options ? { | 
					
						
							|  |  |  | 				options: item.options | 
					
						
							|  |  |  | 			} : undefined; | 
					
						
							| 
									
										
										
										
											2016-12-29 03:07:28 +08:00
										 |  |  | 			return callback(null, Object.assign({}, item, identToLoaderRequest(result), optionsOnly)); | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	}, callback); | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | NormalModuleFactory.prototype.getParser = function getParser(parserOptions) { | 
					
						
							| 
									
										
										
										
											2017-01-11 17:51:58 +08:00
										 |  |  | 	var ident = "null"; | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 	if(parserOptions) { | 
					
						
							|  |  |  | 		if(parserOptions.ident) | 
					
						
							|  |  |  | 			ident = parserOptions.ident; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			ident = JSON.stringify(parserOptions); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	var parser = this.parserCache[ident]; | 
					
						
							|  |  |  | 	if(parser) | 
					
						
							|  |  |  | 		return parser; | 
					
						
							|  |  |  | 	return this.parserCache[ident] = this.createParser(parserOptions); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NormalModuleFactory.prototype.createParser = function createParser(parserOptions) { | 
					
						
							|  |  |  | 	var parser = new Parser(); | 
					
						
							| 
									
										
										
										
											2016-12-05 06:47:19 +08:00
										 |  |  | 	this.applyPlugins2("parser", parser, parserOptions || {}); | 
					
						
							| 
									
										
										
										
											2016-09-14 18:04:42 +08:00
										 |  |  | 	return parser; | 
					
						
							|  |  |  | }; |