Skip to content

Commit bef6b16

Browse files
devsnekBridgeAR
authored andcommitted
test: formalize exposure of internal bindings
moves exposed internalBindings to a single location with short guidelines on how to expose them and a warning for users should they come across it PR-URL: nodejs#18698 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 1350802 commit bef6b16

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

lib/internal/modules/esm/ModuleWrap.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

lib/internal/test/binding.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
process.emitWarning(
4+
'These APIs are exposed only for testing and are not ' +
5+
'tracked by any versioning system or deprecation process.',
6+
'internal/test/binding');
7+
8+
// These exports should be scoped as specifically as possible
9+
// to avoid exposing APIs because even with that warning and
10+
// this file being internal people will still try to abuse it.
11+
12+
const { internalBinding } = require('internal/bootstrap/loaders');
13+
module.exports = {
14+
ModuleWrap: internalBinding('module_wrap').ModuleWrap,
15+
};

node.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
'lib/internal/modules/esm/DefaultResolve.js',
113113
'lib/internal/modules/esm/ModuleJob.js',
114114
'lib/internal/modules/esm/ModuleMap.js',
115-
'lib/internal/modules/esm/ModuleWrap.js',
116115
'lib/internal/modules/esm/Translators.js',
117116
'lib/internal/safe_globals.js',
118117
'lib/internal/net.js',
@@ -128,6 +127,7 @@
128127
'lib/internal/readline.js',
129128
'lib/internal/repl.js',
130129
'lib/internal/socket_list.js',
130+
'lib/internal/test/binding.js',
131131
'lib/internal/test/unicode.js',
132132
'lib/internal/tls.js',
133133
'lib/internal/trace_events_async_hooks.js',

test/parallel/test-internal-module-wrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const common = require('../common');
66
common.crashOnUnhandledRejection();
77
const assert = require('assert');
88

9-
const ModuleWrap = require('internal/modules/esm/ModuleWrap');
9+
const { ModuleWrap } = require('internal/test/binding');
1010
const { getPromiseDetails, isPromise } = process.binding('util');
1111
const setTimeoutAsync = require('util').promisify(setTimeout);
1212

0 commit comments

Comments
 (0)