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: include global node_modules in require.resolve description #20534

Closed
wants to merge 3 commits into from

Conversation

musgravejw
Copy link
Contributor

@musgravejw musgravejw commented May 5, 2018

Closes: #18926

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem. labels May 5, 2018
these paths is used as a starting point for the module resolution algorithm,
meaning that the `node_modules` hierarchy is checked from this location.
paths are used instead of the default resolution paths, with the exception
of global folders like ~/.node_modules, which are always included. Note that
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: ~/.node_modules -> `~/.node_modules`?

Copy link
Contributor

Choose a reason for hiding this comment

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

(If so, this line will need rewrapping at 80 characters.)

@BridgeAR
Copy link
Member

BridgeAR commented May 5, 2018

LGTM with the comments addressed.

@richardlau
Copy link
Member

Looks like GitHub's web interface no longer fully works on IOS 10 so I can't properly review this to request changes.

Please could you rename GLOBAL_NODE_MODULES to something like GLOBAL_FOLDERS since none of the global folders is called node_modules and to try to minimise any confusion with npm's global installations (which are not the same thing).

cc @nodejs/modules

@musgravejw
Copy link
Contributor Author

Updated.

@vsemozhetbyt
Copy link
Contributor

Node.js Collaborators, please, add 👍 here if you approve fast-tracking.

@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt added the fast-track PRs that do not need to wait for 48 hours to land. label May 5, 2018
2. for each DIR in DIRS:
a. LOAD_AS_FILE(DIR/X)
b. LOAD_AS_DIRECTORY(DIR/X)

NODE_MODULES_PATHS(START)
1. let PARTS = path split(START)
2. let I = count of PARTS - 1
3. let DIRS = []
3. let DIRS = [ GLOBAL_FOLDERS ]
Copy link
Member

Choose a reason for hiding this comment

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

The term “GLOBAL_FOLDERS” doesn’t appear to be defined anywhere; if you mean the list in line 424, could you alter that list as well to use this identical term?

Ideally, this term would also link down to that section.

Copy link
Contributor Author

@musgravejw musgravejw May 5, 2018

Choose a reason for hiding this comment

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

@ljharb What would be the best way to capture this? The main heading is regarding "loading from the global folders." Would it make sense to say Additionally, Node.js will search in the following global folders:?

Copy link
Member

Choose a reason for hiding this comment

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

Even just a sentence in the below section like “This list of GLOBAL_FOLDERS:” or something

Copy link
Member

Choose a reason for hiding this comment

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

It’d be cool if the mention in the algorithm itself could also be linked.

@vsemozhetbyt
Copy link
Contributor

2. for each DIR in DIRS:
a. LOAD_AS_FILE(DIR/X)
b. LOAD_AS_DIRECTORY(DIR/X)

NODE_MODULES_PATHS(START)
1. let PARTS = path split(START)
2. let I = count of PARTS - 1
3. let DIRS = []
3. let DIRS = [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders)
Copy link

Choose a reason for hiding this comment

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

Will this link render on the website? On github it's not.

This comment was marked as off-topic.

Copy link

Choose a reason for hiding this comment

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

screenshot from 2018-05-07 12-31-27

It seems not up-to-date, or is it just me?

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I misunderstood the note.

meaning that the `node_modules` hierarchy is checked from this location.
paths are used instead of the default resolution paths, with the exception
of [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders) like
`~/.node_modules`, which are always included. Note that each of these paths
Copy link

Choose a reason for hiding this comment

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

$HOME/.node_modules should be preferred, tild is from bash.

Copy link
Member

Choose a reason for hiding this comment

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

$HOME/.node_modules would also be consistent with the list in the Loading from the global folders section.

@vsemozhetbyt vsemozhetbyt added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 7, 2018
these paths is used as a starting point for the module resolution algorithm,
meaning that the `node_modules` hierarchy is checked from this location.
paths are used instead of the default resolution paths, with the exception
of [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders) like
Copy link
Member

Choose a reason for hiding this comment

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

Since the link #modules_loading_from_the_global_folders is used twice in the document, it can be moved to bottom of the page as follows:

@vsemozhetbyt vsemozhetbyt removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 8, 2018
@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt

This comment has been minimized.

@richardlau
Copy link
Member

@xtuc's comment still stands, the change doesn't render as a link in GitHub: https://github.com/musgravejw/node/blob/4b6bf5cca73c211007d99344522fb91c6b9668bf/doc/api/modules.md#all-together

@ljharb
Copy link
Member

ljharb commented May 8, 2018

Since it's in a preformatted block, I don't think that's possible.

Either way, as long as I can "find in page" for "GLOBAL_FOLDERS", it's good, and i think i'd personally rather have the website be more usable with a link than have the markdown be less messy by omitting the link.

@vsemozhetbyt
Copy link
Contributor

Yes, sorry, I'missed that this is a code block.

@trivikr
Copy link
Member

trivikr commented May 9, 2018

@vsemozhetbyt #20534 (review) is not addressed yet

@vsemozhetbyt
Copy link
Contributor

@musgravejw

  1. After creating the bottom reference you can use it in the text as [GLOBAL_FOLDERS][].
  2. We still need to delete the link from the code block as it is not rendered as a link in the HTML page.

`~/.node_modules`, which are always included. Note that each of these paths
is used as a starting point for the module resolution algorithm, meaning
that the `node_modules` hierarchy is checked from this location.
of [GLOBAL_FOLDERS][] like `$HOME/.node_modules`, which are always
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: trailing space, but this can be fixed on landing)

@vsemozhetbyt
Copy link
Contributor

2. for each DIR in DIRS:
a. LOAD_AS_FILE(DIR/X)
b. LOAD_AS_DIRECTORY(DIR/X)

NODE_MODULES_PATHS(START)
1. let PARTS = path split(START)
2. let I = count of PARTS - 1
3. let DIRS = []
3. let DIRS = [GLOBAL_FOLDERS]

This comment was marked as resolved.

This comment was marked as resolved.

vsemozhetbyt pushed a commit that referenced this pull request May 11, 2018
PR-URL: #20534
Fixes: #18926
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@vsemozhetbyt
Copy link
Contributor

Landed in 6fd8022 (with a tiny fix: insert bottom reference in ASCII sort order).

Thank you!

targos pushed a commit that referenced this pull request May 12, 2018
PR-URL: #20534
Fixes: #18926
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@addaleax addaleax mentioned this pull request May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fast-track PRs that do not need to wait for 48 hours to land. module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify that require.resolve automatically adds global folders to lookup path