diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-10-15 12:10:20 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-10-18 11:36:28 +0200 |
commit | e6dfd59be02c329228c050ad904e1eb046ff379f (patch) | |
tree | d945d77f560dd088dec92c9b243f682ae24f70a5 /lib/module.js | |
parent | b3f9b38174bd2fabd85055a456d06176000fc853 (diff) | |
download | android-node-v8-e6dfd59be02c329228c050ad904e1eb046ff379f.tar.gz android-node-v8-e6dfd59be02c329228c050ad904e1eb046ff379f.tar.bz2 android-node-v8-e6dfd59be02c329228c050ad904e1eb046ff379f.zip |
lib: pass internalBinding more implicitly
Modify passing of the `internalBinding` function so that it’s
easier for core modules to adopt, and also not even accessible
through `--expose-internals`.
This also splits the module wrapper into a separate version for
internal bindings and for CJS modules, which seems like a good
idea given the different semantics.
PR-URL: https://github.com/nodejs/node/pull/16218
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r-- | lib/module.js | 10 |
1 files changed, 8 insertions, 2 deletions
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'); |