Skip to content

Commit 24fc3a7

Browse files
committed
Fixes requirejs#187, better error info when build fails due to misconfiguration for paths urls.
1 parent 6579659 commit 24fc3a7

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

build/jslib/build.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,11 @@ function (lang, logger, file, parse, optimize, pragma,
996996
errMessage = '',
997997
failedPluginMap = {},
998998
failedPluginIds = [],
999-
errIds = [];
999+
errIds = [],
1000+
errUrlMap = {},
1001+
errUrlConflicts = {},
1002+
hasErrUrl = false,
1003+
errUrl, prop;
10001004

10011005
//Reset some state set up in requirePatch.js, and clean up require's
10021006
//current context.
@@ -1042,6 +1046,21 @@ function (lang, logger, file, parse, optimize, pragma,
10421046
if (registry.hasOwnProperty(id) && id.indexOf('_@r') !== 0) {
10431047
if (id.indexOf('_unnormalized') === -1) {
10441048
errIds.push(id);
1049+
errUrl = registry[id].map.url;
1050+
1051+
if (errUrlMap[errUrl]) {
1052+
hasErrUrl = true;
1053+
//This error module has the same URL as another
1054+
//error module, could be misconfiguration.
1055+
if (!errUrlConflicts[errUrl]) {
1056+
errUrlConflicts[errUrl] = [];
1057+
//Store the original module that had the same URL.
1058+
errUrlConflicts[errUrl].push(errUrlMap[errUrl]);
1059+
}
1060+
errUrlConflicts[errUrl].push(id);
1061+
} else {
1062+
errUrlMap[errUrl] = id;
1063+
}
10451064
}
10461065

10471066
//Look for plugins that did not call load()
@@ -1063,6 +1082,18 @@ function (lang, logger, file, parse, optimize, pragma,
10631082
failedPluginIds.join(', ') + '\n';
10641083
}
10651084
errMessage += 'Module loading did not complete for: ' + errIds.join(', ');
1085+
1086+
if (hasErrUrl) {
1087+
errMessage += '\nThe following modules share the same URL. This ' +
1088+
'could be a misconfiguration if that URL only has ' +
1089+
'one anonymous module in it:';
1090+
for (prop in errUrlConflicts) {
1091+
if (errUrlConflicts.hasOwnProperty(prop)) {
1092+
errMessage += '\n' + prop + ': ' +
1093+
errUrlConflicts[prop].join(', ');
1094+
}
1095+
}
1096+
}
10661097
throw new Error(errMessage);
10671098
}
10681099

0 commit comments

Comments
 (0)