-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
lib: add process.loadedModules list
#61330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,15 @@ ObjectDefineProperty(process, 'moduleLoadList', { | |
| writable: false, | ||
| }); | ||
|
|
||
| // Set up process.loadedModules | ||
| const loadedModules = []; | ||
| ObjectDefineProperty(process, 'loadedModules', { | ||
| __proto__: null, | ||
| get() { return ArrayPrototypeSlice(loadedModules); }, | ||
| configurable: true, | ||
| enumerable: true, | ||
| }); | ||
|
|
||
|
|
||
| // processBindingAllowList contains the name of bindings that are allowed | ||
| // for access via process.binding(). This is used to provide a transition | ||
|
|
@@ -405,6 +414,9 @@ class BuiltinModule { | |
| // "NativeModule" is a legacy name of "BuiltinModule". We keep it | ||
| // here to avoid breaking users who parse process.moduleLoadList. | ||
| ArrayPrototypePush(moduleLoadList, `NativeModule ${id}`); | ||
| if (!StringPrototypeStartsWith(id, 'internal/')) { | ||
| ArrayPrototypePush(loadedModules, id); | ||
| } | ||
|
Comment on lines
+417
to
+419
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this handle #61276 (comment) and #61276 (comment) from Joyee had on your previous doc PR? I think it specifically doesn't handle:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may have misunderstood Joyee's feedback, but I tought the |
||
| return this.exports; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const assert = require('assert'); | ||
|
|
||
| assert.ok(Array.isArray(process.loadedModules)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there should be a little more on what's in that is actually what it should be :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it a better now? I'm not willing to test exact values in there to avoid flacky tests, am I wrong? |
||
| assert.throws(() => process.loadedModules = 'foo', /^TypeError: Cannot set property loadedModules of #<process> which has only a getter$/); | ||
Uh oh!
There was an error while loading. Please reload this page.