mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-08 06:43:49 +00:00
Refactored browser module boot loader to improve error messages
This commit is contained in:
parent
364d891ca6
commit
a8099114b5
@ -30,19 +30,23 @@ function resolveModuleName(srcModule,dstModule) {
|
|||||||
}
|
}
|
||||||
return src.join("/");
|
return src.join("/");
|
||||||
} else {
|
} else {
|
||||||
// If there was no / or ./ then it's a built in module
|
// If there was no / or ./ then it's a built in module and the name doesn't need resolving
|
||||||
return dstModule;
|
return dstModule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeModule(name) {
|
/*
|
||||||
var require = function(filepath) {
|
Execute the module named 'modName'. The name can optionally be relative to the module named 'modRoot'
|
||||||
return executeModule(resolveModuleName(name,filepath));
|
*/
|
||||||
|
function executeModule(modName,modRoot) {
|
||||||
|
var name = modRoot ? resolveModuleName(modRoot,modName) : modName,
|
||||||
|
require = function(modRequire) {
|
||||||
|
return executeModule(modRequire,name);
|
||||||
},
|
},
|
||||||
exports = {},
|
exports = {},
|
||||||
module = modules[name];
|
module = modules[name];
|
||||||
if(!module) {
|
if(!module) {
|
||||||
throw new Error("Cannot find module named '" + name + "'");
|
throw new Error("Cannot find module named '" + modName + "' required by module '" + modRoot + "'");
|
||||||
}
|
}
|
||||||
if(module.exports) {
|
if(module.exports) {
|
||||||
return module.exports;
|
return module.exports;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user