Skip to content
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

doc: improve module.builtinModules documentation #17712

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,19 @@ added: v9.3.0
A list of the names of all modules provided by Node.js. Can be used to verify
if a module is maintained by a third-party module or not.

Note that `module` in this context isn't the same object that's provided
Copy link
Member

@Trott Trott Dec 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this note be moved to below the example for accessing builtinModules? Its placement here makes it in To access it (the next sentence) seem like it refers to the module wrapper which is kind of the opposite of the sentences intention, I think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually referring to the module mentioned in the headline of this section just above. But I can see that this can be a bit confusing. Not sure if moving it below the code example helps much unless I also change the code example to assign the required module to a constant like I did in the alternative code example in the PR description. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why I like to refer to this module with an uppercase M as it makes it much easier to distinguish between the two

by the [module wrapper][]. To access it, require the `Module` module:

```js
const builtin = require('module').builtinModules;
```

[`__dirname`]: #modules_dirname
[`__filename`]: #modules_filename
[`Error`]: errors.html#errors_class_error
[`module` object]: #modules_the_module_object
[`path.dirname()`]: path.html#path_path_dirname_path
[exports shortcut]: #modules_exports_shortcut
[module resolution]: #modules_all_together
[module wrapper]: #modules_the_module_wrapper
[native addons]: addons.html