enhanced-resolve
Advanced tools
Comparing version 4.0.0-beta.2 to 4.0.0-beta.3
@@ -27,5 +27,3 @@ /* | ||
this.source = source; | ||
this.name = options.name; | ||
this.alias = options.alias; | ||
this.onlyModule = options.onlyModule; | ||
this.options = options; | ||
this.target = target; | ||
@@ -39,15 +37,17 @@ } | ||
if(!innerRequest) return callback(); | ||
if(innerRequest === this.name || (!this.onlyModule && startsWith(innerRequest, this.name + "/"))) { | ||
if(innerRequest !== this.alias && !startsWith(innerRequest, this.alias + "/")) { | ||
const newRequestStr = this.alias + innerRequest.substr(this.name.length); | ||
const obj = Object.assign({}, request, { | ||
request: newRequestStr | ||
}); | ||
return resolver.doResolve(target, obj, "aliased with mapping '" + this.name + "': '" + this.alias + "' to '" + newRequestStr + "'", resolveContext, (err, result) => { | ||
if(err) return callback(err); | ||
for(const item of this.options) { | ||
if(innerRequest === item.name || (!item.onlyModule && startsWith(innerRequest, item.name + "/"))) { | ||
if(innerRequest !== item.alias && !startsWith(innerRequest, item.alias + "/")) { | ||
const newRequestStr = item.alias + innerRequest.substr(item.name.length); | ||
const obj = Object.assign({}, request, { | ||
request: newRequestStr | ||
}); | ||
return resolver.doResolve(target, obj, "aliased with mapping '" + item.name + "': '" + item.alias + "' to '" + newRequestStr + "'", resolveContext, (err, result) => { | ||
if(err) return callback(err); | ||
// Don't allow other aliasing or raw request | ||
if(result === undefined) return callback(null, null); | ||
callback(null, result); | ||
}); | ||
// Don't allow other aliasing or raw request | ||
if(result === undefined) return callback(null, null); | ||
callback(null, result); | ||
}); | ||
} | ||
} | ||
@@ -54,0 +54,0 @@ } |
@@ -118,3 +118,3 @@ /* | ||
mainFields = mainFields.map(item => { | ||
if(typeof item === "string") { | ||
if(typeof item === "string" || Array.isArray(item)) { | ||
item = { | ||
@@ -183,5 +183,4 @@ name: item, | ||
// described-resolve | ||
alias.forEach(item => { | ||
plugins.push(new AliasPlugin("described-resolve", item, "resolve")); | ||
}); | ||
if(alias.length > 0) | ||
plugins.push(new AliasPlugin("described-resolve", alias, "resolve")); | ||
if(enableConcord) { | ||
@@ -256,5 +255,4 @@ plugins.push(new ConcordModulesPlugin("described-resolve", {}, "resolve")); | ||
// file | ||
alias.forEach(item => { | ||
plugins.push(new AliasPlugin("file", item, "resolve")); | ||
}); | ||
if(alias.length > 0) | ||
plugins.push(new AliasPlugin("file", alias, "resolve")); | ||
if(enableConcord) { | ||
@@ -261,0 +259,0 @@ plugins.push(new ConcordModulesPlugin("file", {}, "resolve")); |
{ | ||
"name": "enhanced-resolve", | ||
"version": "4.0.0-beta.2", | ||
"version": "4.0.0-beta.3", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Offers a async require.resolve function. It's highly configurable.", |
86443
2422