Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrapper: move internalBinding to NativeModule wrapper #23025

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ globals:
DCHECK_LE: false
DCHECK_LT: false
DCHECK_NE: false
internalBinding: false
1 change: 0 additions & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { methods, HTTPParser } = internalBinding('http_parser');

const FreeList = require('internal/freelist');
Expand Down
1 change: 0 additions & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion lib/_tls_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const {
} = require('internal/util');
assertCrypto();

const { internalBinding } = require('internal/bootstrap/loaders');
const {
ERR_CRYPTO_FIPS_FORCED,
ERR_CRYPTO_FIPS_UNAVAILABLE
Expand Down
1 change: 0 additions & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/internal/bash_completion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const { internalBinding } = require('internal/bootstrap/loaders');
const { getOptions } = internalBinding('options');

function print(stream) {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
};

NativeModule.wrapper = [
'(function (exports, require, module, process) {',
'(function (exports, require, module, process, internalBinding) {',
'\n});'
];

Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, it should be safe to remove internalBinding from loaderExports by now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bootstrap/node.js uses it, so we can't


if (config.experimentalModules && !NativeModule.isInternal(this.id)) {
this.exportKeys = ObjectKeys(this.exports);
Expand Down
1 change: 0 additions & 1 deletion lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/cluster/round_robin_handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/certificate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const {
certExportChallenge,
certExportPublicKey,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/cipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const {

const { isArrayBufferView } = require('internal/util/types');

const { internalBinding } = require('internal/bootstrap/loaders');
const {
CipherBase,
privateDecrypt: _privateDecrypt,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/keygen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const {
generateKeyPairRSA,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/pbkdf2.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/scrypt.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/sig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const {
getCiphers: _getCiphers,
getCurves: _getCurves,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/dgram.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/dns/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/dns/utils.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/domexception.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { registerDOMException } = internalBinding('messaging');
const { ERR_INVALID_THIS } = require('internal/errors').codes;

Expand Down
1 change: 0 additions & 1 deletion lib/internal/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const {

const { isArrayBufferView } = require('internal/util/types');

const { internalBinding } = require('internal/bootstrap/loaders');
const {
isArrayBuffer
} = internalBinding('types');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/fs/watchers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const errors = require('internal/errors');
const { internalBinding } = require('internal/bootstrap/loaders');
const {
kFsStatsFieldsLength,
StatWatcher: _StatWatcher
Expand Down
1 change: 0 additions & 1 deletion lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const Stream = require('stream');
const Readable = Stream.Readable;
const binding = internalBinding('http2');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const {

assertCrypto();

const { internalBinding } = require('internal/bootstrap/loaders');
const assert = require('assert');
const EventEmitter = require('events');
const fs = require('fs');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/http2/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const binding = internalBinding('http2');
const {
ERR_HTTP2_HEADER_SINGLE_VALUE,
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/modules/esm/create_dynamic_module.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/esm/default_resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion lib/internal/modules/esm/module_job.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/internal/print_help.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const { internalBinding } = require('internal/bootstrap/loaders');
const { getOptions, types } = internalBinding('options');

const typeLookup = [];
Expand Down
1 change: 0 additions & 1 deletion lib/internal/process/esm_loader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const {
setImportModuleDynamicallyCallback,
setInitializeImportMetaObjectCallback
Expand Down
1 change: 0 additions & 1 deletion lib/internal/process/promises.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { internalBinding } = require('internal/bootstrap/loaders');
const { safeToString } = internalBinding('util');

const maybeUnhandledPromises = new WeakMap();
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/process/stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/internal/queue_microtask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/internal/stream_base_commons.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 0 additions & 1 deletion lib/internal/test/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
1 change: 0 additions & 1 deletion lib/internal/test/heap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
1 change: 0 additions & 1 deletion lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading