Skip to content

Commit

Permalink
lib: expose primordials object
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
aduh95 committed Jan 18, 2021
1 parent 78ca54c commit 983e922
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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 };

0 comments on commit 983e922

Please sign in to comment.