doc: Error for "." and ".." specifiers differs from documented Resolver Algorithm
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
- 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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 esm.html 部分中的 ESM Resolver Algorithm 规范开始,将第 3 步与对 "." 和 ".." 观察到的 import 行为进行比较。确认预期的是文档中的算法还是运行时行为,然后更新文档,使算法与报告的错误一致;当文档中的结果与 Node 的行为一致时,该 issue 即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- backend, documentation
- Issue 类型
- 文档
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100