From e7f710c1d4729890806610e5450d7a0edfb4ac11 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Sat, 22 Sep 2018 09:49:52 -0500 Subject: [PATCH] bootstrapper: move internalBinding to NativeModule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit internalBinding is used so often that it should just automatically be available for usage in internals. PR-URL: https://github.com/nodejs/node/pull/23025 Refs: https://github.com/nodejs/node/commit/2a9eb31 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Joyee Cheung Reviewed-By: Refael Ackermann Reviewed-By: Ruben Bridgewater Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Trivikram Kamat --- lib/.eslintrc.yaml | 1 + lib/_http_client.js | 1 - lib/_http_common.js | 1 - lib/_http_server.js | 1 - lib/_tls_common.js | 1 - lib/_tls_wrap.js | 1 - lib/buffer.js | 1 - lib/child_process.js | 1 - lib/console.js | 1 - lib/crypto.js | 1 - lib/dgram.js | 1 - lib/dns.js | 1 - lib/domain.js | 1 - lib/internal/async_hooks.js | 1 - lib/internal/bash_completion.js | 1 - lib/internal/bootstrap/loaders.js | 4 ++-- lib/internal/child_process.js | 1 - lib/internal/cluster/round_robin_handle.js | 1 - lib/internal/crypto/certificate.js | 1 - lib/internal/crypto/cipher.js | 1 - lib/internal/crypto/keygen.js | 1 - lib/internal/crypto/pbkdf2.js | 1 - lib/internal/crypto/random.js | 1 - lib/internal/crypto/scrypt.js | 1 - lib/internal/crypto/sig.js | 1 - lib/internal/crypto/util.js | 1 - lib/internal/dgram.js | 1 - lib/internal/dns/promises.js | 1 - lib/internal/dns/utils.js | 1 - lib/internal/domexception.js | 1 - lib/internal/encoding.js | 1 - lib/internal/errors.js | 1 - lib/internal/fs/watchers.js | 1 - lib/internal/http2/compat.js | 1 - lib/internal/http2/core.js | 1 - lib/internal/http2/util.js | 1 - lib/internal/modules/cjs/loader.js | 2 +- lib/internal/modules/esm/create_dynamic_module.js | 1 - lib/internal/modules/esm/default_resolve.js | 2 +- lib/internal/modules/esm/module_job.js | 1 - lib/internal/modules/esm/translators.js | 2 +- lib/internal/print_help.js | 1 - lib/internal/process/esm_loader.js | 1 - lib/internal/process/promises.js | 1 - lib/internal/process/stdio.js | 2 -- lib/internal/queue_microtask.js | 1 - lib/internal/stream_base_commons.js | 1 - lib/internal/test/binding.js | 1 - lib/internal/test/heap.js | 1 - lib/internal/timers.js | 1 - lib/internal/trace_events_async_hooks.js | 1 - lib/internal/url.js | 1 - lib/internal/util.js | 1 - lib/internal/util/comparisons.js | 1 - lib/internal/util/inspect.js | 2 -- lib/internal/vm/source_text_module.js | 1 - lib/internal/worker.js | 1 - lib/internal/wrap_js_stream.js | 1 - lib/net.js | 1 - lib/os.js | 1 - lib/perf_hooks.js | 1 - lib/repl.js | 1 - lib/stream.js | 1 - lib/string_decoder.js | 1 - lib/timers.js | 1 - lib/tls.js | 1 - lib/trace_events.js | 1 - lib/tty.js | 1 - lib/util.js | 2 -- lib/v8.js | 1 - lib/vm.js | 1 - 71 files changed, 6 insertions(+), 74 deletions(-) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index a1a0b9490a9177..65c7c88ba0cbe7 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -44,3 +44,4 @@ globals: DCHECK_LE: false DCHECK_LT: false DCHECK_NE: false + internalBinding: false diff --git a/lib/_http_client.js b/lib/_http_client.js index cbc77744894bd9..c83800a93b1da9 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -24,7 +24,6 @@ const util = require('util'); const net = require('net'); const url = require('url'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { HTTPParser } = internalBinding('http_parser'); const assert = require('assert').ok; const { diff --git a/lib/_http_common.js b/lib/_http_common.js index 09f9aebe9b2ff2..1de0ee6025d571 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -21,7 +21,6 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { methods, HTTPParser } = internalBinding('http_parser'); const FreeList = require('internal/freelist'); diff --git a/lib/_http_server.js b/lib/_http_server.js index b216eab32a3542..cc1a428cd66c3b 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -23,7 +23,6 @@ const util = require('util'); const net = require('net'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { HTTPParser } = internalBinding('http_parser'); const assert = require('assert').ok; const { diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 2401bd0b4b1fa5..b8e68eec153fe0 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -34,7 +34,6 @@ const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto; // Lazily loaded from internal/crypto/util. let toBuf = null; -const { internalBinding } = require('internal/bootstrap/loaders'); const { SecureContext: NativeSecureContext } = internalBinding('crypto'); function SecureContext(secureProtocol, secureOptions, context) { if (!(this instanceof SecureContext)) { diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 7df4b6612229aa..fb9662c922956f 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -32,7 +32,6 @@ const common = require('_tls_common'); const { StreamWrap } = require('_stream_wrap'); const { Buffer } = require('buffer'); const debug = util.debuglog('tls'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap'); const tls_wrap = internalBinding('tls_wrap'); const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); diff --git a/lib/buffer.js b/lib/buffer.js index da1563ec3ab91c..f274c51739d418 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -41,7 +41,6 @@ const { // that test/parallel/test-buffer-bindingobj-no-zerofill.js is written. let isAnyArrayBuffer; try { - const { internalBinding } = require('internal/bootstrap/loaders'); isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer; } catch (e) { isAnyArrayBuffer = require('util').types.isAnyArrayBuffer; diff --git a/lib/child_process.js b/lib/child_process.js index 2962f5cf0599af..7ac3a3bcc0a7f3 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -28,7 +28,6 @@ const { const { isArrayBufferView } = require('internal/util/types'); const debug = util.debuglog('child_process'); const { Buffer } = require('buffer'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const { ERR_INVALID_ARG_VALUE, diff --git a/lib/console.js b/lib/console.js index 406f7007e23c03..c254a3889b7856 100644 --- a/lib/console.js +++ b/lib/console.js @@ -29,7 +29,6 @@ const { ERR_INVALID_ARG_VALUE, }, } = require('internal/errors'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { previewEntries } = internalBinding('util'); const { Buffer: { isBuffer } } = require('buffer'); const util = require('util'); diff --git a/lib/crypto.js b/lib/crypto.js index ed902272de4b4d..bff21f6dd65799 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -30,7 +30,6 @@ const { } = require('internal/util'); assertCrypto(); -const { internalBinding } = require('internal/bootstrap/loaders'); const { ERR_CRYPTO_FIPS_FORCED, ERR_CRYPTO_FIPS_UNAVAILABLE diff --git a/lib/dgram.js b/lib/dgram.js index cfaea69abd9cf3..c4819f0eb0f6a8 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -52,7 +52,6 @@ const { defaultTriggerAsyncIdScope, symbols: { async_id_symbol, owner_symbol } } = require('internal/async_hooks'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { UV_UDP_REUSEADDR } = process.binding('constants').os; const { UDP, SendWrap } = internalBinding('udp_wrap'); diff --git a/lib/dns.js b/lib/dns.js index 44fdb1764a13c0..326499497b1580 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -21,7 +21,6 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const cares = internalBinding('cares_wrap'); const { isIP, isIPv4, isLegalPort } = require('internal/net'); const { customPromisifyArgs } = require('internal/util'); diff --git a/lib/domain.js b/lib/domain.js index beacdc89104411..e8ae3ff1003486 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -34,7 +34,6 @@ const { ERR_UNHANDLED_ERROR } = require('internal/errors').codes; const { createHook } = require('async_hooks'); -const { internalBinding } = require('internal/bootstrap/loaders'); // overwrite process.domain with a getter/setter that will allow for more // effective optimizations diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index fd48e2b25bd29d..a42f603293c82e 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -4,7 +4,6 @@ const { ERR_ASYNC_TYPE, ERR_INVALID_ASYNC_ID } = require('internal/errors').codes; -const { internalBinding } = require('internal/bootstrap/loaders'); const async_wrap = internalBinding('async_wrap'); /* async_hook_fields is a Uint32Array wrapping the uint32_t array of * Environment::AsyncHooks::fields_[]. Each index tracks the number of active diff --git a/lib/internal/bash_completion.js b/lib/internal/bash_completion.js index 7d2ffbe901d285..cb8eab9ceec855 100644 --- a/lib/internal/bash_completion.js +++ b/lib/internal/bash_completion.js @@ -1,5 +1,4 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { getOptions } = internalBinding('options'); function print(stream) { diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 5a28fdda10c529..8234275700c535 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -223,7 +223,7 @@ }; NativeModule.wrapper = [ - '(function (exports, require, module, process) {', + '(function (exports, require, module, process, internalBinding) {', '\n});' ]; @@ -294,7 +294,7 @@ const requireFn = this.id.startsWith('internal/deps/') ? NativeModule.requireForDeps : NativeModule.require; - fn(this.exports, requireFn, this, process); + fn(this.exports, requireFn, this, process, internalBinding); if (config.experimentalModules && !NativeModule.isInternal(this.id)) { this.exportKeys = ObjectKeys(this.exports); diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 1c5aace9151e88..e6cdde56c1f7bc 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -21,7 +21,6 @@ const dgram = require('dgram'); const util = require('util'); const assert = require('assert'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { Process } = internalBinding('process_wrap'); const { WriteWrap } = internalBinding('stream_wrap'); const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); diff --git a/lib/internal/cluster/round_robin_handle.js b/lib/internal/cluster/round_robin_handle.js index 9f09d9fbf76635..6b2bc372545cd9 100644 --- a/lib/internal/cluster/round_robin_handle.js +++ b/lib/internal/cluster/round_robin_handle.js @@ -2,7 +2,6 @@ const assert = require('assert'); const net = require('net'); const { sendHelper } = require('internal/cluster/utils'); -const { internalBinding } = require('internal/bootstrap/loaders'); const uv = internalBinding('uv'); module.exports = RoundRobinHandle; diff --git a/lib/internal/crypto/certificate.js b/lib/internal/crypto/certificate.js index d96965224d9066..29372ca497c935 100644 --- a/lib/internal/crypto/certificate.js +++ b/lib/internal/crypto/certificate.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { certExportChallenge, certExportPublicKey, diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js index 59507fea913f82..2d7ddede578b35 100644 --- a/lib/internal/crypto/cipher.js +++ b/lib/internal/crypto/cipher.js @@ -21,7 +21,6 @@ const { const { isArrayBufferView } = require('internal/util/types'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { CipherBase, privateDecrypt: _privateDecrypt, diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js index b3025ee9d9caba..61898989b08abe 100644 --- a/lib/internal/crypto/keygen.js +++ b/lib/internal/crypto/keygen.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { generateKeyPairRSA, diff --git a/lib/internal/crypto/pbkdf2.js b/lib/internal/crypto/pbkdf2.js index 616892d98f04f7..e1a7a4811a2159 100644 --- a/lib/internal/crypto/pbkdf2.js +++ b/lib/internal/crypto/pbkdf2.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { Buffer } = require('buffer'); const { pbkdf2: _pbkdf2 } = internalBinding('crypto'); diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index 3393da92d2d448..d6b6f47b20ccef 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { Buffer, kMaxLength } = require('buffer'); const { randomBytes: _randomBytes } = internalBinding('crypto'); diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js index b8ab0a590f1aee..d364c1385995a8 100644 --- a/lib/internal/crypto/scrypt.js +++ b/lib/internal/crypto/scrypt.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { AsyncWrap, Providers } = internalBinding('async_wrap'); const { Buffer } = require('buffer'); const { scrypt: _scrypt } = internalBinding('crypto'); diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js index 5a1787d00f3639..86b43341bd029c 100644 --- a/lib/internal/crypto/sig.js +++ b/lib/internal/crypto/sig.js @@ -5,7 +5,6 @@ const { ERR_INVALID_OPT_VALUE } = require('internal/errors').codes; const { validateString } = require('internal/validators'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { Sign: _Sign, Verify: _Verify } = internalBinding('crypto'); const { RSA_PSS_SALTLEN_AUTO, diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index 6549f634305c8e..496f195c731015 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { getCiphers: _getCiphers, getCurves: _getCurves, diff --git a/lib/internal/dgram.js b/lib/internal/dgram.js index 829b11bf68706a..9dac221301d9dd 100644 --- a/lib/internal/dgram.js +++ b/lib/internal/dgram.js @@ -1,6 +1,5 @@ 'use strict'; const { codes } = require('internal/errors'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { UDP } = internalBinding('udp_wrap'); const { isInt32 } = require('internal/validators'); const TTYWrap = internalBinding('tty_wrap'); diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 408dec712d821f..6d2fa3b170418d 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -6,7 +6,6 @@ const { } = require('internal/dns/utils'); const { codes, dnsException } = require('internal/errors'); const { isIP, isIPv4, isLegalPort } = require('internal/net'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { getaddrinfo, getnameinfo, diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index 2362f28a821b9a..143d36193a352b 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -1,7 +1,6 @@ 'use strict'; const errors = require('internal/errors'); const { isIP } = require('internal/net'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { ChannelWrap, strerror, diff --git a/lib/internal/domexception.js b/lib/internal/domexception.js index 586d954dc4912b..3f9d3f36018264 100644 --- a/lib/internal/domexception.js +++ b/lib/internal/domexception.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { registerDOMException } = internalBinding('messaging'); const { ERR_INVALID_THIS } = require('internal/errors').codes; diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index ae874c530ccce9..161ae72a19eaef 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -23,7 +23,6 @@ const { const { isArrayBufferView } = require('internal/util/types'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { isArrayBuffer } = internalBinding('types'); diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 1914f2ec8db000..19638b83eeeb6a 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -15,7 +15,6 @@ const kInfo = Symbol('info'); const messages = new Map(); const codes = {}; -const { internalBinding } = require('internal/bootstrap/loaders'); const { errmap, UV_EAI_NODATA, diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js index 758fb4e69285ba..0863664110372e 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -1,7 +1,6 @@ 'use strict'; const errors = require('internal/errors'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { kFsStatsFieldsLength, StatWatcher: _StatWatcher diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index a20275b3131287..4622d97614a1bb 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const Stream = require('stream'); const Readable = Stream.Readable; const binding = internalBinding('http2'); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index a772fb277d7767..b1ed1eee8ff448 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -10,7 +10,6 @@ const { assertCrypto(); -const { internalBinding } = require('internal/bootstrap/loaders'); const assert = require('assert'); const EventEmitter = require('events'); const fs = require('fs'); diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index 473806aa18e300..99466b36d3b321 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const binding = internalBinding('http2'); const { ERR_HTTP2_HEADER_SINGLE_VALUE, diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index fba416d4db35d6..f3f8b0c8e0afe7 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -21,7 +21,7 @@ 'use strict'; -const { internalBinding, NativeModule } = require('internal/bootstrap/loaders'); +const { NativeModule } = require('internal/bootstrap/loaders'); const util = require('util'); const { pathToFileURL } = require('internal/url'); const vm = require('vm'); diff --git a/lib/internal/modules/esm/create_dynamic_module.js b/lib/internal/modules/esm/create_dynamic_module.js index c01844feb8b654..8e93a08502c3cf 100644 --- a/lib/internal/modules/esm/create_dynamic_module.js +++ b/lib/internal/modules/esm/create_dynamic_module.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { ModuleWrap } = internalBinding('module_wrap'); const debug = require('util').debuglog('esm'); const ArrayJoin = Function.call.bind(Array.prototype.join); diff --git a/lib/internal/modules/esm/default_resolve.js b/lib/internal/modules/esm/default_resolve.js index 875c560cb15079..8f8efcb5360d63 100644 --- a/lib/internal/modules/esm/default_resolve.js +++ b/lib/internal/modules/esm/default_resolve.js @@ -3,7 +3,7 @@ const { URL } = require('url'); const CJSmodule = require('internal/modules/cjs/loader'); const internalFS = require('internal/fs/utils'); -const { NativeModule, internalBinding } = require('internal/bootstrap/loaders'); +const { NativeModule } = require('internal/bootstrap/loaders'); const { extname } = require('path'); const { realpathSync } = require('fs'); const preserveSymlinks = !!process.binding('config').preserveSymlinks; diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index 9735eae8b50c9c..50aa00a09a03ee 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { ModuleWrap } = internalBinding('module_wrap'); const { SafeSet, SafePromise } = require('internal/safe_globals'); const { decorateErrorStack } = require('internal/util'); diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index aaf35ed461edb9..df3c446cab7ce7 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -1,6 +1,6 @@ 'use strict'; -const { NativeModule, internalBinding } = require('internal/bootstrap/loaders'); +const { NativeModule } = require('internal/bootstrap/loaders'); const { ModuleWrap } = internalBinding('module_wrap'); const { stripShebang, diff --git a/lib/internal/print_help.js b/lib/internal/print_help.js index 065d6524b764cb..8acc9271b19188 100644 --- a/lib/internal/print_help.js +++ b/lib/internal/print_help.js @@ -1,5 +1,4 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { getOptions, types } = internalBinding('options'); const typeLookup = []; diff --git a/lib/internal/process/esm_loader.js b/lib/internal/process/esm_loader.js index 6f3ac729f8143a..23b98c620e64e5 100644 --- a/lib/internal/process/esm_loader.js +++ b/lib/internal/process/esm_loader.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { setImportModuleDynamicallyCallback, setInitializeImportMetaObjectCallback diff --git a/lib/internal/process/promises.js b/lib/internal/process/promises.js index 695baefefae3e5..d70deb516025fe 100644 --- a/lib/internal/process/promises.js +++ b/lib/internal/process/promises.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { safeToString } = internalBinding('util'); const maybeUnhandledPromises = new WeakMap(); diff --git a/lib/internal/process/stdio.js b/lib/internal/process/stdio.js index 57969324a99efd..2665e4b939fbbb 100644 --- a/lib/internal/process/stdio.js +++ b/lib/internal/process/stdio.js @@ -47,7 +47,6 @@ function getMainThreadStdio() { function getStdin() { if (stdin) return stdin; - const { internalBinding } = require('internal/bootstrap/loaders'); const tty_wrap = internalBinding('tty_wrap'); const fd = 0; @@ -164,7 +163,6 @@ function setupProcessStdio({ getStdout, getStdin, getStderr }) { function createWritableStdioStream(fd) { var stream; - const { internalBinding } = require('internal/bootstrap/loaders'); const tty_wrap = internalBinding('tty_wrap'); // Note stream._type is used for test-module-load-list.js diff --git a/lib/internal/queue_microtask.js b/lib/internal/queue_microtask.js index 3ff7ae9ae48702..e9cc414389ac13 100644 --- a/lib/internal/queue_microtask.js +++ b/lib/internal/queue_microtask.js @@ -3,7 +3,6 @@ const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; const { AsyncResource } = require('async_hooks'); const { getDefaultTriggerAsyncId } = require('internal/async_hooks'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { enqueueMicrotask } = internalBinding('util'); // declared separately for name, arrow function to prevent construction diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js index 5c49026e99e3fe..8da15983f18997 100644 --- a/lib/internal/stream_base_commons.js +++ b/lib/internal/stream_base_commons.js @@ -1,7 +1,6 @@ 'use strict'; const { Buffer } = require('buffer'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { WriteWrap } = internalBinding('stream_wrap'); const { UV_EOF } = internalBinding('uv'); const { errnoException } = require('internal/errors'); diff --git a/lib/internal/test/binding.js b/lib/internal/test/binding.js index 8c19be8ac0b404..17f1574efc7b98 100644 --- a/lib/internal/test/binding.js +++ b/lib/internal/test/binding.js @@ -5,5 +5,4 @@ process.emitWarning( 'tracked by any versioning system or deprecation process.', 'internal/test/binding'); -const { internalBinding } = require('internal/bootstrap/loaders'); module.exports = { internalBinding }; diff --git a/lib/internal/test/heap.js b/lib/internal/test/heap.js index a9260f651b9c1a..fae83266455250 100644 --- a/lib/internal/test/heap.js +++ b/lib/internal/test/heap.js @@ -5,7 +5,6 @@ process.emitWarning( 'tracked by any versioning system or deprecation process.', 'internal/test/heap'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { createHeapDump, buildEmbedderGraph } = internalBinding('heap_utils'); const assert = require('assert'); diff --git a/lib/internal/timers.js b/lib/internal/timers.js index be86153d5df397..5c96b38ee6e00d 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -6,7 +6,6 @@ const { initHooksExist, emitInit } = require('internal/async_hooks'); -const { internalBinding } = require('internal/bootstrap/loaders'); // Symbols for storing async id state. const async_id_symbol = Symbol('asyncId'); const trigger_async_id_symbol = Symbol('triggerId'); diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js index 6eb52f59493ad0..0cf5d517c2bf9f 100644 --- a/lib/internal/trace_events_async_hooks.js +++ b/lib/internal/trace_events_async_hooks.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { trace } = internalBinding('trace_events'); const async_wrap = internalBinding('async_wrap'); const async_hooks = require('async_hooks'); diff --git a/lib/internal/url.js b/lib/internal/url.js index 40b3104baf4116..f6cf35323389ba 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -37,7 +37,6 @@ let querystring; const { platform } = process; const isWindows = platform === 'win32'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { domainToASCII: _domainToASCII, domainToUnicode: _domainToUnicode, diff --git a/lib/internal/util.js b/lib/internal/util.js index 9a102907ee3aa1..745b69381d4a89 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -6,7 +6,6 @@ const { ERR_UNKNOWN_SIGNAL } = require('internal/errors').codes; const { signals } = process.binding('constants').os; -const { internalBinding } = require('internal/bootstrap/loaders'); const { getHiddenValue, setHiddenValue, diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 1cef5533bc1195..3641f0cdc23cc4 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -2,7 +2,6 @@ const { compare } = process.binding('buffer'); const { isArrayBufferView } = require('internal/util/types'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { isAnyArrayBuffer, isDate, diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 4f018ed314be51..4cff372b330ec1 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1,7 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); - const { getOwnNonIndexProperties, getPromiseDetails, diff --git a/lib/internal/vm/source_text_module.js b/lib/internal/vm/source_text_module.js index 6bba7d782f4385..c1c3611d8fd38a 100644 --- a/lib/internal/vm/source_text_module.js +++ b/lib/internal/vm/source_text_module.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { URL } = require('internal/url'); const { isContext } = internalBinding('contextify'); const { diff --git a/lib/internal/worker.js b/lib/internal/worker.js index 2cffb77e521978..41432f55e94d35 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -12,7 +12,6 @@ const { ERR_WORKER_UNSUPPORTED_EXTENSION, } = require('internal/errors').codes; -const { internalBinding } = require('internal/bootstrap/loaders'); const { MessagePort, MessageChannel } = internalBinding('messaging'); const { handle_onclose: handleOnCloseSymbol, diff --git a/lib/internal/wrap_js_stream.js b/lib/internal/wrap_js_stream.js index 3c75bd9163fccf..b51e008705c85e 100644 --- a/lib/internal/wrap_js_stream.js +++ b/lib/internal/wrap_js_stream.js @@ -3,7 +3,6 @@ const assert = require('assert'); const util = require('util'); const { Socket } = require('net'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { JSStream } = internalBinding('js_stream'); const uv = internalBinding('uv'); const debug = util.debuglog('stream_wrap'); diff --git a/lib/net.js b/lib/net.js index fdf7e8a1d0f910..8fdd7bd86a8c46 100644 --- a/lib/net.js +++ b/lib/net.js @@ -34,7 +34,6 @@ const { makeSyncWrite } = require('internal/net'); const assert = require('assert'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { UV_EADDRINUSE, UV_EINVAL diff --git a/lib/os.js b/lib/os.js index 9a05201ea4459c..86a24b7c6261eb 100644 --- a/lib/os.js +++ b/lib/os.js @@ -21,7 +21,6 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { pushValToArrayMax, safeGetenv } = internalBinding('util'); const constants = process.binding('constants').os; const { deprecate } = require('internal/util'); diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 37ede26aa78996..1086c4b5199f16 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -1,6 +1,5 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { PerformanceEntry, mark: _mark, diff --git a/lib/repl.js b/lib/repl.js index a9bb9d6ab8ced8..831d1519f563aa 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -53,7 +53,6 @@ const { } = require('internal/deps/acorn/dist/acorn'); const internalUtil = require('internal/util'); const util = require('util'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { inherits } = util; const Stream = require('stream'); const vm = require('vm'); diff --git a/lib/stream.js b/lib/stream.js index 860c875bec01a1..52c0e50582ddb2 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -49,7 +49,6 @@ try { } else { // This throws for Node < 4.2.0 because there's no util binding and // returns undefined for Node < 7.4.0. - const { internalBinding } = require('internal/bootstrap/loaders'); Stream._isUint8Array = internalBinding('util').isUint8Array; } } catch (e) { diff --git a/lib/string_decoder.js b/lib/string_decoder.js index e5f396cab30d3b..b460da19840c00 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -22,7 +22,6 @@ 'use strict'; const { Buffer } = require('buffer'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { kIncompleteCharactersStart, kIncompleteCharactersEnd, diff --git a/lib/timers.js b/lib/timers.js index 0c5d7b07b2cca7..9070ade70e3d72 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -21,7 +21,6 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { getLibuvNow, setupTimers, diff --git a/lib/tls.js b/lib/tls.js index 9da17411db3df6..898e602807418b 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -29,7 +29,6 @@ const { isUint8Array } = require('internal/util/types'); const net = require('net'); const url = require('url'); -const { internalBinding } = require('internal/bootstrap/loaders'); const binding = internalBinding('crypto'); const { Buffer } = require('buffer'); const EventEmitter = require('events'); diff --git a/lib/trace_events.js b/lib/trace_events.js index 79347b370e70de..bf303c28b7dcdc 100644 --- a/lib/trace_events.js +++ b/lib/trace_events.js @@ -16,7 +16,6 @@ const { if (!hasTracing) throw new ERR_TRACE_EVENTS_UNAVAILABLE(); -const { internalBinding } = require('internal/bootstrap/loaders'); const { CategorySet, getEnabledCategories } = internalBinding('trace_events'); const { customInspectSymbol } = require('internal/util'); const { format } = require('util'); diff --git a/lib/tty.js b/lib/tty.js index 3cc2320e9695f1..83e00df1106d8c 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -23,7 +23,6 @@ const { inherits, _extend } = require('util'); const net = require('net'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { TTY, isTTY } = internalBinding('tty_wrap'); const errors = require('internal/errors'); const { diff --git a/lib/util.js b/lib/util.js index f2eeefde25b1f7..27affda109576c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -32,8 +32,6 @@ const { validateNumber } = require('internal/validators'); const { TextDecoder, TextEncoder } = require('internal/encoding'); const { isBuffer } = require('buffer').Buffer; -const { internalBinding } = require('internal/bootstrap/loaders'); - const types = internalBinding('types'); Object.assign(types, require('internal/util/types')); const { diff --git a/lib/v8.js b/lib/v8.js index c6ac8b362fba96..1cba0464b1be67 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -16,7 +16,6 @@ const { Buffer } = require('buffer'); const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; -const { internalBinding } = require('internal/bootstrap/loaders'); const { Serializer: _Serializer, Deserializer: _Deserializer diff --git a/lib/vm.js b/lib/vm.js index 6ec40f9bcabeef..373fb4029dd605 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -21,7 +21,6 @@ 'use strict'; -const { internalBinding } = require('internal/bootstrap/loaders'); const { ContextifyScript, makeContext,