summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.eslintrc.yaml1
-rw-r--r--lib/internal/bootstrap_node.js8
-rw-r--r--lib/internal/loader/ModuleWrap.js3
-rw-r--r--lib/internal/loader/search.js2
-rw-r--r--lib/internal/process.js6
-rw-r--r--lib/module.js10
6 files changed, 18 insertions, 12 deletions
diff --git a/.eslintrc.yaml b/.eslintrc.yaml
index d8768459c2..21901f03a5 100644
--- a/.eslintrc.yaml
+++ b/.eslintrc.yaml
@@ -197,3 +197,4 @@ globals:
LTTNG_HTTP_SERVER_RESPONSE: false
LTTNG_NET_SERVER_CONNECTION: false
LTTNG_NET_STREAM_END: false
+ internalBinding: false
diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js
index e7676c0867..366eff06f0 100644
--- a/lib/internal/bootstrap_node.js
+++ b/lib/internal/bootstrap_node.js
@@ -8,6 +8,7 @@
'use strict';
(function(process) {
+ let internalBinding;
function startup() {
const EventEmitter = NativeModule.require('events');
@@ -20,6 +21,9 @@
setupProcessObject();
+ internalBinding = process._internalBinding;
+ delete process._internalBinding;
+
// do this good and early, since it handles errors.
setupProcessFatal();
@@ -574,7 +578,7 @@
};
NativeModule.wrapper = [
- '(function (exports, require, module, __filename, __dirname) { ',
+ '(function (exports, require, module, internalBinding) {',
'\n});'
];
@@ -590,7 +594,7 @@
lineOffset: 0,
displayErrors: true
});
- fn(this.exports, NativeModule.require, this, this.filename);
+ fn(this.exports, NativeModule.require, this, internalBinding);
this.loaded = true;
} finally {
diff --git a/lib/internal/loader/ModuleWrap.js b/lib/internal/loader/ModuleWrap.js
index 8766041d94..7e5d2be616 100644
--- a/lib/internal/loader/ModuleWrap.js
+++ b/lib/internal/loader/ModuleWrap.js
@@ -1,7 +1,6 @@
'use strict';
-const { ModuleWrap } =
- require('internal/process').internalBinding('module_wrap');
+const { ModuleWrap } = internalBinding('module_wrap');
const debug = require('util').debuglog('esm');
const ArrayJoin = Function.call.bind(Array.prototype.join);
const ArrayMap = Function.call.bind(Array.prototype.map);
diff --git a/lib/internal/loader/search.js b/lib/internal/loader/search.js
index 3d78443c9f..ea46f92dfe 100644
--- a/lib/internal/loader/search.js
+++ b/lib/internal/loader/search.js
@@ -3,7 +3,7 @@
const { URL } = require('url');
const CJSmodule = require('module');
const errors = require('internal/errors');
-const { resolve } = require('internal/process').internalBinding('module_wrap');
+const { resolve } = internalBinding('module_wrap');
module.exports = (target, base) => {
if (base === undefined) {
diff --git a/lib/internal/process.js b/lib/internal/process.js
index be1c44c4a0..21a74abba7 100644
--- a/lib/internal/process.js
+++ b/lib/internal/process.js
@@ -4,9 +4,6 @@ const errors = require('internal/errors');
const util = require('util');
const constants = process.binding('constants').os.signals;
-const internalBinding = process._internalBinding;
-delete process._internalBinding;
-
const assert = process.assert = function(x, msg) {
if (!x) throw new errors.Error('ERR_ASSERTION', msg || 'assertion error');
};
@@ -259,6 +256,5 @@ module.exports = {
setupKillAndExit,
setupSignalHandlers,
setupChannel,
- setupRawDebug,
- internalBinding
+ setupRawDebug
};
diff --git a/lib/module.js b/lib/module.js
index c8239cf4e8..a0bbc429df 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -80,8 +80,14 @@ Module._extensions = Object.create(null);
var modulePaths = [];
Module.globalPaths = [];
-Module.wrapper = NativeModule.wrapper;
-Module.wrap = NativeModule.wrap;
+Module.wrap = function(script) {
+ return Module.wrapper[0] + script + Module.wrapper[1];
+};
+
+Module.wrapper = [
+ '(function (exports, require, module, __filename, __dirname) { ',
+ '\n});'
+];
const debug = util.debuglog('module');