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

esm: fix imports from non-file module by aduh95 · Pull Request #42881 · nodejs/node · GitHub

/ node Public

esm: fix imports from non-file module - #42881

Merged
nodejs-github-bot merged 3 commits into
nodejs:masterfrom
aduh95:fix-import-from-data-modules
Apr 29, 2022
Merged

esm: fix imports from non-file module#42881
nodejs-github-bot merged 3 commits into
nodejs:masterfrom
aduh95:fix-import-from-data-modules

Conversation

aduh95 commented Apr 27, 2022

Copy link
Copy Markdown
Contributor

Calling fileURLToPath on a possibly non-file URL throws. Converting to a path is not necessary anyway, as it's already common to see a URL in error messages rather than a path.

Fixes: #42860

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/modules

nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Apr 27, 2022
Comment on lines -1018 to -1019
const parentURL = fileURLToPath(parsedParentURL?.href);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There was a reason for this (I'm pretty sure not doing this will break something), but I can't remember what it was. @bmeck do you remember?

JakobJingleheimer Apr 27, 2022
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

OH! I partially remember! It's when something is wrong with parsedParentURL—that's why it uses ?.. Without this, the error message was too confusing, like " is not allowed" (where there should be something at the front). Adding it provided an important clue to what is wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We're checking that parsedParentURL is truthy the line just before that, I don't think the ?. could ever take effect. Arguably it's fixing a bigger issue than a confusing error message, I'd be inclined to land this anyway. We can always improve things later if the original problem comes back. wdyt?

GeoffreyBooth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I’m assuming you’ve checked that this is okay with ERR_NETWORK_IMPORT_DISALLOWED.

To answer @JakobJingleheimer’s question, I’d guess we were trying to create a more readable error message, telling the user which file had the issue? And assuming that it would be more expected to tell the user their file as a path rather than as a URL.

JakobJingleheimer commented Apr 27, 2022
edited
Loading

Copy link
Copy Markdown
Member

Maaaybe, but I think it was more than metely pretty-fying. At the least, I think it made the path intelligible in some circumstance it otherwise wasn't. I specifically remember talking to Bradley about this line, but slack ate it (it's beyond the retention age for free Slack 😰).

Maybe it had to do with normalising the same error message across CJS and ESM and there was an issue filed this fixed? 🕵️‍♂️ nvmd, I was thinking of #39787 which was resolved via a documentation update.

I guess it can't be that important or I would have put a code comment.

Copy link
Copy Markdown
Member

@aduh95 please see my inline comment. I lost quite a bit of time when I was testing a specific scenario for #36328 because of the missing information in the error message that fileURLToPath() reveals. If needed, I can try to re-discover what the specific repro steps were for this (so it can be addressed in a different way).

aduh95 commented Apr 27, 2022

Copy link
Copy Markdown
Contributor Author

I can try to re-discover what the specific repro steps were for this (so it can be addressed in a different way).

Having a test for that would be ideal 👍 It can also be taken to its own PR as I'd like this patch to land ASAP.

JakobJingleheimer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sure! That works for me!

aduh95 added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Apr 27, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 27, 2022

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 29, 2022
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 29, 2022
nodejs-github-bot merged commit 27ecf1d into nodejs:master Apr 29, 2022

Copy link
Copy Markdown
Collaborator

Landed in 27ecf1d

aduh95 deleted the fix-import-from-data-modules branch April 29, 2022 14:31
targos pushed a commit that referenced this pull request May 2, 2022
Fixes: #42860

PR-URL: #42881
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
targos mentioned this pull request May 2, 2022
juanarbol pushed a commit that referenced this pull request May 31, 2022
Fixes: #42860

PR-URL: #42881
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
danielleadams pushed a commit that referenced this pull request Jun 27, 2022
Fixes: #42860

PR-URL: #42881
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
targos pushed a commit that referenced this pull request Jul 12, 2022
Fixes: #42860

PR-URL: #42881
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
Fixes: #42860

PR-URL: #42881
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
Fixes: nodejs/node#42860

PR-URL: nodejs/node#42881
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
github-merge-queue Bot pushed a commit to yarnpkg/berry that referenced this pull request Jun 1, 2023
**What's the problem this PR addresses?**

The test added in #5362 doesn't run
on Node.js v17.

Fixes
https://github.com/yarnpkg/berry/actions/runs/5060283241/jobs/9083017466

**How did you fix it?**

Updated the range to match Node.js versions containing
nodejs/node#42881

**Checklist**
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
github-merge-queue Bot pushed a commit to yarnpkg/berry that referenced this pull request Jun 1, 2023
**What's the problem this PR addresses?**

The test added in #5362 doesn't run
on Node.js v17.

Fixes
https://github.com/yarnpkg/berry/actions/runs/5060283241/jobs/9083017466

**How did you fix it?**

Updated the range to match Node.js versions containing
nodejs/node#42881

**Checklist**
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
github-merge-queue Bot pushed a commit to yarnpkg/berry that referenced this pull request Jun 1, 2023
**What's the problem this PR addresses?**

The test added in #5362 doesn't run
on Node.js v17.

Fixes
https://github.com/yarnpkg/berry/actions/runs/5060283241/jobs/9083017466

**How did you fix it?**

Updated the range to match Node.js versions containing
nodejs/node#42881

**Checklist**
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
arcanis pushed a commit to yarnpkg/berry that referenced this pull request Jun 1, 2023
**What's the problem this PR addresses?**

The test added in #5362 doesn't run
on Node.js v17.

Fixes
https://github.com/yarnpkg/berry/actions/runs/5060283241/jobs/9083017466

**How did you fix it?**

Updated the range to match Node.js versions containing
nodejs/node#42881

**Checklist**
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
merceyz added a commit to yarnpkg/berry that referenced this pull request Jun 1, 2023
**What's the problem this PR addresses?**

The test added in #5362 doesn't run
on Node.js v17.

Fixes
https://github.com/yarnpkg/berry/actions/runs/5060283241/jobs/9083017466

**How did you fix it?**

Updated the range to match Node.js versions containing
nodejs/node#42881

**Checklist**
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
arcanis pushed a commit to yarnpkg/example-repo-zipn that referenced this pull request Jul 3, 2023
**What's the problem this PR addresses?**

The test added in yarnpkg/berry#5362 doesn't run
on Node.js v17.

Fixes
https://github.com/yarnpkg/berry/actions/runs/5060283241/jobs/9083017466

**How did you fix it?**

Updated the range to match Node.js versions containing
nodejs/node#42881

**Checklist**
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
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. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regression file:/// import within a data: url no longer works

5 participants


Back | FazBrowse Home | New Git URL