-
Notifications
You must be signed in to change notification settings - Fork 30k
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
module: change default resolver to not throw on unknown scheme #47824
Merged
nodejs-github-bot
merged 12 commits into
nodejs:main
from
giltayar:default-resolve-no-throw-scheme
May 19, 2023
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
52d276e
module: change default resolver to not throw on unknown scheme
giltayar 94afcae
fix lint errors
giltayar c87c78c
Update doc/api/esm.md
giltayar 3df4003
added test for extensions, and simplified protocol test
giltayar f615248
remove fixtures by inlining them in the test
giltayar e4b4cdf
change load example to "import map" semantics
giltayar a387b9c
fix lint errors
giltayar 88a4ce9
Update doc/api/esm.md to improve "import map" loader
giltayar b0eb1c0
Document resolution not failing on url protocol
giltayar 98924dd
add some loader info to esm docs and change to "default resolver"
giltayar 357e8db
esm.md fixed based on comments
giltayar 2c7e695
fix expected error message
giltayar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
import-map.json
should be given by the user of the loader, so it should be taken from current working directory and not next to the source code of the loader. So I would prefer leaving it like this and not accepting your suggestion. Having said that, I don't feel strongly about it, as this is demo code, so just say the word and I'll commit the suggestion.(obviously, cwd is naive and there should be an env variable or some such, but this is naive code for demo purpose only)
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.
Why not just make the example the
esm.sh
one then? That’s much simpler and involves only one file, so the overall example would also be shorter.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.
Can you wrap it in
path.resolve
and/or add a comment? Without that, it’s a bit confusing IMO.We would have trouble with Windows compatibility, right?
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.
That example I had in mind was to rewrite all bare specifiers like
lodash
tohttps://esm.sh/lodash
, and that’s it. Add a comment thatload
would fail without--experimental-network-imports
, or without chaining the example HTTPS loader, and call it a day. It should be like a five-line example I’d think.It’s still a bit contrived as presumably you wouldn’t always want to load the latest version of every dependency, but for an example I think it gets the idea across and then real-world implementations can fill in details.
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.
It seems unwise for node docs to bless an arbitrary site in the ecosystem by including it in examples.