ModuleScope module = new ModuleScope(moduleName, resource, prototype, worker);
// put module scope in map right away to make circular dependencies work
worker.registerModule(resource, module);
// warnings are disabled in shell - enable warnings for module loading
ErrorReporter er = cx.getErrorReporter();
ToolErrorReporter reporter = er instanceof ToolErrorReporter ?
(ToolErrorReporter) er : null;
if (reporter != null && !reporter.isReportingWarnings()) {
try {
reporter.setIsReportingWarnings(true);
script.exec(cx, module);
} finally {
reporter.setIsReportingWarnings(false);
}
} else {
script.exec(cx, module);
}
// Update exports in case module updated module.exports