提交 3b1fdf26 编写于 作者: A Alex Dima

Adopt latest loader

上级 790a8d2e
......@@ -768,8 +768,7 @@ var AMDLoader;
}
contents = nodeInstrumenter(contents, normalizedScriptSrc);
if (!opts.nodeCachedDataDir) {
_this._loadAndEvalScript(moduleManager, scriptSrc, vmScriptSrc, contents, { filename: vmScriptSrc }, recorder);
callback();
_this._loadAndEvalScript(moduleManager, scriptSrc, vmScriptSrc, contents, { filename: vmScriptSrc }, recorder, callback, errorback);
}
else {
var cachedDataPath_1 = _this._getCachedDataPath(opts.nodeCachedDataDir, scriptSrc);
......@@ -780,22 +779,34 @@ var AMDLoader;
produceCachedData: typeof cachedData === 'undefined',
cachedData: cachedData
};
var script = _this._loadAndEvalScript(moduleManager, scriptSrc, vmScriptSrc, contents, options, recorder);
callback();
var script = _this._loadAndEvalScript(moduleManager, scriptSrc, vmScriptSrc, contents, options, recorder, callback, errorback);
_this._processCachedData(moduleManager, script, cachedDataPath_1);
});
}
});
}
};
NodeScriptLoader.prototype._loadAndEvalScript = function (moduleManager, scriptSrc, vmScriptSrc, contents, options, recorder) {
NodeScriptLoader.prototype._loadAndEvalScript = function (moduleManager, scriptSrc, vmScriptSrc, contents, options, recorder, callback, errorback) {
// create script, run script
recorder.record(31 /* NodeBeginEvaluatingScript */, scriptSrc);
var script = new this._vm.Script(contents, options);
var r = script.runInThisContext(options);
r.call(AMDLoader.global, moduleManager.getGlobalAMDRequireFunc(), moduleManager.getGlobalAMDDefineFunc(), vmScriptSrc, this._path.dirname(scriptSrc));
var globalDefineFunc = moduleManager.getGlobalAMDDefineFunc();
var receivedDefineCall = false;
var localDefineFunc = function () {
receivedDefineCall = true;
return globalDefineFunc.apply(null, arguments);
};
localDefineFunc.amd = globalDefineFunc.amd;
r.call(AMDLoader.global, moduleManager.getGlobalAMDRequireFunc(), localDefineFunc, vmScriptSrc, this._path.dirname(scriptSrc));
// signal done
recorder.record(32 /* NodeEndEvaluatingScript */, scriptSrc);
if (receivedDefineCall) {
callback();
}
else {
errorback(new Error("Didn't receive define call in " + scriptSrc + "!"));
}
return script;
};
NodeScriptLoader.prototype._getCachedDataPath = function (basedir, filename) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册