-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
esm: fix imports from non-file module #42881
esm: fix imports from non-file module #42881
Conversation
Review requested:
|
const parentURL = fileURLToPath(parsedParentURL?.href); | ||
|
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.
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?
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.
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.
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.
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?
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.
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.
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 😰).
I guess it can't be that important or I would have put a code comment. |
@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 |
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. |
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.
Sure! That works for me!
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.
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.
Landed in 27ecf1d |
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>
**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.
**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.
**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.
**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.
**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.
**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.
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