Skip to content

Commit 8912cab

Browse files
aduh95targos
authored andcommitted
lib: expose primordials object
Expose the internal `primordials` object to help with Node.js core development. ```console $ node --expose-internals -r internal/test/binding lib/fs.js (node:5299) internal/test/binding: These APIs are for internal testing only. Do not use them. (Use `node --trace-warnings ...` to show where the warning was created) ``` PR-URL: #36872 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 46c019b commit 8912cab

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/internal/modules/cjs/loader.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ ObjectDefineProperty(Module, 'wrapper', {
233233
}
234234
});
235235

236-
ObjectDefineProperty(Module.prototype, 'isPreloading', {
237-
get() { return isPreloading; }
238-
});
236+
const isPreloadingDesc = { get() { return isPreloading; } };
237+
ObjectDefineProperty(Module.prototype, 'isPreloading', isPreloadingDesc);
238+
ObjectDefineProperty(NativeModule.prototype, 'isPreloading', isPreloadingDesc);
239239

240240
let debug = require('internal/util/debuglog').debuglog('module', (fn) => {
241241
debug = fn;

lib/internal/test/binding.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ process.emitWarning(
44
'These APIs are for internal testing only. Do not use them.',
55
'internal/test/binding');
66

7-
module.exports = { internalBinding };
7+
if (module.isPreloading) {
8+
globalThis.internalBinding = internalBinding;
9+
globalThis.primordials = primordials;
10+
}
11+
12+
module.exports = { internalBinding, primordials };

0 commit comments

Comments
 (0)