doc: Error for "." and ".." specifiers differs from documented Resolver Algorithm
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
- Version: ✍️
16.7.0
- Platform: ✍️
Linux penguin 5.4.119-14945-gafc97d54f809 #1 SMP PREEMPT Tue Aug 10 21:49:04 PDT 2021 x86_64 GNU/Linux
- Subsystem: ✍️
module
Location
Affected URL(s):
Description
I'm not sure if this is a bug with the ESM resolver or with the docs but basically if we do:
import foo from ".";
Then Node throws a ERR_UNSUPPORTED_DIR_IMPORT error, based on a reading of the Resolver Algorithm I expected this to be ERR_INVALID_MODULE_SPECIFIER.
As CommonJS already treats require(".") and require("..") as directory imports the current behaviour in Node is probably the best, so the docs should be updated to reflect it. This would involve changing ESM_RESOLVE step 3 to:
- Otherwise, if specifier starts with "/", "./" or "../", or specifier equals "." or ".." then
Although if the current documented behaviour is the intended behaviour then the error needs updating.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ESM Resolver Algorithm specification at the linked esm.html section and compare step 3 with the observed import behavior for "." and "..". Confirm whether the documented algorithm or the runtime behavior is intended, then update the documentation so the algorithm and reported error agree; the issue is done when the documented result matches Node's behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100