in build_web_compilers/lib/src/dev_compiler_bootstrap.dart [409:453]
String _requireJsConfig(bool soundNullSafety) => '''
// Whenever we fail to load a JS module, try to request the corresponding
// `.errors` file, and log it to the console.
(function() {
var oldOnError = requirejs.onError;
requirejs.onError = function(e) {
if (e.requireModules) {
if (e.message) {
// If error occurred on loading dependencies, we need to invalidate ancessor too.
var ancesor = e.message.match(/needed by: (.*)/);
if (ancesor) {
e.requireModules.push(ancesor[1]);
}
}
for (const module of e.requireModules) {
var errorCallbacks = \$dartLoader.moduleLoadingErrorCallbacks.get(module);
if (errorCallbacks) {
for (const callback of errorCallbacks) callback(e);
errorCallbacks.clear();
}
}
}
if (e.originalError && e.originalError.srcElement) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
var message;
if (this.status == 200) {
message = this.responseText;
} else {
message = "Unknown error loading " + e.originalError.srcElement.src;
}
console.error(message);
var errorEvent = new CustomEvent(
'dartLoadException', { detail: message });
window.dispatchEvent(errorEvent);
}
};
xhr.open("GET", e.originalError.srcElement.src + ".errors", true);
xhr.send();
}
// Also handle errors the normal way.
if (oldOnError) oldOnError(e);
};
}());