From a015a0d16fba8f46a95c723931674459e241671a Mon Sep 17 00:00:00 2001 From: guybedford Date: Thu, 10 Mar 2016 14:43:25 +0200 Subject: [PATCH] support conditional aliases, alias subpath fix --- lib/utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index df57638..816cd26 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -69,6 +69,9 @@ function getAlias(loader, canonicalName) { if (pluginIndex != -1) return getAlias(loader, canonicalName.substr(0, pluginIndex)) + '!' + getAlias(loader, canonicalName.substr(pluginIndex + 1)); + // replace subpath conditionals with subpath + canonicalName = canonicalName.replace('/#:./', '/'); + if (canonicalName.match(/\#[\:\{\?]/)) throw new Error('Unable to alias the conditional dependency "' + canonicalName + '".'); @@ -91,7 +94,7 @@ function getAlias(loader, canonicalName) { else if (canonicalName.substr(0, mapped.length) == mapped && (canonicalName.length == mapped.length || canonicalName[mapped.length] == '/')) { bestAlias = alias; - bestAliasSubpath = canonicalName.substr(alias.length); + bestAliasSubpath = canonicalName.substr(mapped.length); bestAliasLength = alias.split('/').length; } });