mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
Revert "always use vm-based execution in Node environments"
This reverts commit 808c5cddd9625f56648e4713cc05598e03ab53dd.
This commit is contained in:
parent
c2a865e67a
commit
c2a3ea9efb
@ -49,19 +49,15 @@ var __exec;
|
||||
'\n//# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(load.metadata.sourceMap))) || '')
|
||||
}
|
||||
|
||||
if (typeof require != 'undefined' && typeof process != 'undefined' && process.versions && process.versions.node) {
|
||||
// global scoped eval for node
|
||||
var vmModule = 'vm';
|
||||
try {
|
||||
var vm = require(vmModule);
|
||||
}
|
||||
catch(e) {}
|
||||
// Web Worker and Chrome Extensions use original ESML eval
|
||||
// this may lead to some global module execution differences (eg var not defining onto global)
|
||||
if (isWorker || isBrowser && window.chrome && window.chrome.extension) {
|
||||
__exec = function(load) {
|
||||
if (load.metadata.integrity)
|
||||
throw new TypeError('Subresource integrity checking is unavailable in Node.');
|
||||
throw new TypeError('Subresource integrity checking is not supported in Web Workers or Chrome Extensions.');
|
||||
try {
|
||||
preExec(this, load);
|
||||
vm.runInThisContext(getSource(load));
|
||||
new Function(getSource(load)).call(__global);
|
||||
postExec();
|
||||
}
|
||||
catch(e) {
|
||||
@ -72,7 +68,7 @@ var __exec;
|
||||
}
|
||||
|
||||
// use script injection eval to get identical global script behaviour
|
||||
if (!__exec && typeof document != 'undefined' && !isWorker && !(isBrowser && window.chrome && window.chrome.extension)) {
|
||||
else if (typeof document != 'undefined') {
|
||||
var head;
|
||||
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
@ -104,21 +100,21 @@ var __exec;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Web Worker and Chrome Extensions use original ESML eval
|
||||
// this may lead to some global module execution differences (eg var not defining onto global)
|
||||
else if (!__exec) {
|
||||
else {
|
||||
// global scoped eval for node
|
||||
var vmModule = 'vm';
|
||||
var vm = require(vmModule);
|
||||
__exec = function(load) {
|
||||
if (load.metadata.integrity)
|
||||
throw new TypeError('Subresource integrity checking is not supported in Web Workers or Chrome Extensions.');
|
||||
throw new TypeError('Subresource integrity checking is unavailable in Node.');
|
||||
try {
|
||||
preExec(this, load);
|
||||
new Function(getSource(load)).call(__global);
|
||||
vm.runInThisContext(getSource(load));
|
||||
postExec();
|
||||
}
|
||||
catch(e) {
|
||||
postExec();
|
||||
throw addToError(e, 'Evaluating ' + load.address);
|
||||
throw addToError(e.toString(), 'Evaluating ' + load.address);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user