Skip to content

Commit

Permalink
Fixes #187, better error info when build fails due to misconfiguratio…
Browse files Browse the repository at this point in the history
…n for paths urls.
  • Loading branch information
jrburke committed Jun 9, 2012
1 parent 6579659 commit 24fc3a7
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion build/jslib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,11 @@ function (lang, logger, file, parse, optimize, pragma,
errMessage = '',
failedPluginMap = {},
failedPluginIds = [],
errIds = [];
errIds = [],
errUrlMap = {},
errUrlConflicts = {},
hasErrUrl = false,
errUrl, prop;

//Reset some state set up in requirePatch.js, and clean up require's
//current context.
Expand Down Expand Up @@ -1042,6 +1046,21 @@ function (lang, logger, file, parse, optimize, pragma,
if (registry.hasOwnProperty(id) && id.indexOf('_@r') !== 0) {
if (id.indexOf('_unnormalized') === -1) {
errIds.push(id);
errUrl = registry[id].map.url;

if (errUrlMap[errUrl]) {
hasErrUrl = true;
//This error module has the same URL as another
//error module, could be misconfiguration.
if (!errUrlConflicts[errUrl]) {
errUrlConflicts[errUrl] = [];
//Store the original module that had the same URL.
errUrlConflicts[errUrl].push(errUrlMap[errUrl]);
}
errUrlConflicts[errUrl].push(id);
} else {
errUrlMap[errUrl] = id;
}
}

//Look for plugins that did not call load()
Expand All @@ -1063,6 +1082,18 @@ function (lang, logger, file, parse, optimize, pragma,
failedPluginIds.join(', ') + '\n';
}
errMessage += 'Module loading did not complete for: ' + errIds.join(', ');

if (hasErrUrl) {
errMessage += '\nThe following modules share the same URL. This ' +
'could be a misconfiguration if that URL only has ' +
'one anonymous module in it:';
for (prop in errUrlConflicts) {
if (errUrlConflicts.hasOwnProperty(prop)) {
errMessage += '\n' + prop + ': ' +
errUrlConflicts[prop].join(', ');
}
}
}
throw new Error(errMessage);
}

Expand Down

0 comments on commit 24fc3a7

Please sign in to comment.