|
3 | 3 | const NativeModule = require('native_module');
|
4 | 4 | const util = require('util');
|
5 | 5 | const runInThisContext = require('vm').runInThisContext;
|
6 |
| -const runInNewContext = require('vm').runInNewContext; |
7 | 6 | const assert = require('assert').ok;
|
8 | 7 | const fs = require('fs');
|
9 | 8 | const path = require('path');
|
@@ -31,9 +30,6 @@ function Module(id, parent) {
|
31 | 30 | }
|
32 | 31 | module.exports = Module;
|
33 | 32 |
|
34 |
| -// Set the environ variable NODE_MODULE_CONTEXTS=1 to make node load all |
35 |
| -// modules in their own context. |
36 |
| -Module._contextLoad = (+process.env['NODE_MODULE_CONTEXTS'] > 0); |
37 | 33 | Module._cache = {};
|
38 | 34 | Module._pathCache = {};
|
39 | 35 | Module._extensions = {};
|
@@ -391,36 +387,6 @@ Module.prototype._compile = function(content, filename) {
|
391 | 387 |
|
392 | 388 | var dirname = path.dirname(filename);
|
393 | 389 |
|
394 |
| - if (Module._contextLoad) { |
395 |
| - if (self.id !== '.') { |
396 |
| - debug('load submodule'); |
397 |
| - // not root module |
398 |
| - var sandbox = {}; |
399 |
| - for (var k in global) { |
400 |
| - sandbox[k] = global[k]; |
401 |
| - } |
402 |
| - sandbox.require = require; |
403 |
| - sandbox.exports = self.exports; |
404 |
| - sandbox.__filename = filename; |
405 |
| - sandbox.__dirname = dirname; |
406 |
| - sandbox.module = self; |
407 |
| - sandbox.global = sandbox; |
408 |
| - sandbox.root = root; |
409 |
| - |
410 |
| - return runInNewContext(content, sandbox, { filename: filename }); |
411 |
| - } |
412 |
| - |
413 |
| - debug('load root module'); |
414 |
| - // root module |
415 |
| - global.require = require; |
416 |
| - global.exports = self.exports; |
417 |
| - global.__filename = filename; |
418 |
| - global.__dirname = dirname; |
419 |
| - global.module = self; |
420 |
| - |
421 |
| - return runInThisContext(content, { filename: filename }); |
422 |
| - } |
423 |
| - |
424 | 390 | // create wrapper function
|
425 | 391 | var wrapper = Module.wrap(content);
|
426 | 392 |
|
|
0 commit comments