nodejs / nodejs/node

Provide built-in implementations of module linker, initializeImportMeta, importModuleDynamically

未关闭
#31,234 12 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

vm
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

Is your feature request related to a problem? Please describe.

When using vm.SourceTextModule we have to implement a linker, initializeImportMeta, and importModuleDynamically, even if we just want the default behavior of built-in module support. There are many subtle ways to get that wrong.

Describe the solution you'd like

Default implementations that do basically what built-in module support does:

  • A linker function that:
    • Reads files from disk, within a specified root.
    • Uses Node module resolution as implemented for modules
    • Uses a specified module cache
    • initializeImportMeta that sets url property
    • By configuration, allows access to built-in modules.

Describe alternatives you've considered

Userland libraries can take the first cuts at easy-to-use vm.Modules, but I think something for common use cases should likely be included.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 vm.SourceTextModule 入口点以及 issue 中引用的 Node 模块解析行为开始。处理 linker、initializeImportMeta 和 importModuleDynamically 所请求的默认值,包括 root、模块缓存和内置模块配置。完成的标准是常见的 vm.Modules 可以在不使用自定义回调的情况下使用内置实现。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
backend
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。