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

Commit

Permalink
proper circular conditional error, fix #1599 again
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Apr 1, 2016
1 parent b874bdf commit 8bac50b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Trace.prototype.getLoadRecord = function(canonical, excludeURLs, parentStack) {
function toPackagePath(subPath) {
if (isPlain(subPath)) {
// plain name -> apply global map
return loader.normalize(subPath, normalizedPkgName + '/');
return loader.normalize(subPath);
}
else if (subPath == '.') {
return Promise.resolve(normalizedPkgName);
Expand Down Expand Up @@ -685,11 +685,14 @@ Trace.prototype.inlineConditions = function(tree, loader, conditionalEnv) {
Object.keys(conditionalResolutions).forEach(function(c) {
var resolution = conditionalResolutions[c];

// yes this hangs on circular...
while (conditionalResolutions[resolution]) {
var seen = [];
while (conditionalResolutions[resolution] && seen.indexOf(resolution) == -1) {
seen.push(resolution);
resolution = conditionalResolutions[resolution];
conditionalResolutions[c] = resolution;
}
if (seen.indexOf(resolution) != -1)
throw new Error('Circular conditional resolution ' + seen.join(' -> ') + ' -> ' + resolution);
});

// finally we do a deep clone of the tree, applying the conditional resolutions as we go
Expand Down

0 comments on commit 8bac50b

Please sign in to comment.