Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
pluginFirst builder support
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Aug 13, 2015
1 parent db0f07e commit 76fdaca
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions lib/utils.js
Expand Up @@ -38,11 +38,20 @@ var absURLRegEx = /^[^\/]+:\/\//;
exports.getCanonicalName = getCanonicalName;
function getCanonicalName(loader, normalized) {
// remove the plugin part first
var pluginIndex = normalized.indexOf('!');
var plugin;
if (pluginIndex != -1) {
plugin = normalized.substr(pluginIndex + 1);
normalized = normalized.substr(0, pluginIndex);
if (loader.pluginFirst) {
var pluginIndex = normalized.indexOf('!');
if (pluginIndex != -1) {
plugin = normalized.substr(0, pluginIndex);
normalized = normalized.substr(pluginIndex + 1);
}
}
else {
var pluginIndex = normalized.lastIndexOf('!');
if (pluginIndex != -1) {
plugin = normalized.substr(pluginIndex + 1);
normalized = normalized.substr(0, pluginIndex);
}
}

// now just reverse apply paths rules to get canonical name
Expand Down Expand Up @@ -87,8 +96,14 @@ function getCanonicalName(loader, normalized) {
pathMatch = normalized;
}

if (plugin)
pathMatch += '!' + getCanonicalName(loader, plugin);
if (plugin) {
if (loader.pluginFirst) {
pathMatch = getCanonicalName(loader, plugin) + '!' + pathMatch;
}
else {
pathMatch += '!' + getCanonicalName(loader, plugin);
}
}

return pathMatch;
}
Expand Down

0 comments on commit 76fdaca

Please sign in to comment.