Skip to content
Merged
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
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>
  • Loading branch information
aduh95 committed Jan 18, 2021
commit 983e9222ca74aa5bc4113052088443eb5a6866d0
6 changes: 3 additions & 3 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ ObjectDefineProperty(Module, 'wrapper', {
}
});

ObjectDefineProperty(Module.prototype, 'isPreloading', {
get() { return isPreloading; }
});
const isPreloadingDesc = { get() { return isPreloading; } };
ObjectDefineProperty(Module.prototype, 'isPreloading', isPreloadingDesc);
ObjectDefineProperty(NativeModule.prototype, 'isPreloading', isPreloadingDesc);

function getModuleParent() {
return moduleParentCache.get(this);
Expand Down
7 changes: 6 additions & 1 deletion lib/internal/test/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ process.emitWarning(
'These APIs are for internal testing only. Do not use them.',
'internal/test/binding');

module.exports = { internalBinding };
if (module.isPreloading) {
globalThis.internalBinding = internalBinding;
globalThis.primordials = primordials;
}

module.exports = { internalBinding, primordials };