Just making sure I understand this correctly so that I avoid running into similar errors later on, "synth:onLoadMap" and any other similar case run from SetDefaultMapScript runs from a different "scope" than the main module and anything declared/defined in it that is not explicitly added to the global object? If I put
// main
global.somepkg = require('somepkg');
global.otherpkg = require('otherpkg');
is somepkg available from otherpkg without doing global.somepkg = require('somepkg'); from there as well? I have only a rudimentary understanding of CommonJS usage.
Also, as a suggestion, can you replace glob strings in CellScript's files function with a regular expression? I don't know how common this is, but I sometimes save copies of a script as "scriptname.bak.js" if I have to make major changes to scriptname.js and don't want to have to do a lot of backtracking and rewriting if I have to exit before the major change is implemented. This would allow me to do something like
install("@/scripts",files(/scripts\/.*(^bak)\.js$/, true));