-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
doc: document process.moduleLoadList #61276
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 all commits
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 |
|---|---|---|
|
|
@@ -2858,6 +2858,31 @@ console.log(memoryUsage.rss()); | |
| // 35655680 | ||
| ``` | ||
| ## `process.moduleLoadList` | ||
| <!-- YAML | ||
| added: v0.5.3 | ||
| --> | ||
| * Type: {string\[]} | ||
| The `process.moduleLoadList` property returns an array of internal bindings and core modules that | ||
| were loaded during the current Node.js process execution. | ||
|
Contributor
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. Small wording nit: "process execution" feels slightly redundant. "during the current process" might be cleaner.
|
||
| ```mjs | ||
| import { moduleLoadList } from 'node:process'; | ||
|
|
||
| console.log(moduleLoadList); | ||
| // ['Internal Binding builtins', 'Internal Binding module_wrap', 'Internal Binding errors', ...] | ||
|
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 the current shape of the API isn't very suitable to be a proper, public API - for example the types and the module names are mixed into a string, and there are no guarantees about when the types would change or what types there are; the names of the modules are also highly volatile and cannot be reliably depended on, and this might backfire if users start to claim changes to this array - removing/adding internal modules or their types - are supposed to be semver-major, just because this is a documented API. IMO a documented version of this should either expose enum-like constants for types, and/or just filter out all the internals in the array.
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. Thanks for the review! I also feel like it would be better to have something like { type: 'INTERNAL' | 'BUILTIN', name: string } in this list instead of concatened strings albeit as far as I understand, it wouldn't fix the concern regarding the removing/adding of internal modules being claimed as major changes. Or am I mistaken here? Filtering out the internals is also a good option: tests do not rely on them being present anyway. Could this list become as list of builtins name in the form of What's option seems the safest to you regarding the concerns you mentionned?
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. Third option: leave is as is, untouched and undocumented on purpose.
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. cc @aduh95 (#41233 (comment)) – don't know whether you still have an opinion?
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. FWIW it wasn't added in #24775, as suggested in the changelog in this PR this dates back to the 0.x days when everything got exposed on process without a lot of thoughts into what's public and what's internal.
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. Also I think my personal preference would be: a separate list of strings with public modules only, and document that instead > leave it as is > a separate list of objects with enum + names (including internals) > document the current API
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. Just to be sure to not mess up the next step too much, "separate" means leave |
||
| ``` | ||
| ```cjs | ||
| const { moduleLoadList } = require('node:process'); | ||
|
|
||
| console.log(moduleLoadList); | ||
| // ['Internal Binding builtins', 'Internal Binding module_wrap', 'Internal Binding errors', ...] | ||
| ``` | ||
| ## `process.nextTick(callback[, ...args])` | ||
| <!-- YAML | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since the documentation text specifically refers to
process.moduleLoadList, should the example useprocess.moduleLoadListdirectly instead of destructuring?