Add async alternative to import.meta.resolve() with additional options
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
What is the problem this feature will solve?
Tools often need to resolve imports of files they are analyzing, which requires a resolve API that import.meta.resolve() isn't suited for.
- The
resolve()call needs a referrer path, which is only available with a flag and is non standard - The tool might want to specify import conditions, which are non-standard
- The call should be async, so that file system access isn't blocking. This is especially important for online resolution in servers.
Node might be able to add non-standard options via a second argument, though I'm a bit dubious of this approach because it might preclude import.meta.resolve() from adding a standard second argument.
So currently, we have complex user land resolvers that try to emulate what Node does, like Rollup's.
What is the feature you are proposing to solve the problem?
I think node:module should provide a function to perform built-in resolution, given a referrer path and import conditions.
This API would be free from having to conform to the import.meta.resolve() standard. import.meta.resolve() would still exist for cross-platform needs of resolving from within the referrer only.
What alternatives have you considered?
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先审查 Node 现有的 import.meta.resolve() 行为,以及 issue 中描述的 node:module API 表面。定义一个接受引用者路径和导入条件的异步内置解析器,同时保留 import.meta.resolve() 以供标准跨平台使用;当所提议的 API 及其兼容性影响得到确定时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- api, backend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100