enhanced-resolve
Advanced tools
Comparing version 5.17.1 to 5.18.0
@@ -61,2 +61,3 @@ /* | ||
if (!innerRequest) return callback(); | ||
forEachBail( | ||
@@ -67,3 +68,4 @@ this.options, | ||
let shouldStop = false; | ||
if ( | ||
const matchRequest = | ||
innerRequest === item.name || | ||
@@ -73,6 +75,8 @@ (!item.onlyModule && | ||
? innerRequest.startsWith(`${item.name}/`) | ||
: isSubPath(innerRequest, item.name))) | ||
) { | ||
/** @type {string} */ | ||
const remainingRequest = innerRequest.slice(item.name.length); | ||
: isSubPath(innerRequest, item.name))); | ||
const splitName = item.name.split("*"); | ||
const matchWildcard = !item.onlyModule && splitName.length === 2; | ||
if (matchRequest || matchWildcard) { | ||
/** | ||
@@ -96,8 +100,30 @@ * @param {Alias} alias alias | ||
} | ||
let newRequestStr; | ||
const [prefix, suffix] = splitName; | ||
if ( | ||
matchWildcard && | ||
innerRequest.startsWith(prefix) && | ||
innerRequest.endsWith(suffix) | ||
) { | ||
const match = innerRequest.slice( | ||
prefix.length, | ||
innerRequest.length - suffix.length | ||
); | ||
newRequestStr = item.alias.toString().replace("*", match); | ||
} | ||
if ( | ||
matchRequest && | ||
innerRequest !== alias && | ||
!innerRequest.startsWith(alias + "/") | ||
) { | ||
/** @type {string} */ | ||
const remainingRequest = innerRequest.slice(item.name.length); | ||
newRequestStr = alias + remainingRequest; | ||
} | ||
if (newRequestStr !== undefined) { | ||
shouldStop = true; | ||
const newRequestStr = alias + remainingRequest; | ||
/** @type {ResolveRequest} */ | ||
@@ -129,2 +155,3 @@ const obj = { | ||
}; | ||
/** | ||
@@ -143,2 +170,3 @@ * @param {null|Error} [err] error | ||
}; | ||
if (Array.isArray(item.alias)) { | ||
@@ -154,2 +182,3 @@ return forEachBail( | ||
} | ||
return callback(); | ||
@@ -156,0 +185,0 @@ }, |
{ | ||
"name": "enhanced-resolve", | ||
"version": "5.17.1", | ||
"version": "5.18.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Offers a async require.resolve function. It's highly configurable.", |
212397
6775