FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

doc: add ESM code examples in url.md by aduh95 · Pull Request #38651 · nodejs/node · GitHub

/ node Public

doc: add ESM code examples in url.md - #38651

Closed
aduh95 wants to merge 2 commits into
nodejs:masterfrom
aduh95:url-esm
Closed

doc: add ESM code examples in url.md#38651
aduh95 wants to merge 2 commits into
nodejs:masterfrom
aduh95:url-esm

Conversation

aduh95 commented May 12, 2021

Copy link
Copy Markdown
Contributor

Alternative to #38645, removing use of require or adding import equivalents where it makes sense.

@fisker what do you think?

github-actions Bot added doc Issues and PRs related to the documentations. url Issues and PRs related to the legacy built-in url module. labels May 12, 2021

fisker commented May 12, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

Switching to import is good, but I think removing import/require is bad. Like I said, it's not clear where these methods from.

When I first saw

new URL('file:///C:/path/').pathname;    // Incorrect: /C:/path/
fileURLToPath('file:///C:/path/');       // Correct:   C:\path\ (Windows)

I really don't know how to use fileURLToPath,

  • Is it static method of URL? URL.fileURLToPath(...)
  • Is it method of URL instance? new URL(...).fileURLToPath()
  • Or the correct one import {fileURLToPath} from 'url'
  • (edit) Or even it's global ? Like URL

It doesn't make sense to remove these imports. check https://nodejs.org/api/child_process.html, every example has require('child_process') it's very clear how to use it.

fisker commented May 12, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

worker_threads /fs / assert/dns has those imports as well, I don't think people care much it's import or require

aduh95 commented May 13, 2021

Copy link
Copy Markdown
Contributor Author

@fisker Fair enough, I've added the require calls back and added ESM examples. Would you like to add ESM examples to #38645?

aduh95 added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label May 13, 2021

fisker commented May 13, 2021

Copy link
Copy Markdown
Contributor

Yes, with pleasure.

jasnell pushed a commit that referenced this pull request May 14, 2021
PR-URL: #38651
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>

jasnell commented May 14, 2021

Copy link
Copy Markdown
Member

Landed in df744db

jasnell closed this May 14, 2021
aduh95 deleted the url-esm branch May 15, 2021 08:54
targos pushed a commit that referenced this pull request May 17, 2021
PR-URL: #38651
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. doc Issues and PRs related to the documentations. url Issues and PRs related to the legacy built-in url module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL