Skip to content

Commit 3e8af96

Browse files
committed
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: #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 01d0491 commit 3e8af96

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

lib/internal/loader/ModuleWrap.js

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

lib/internal/test/binding.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
module.exports = {
12+
ModuleWrap: internalBinding('module_wrap').ModuleWrap,
13+
};

node.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
'lib/internal/loader/DefaultResolve.js',
108108
'lib/internal/loader/ModuleJob.js',
109109
'lib/internal/loader/ModuleMap.js',
110-
'lib/internal/loader/ModuleWrap.js',
111110
'lib/internal/loader/Translators.js',
112111
'lib/internal/safe_globals.js',
113112
'lib/internal/net.js',
@@ -125,6 +124,7 @@
125124
'lib/internal/repl.js',
126125
'lib/internal/repl/await.js',
127126
'lib/internal/socket_list.js',
127+
'lib/internal/test/binding.js',
128128
'lib/internal/test/unicode.js',
129129
'lib/internal/timers.js',
130130
'lib/internal/tls.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/loader/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)