nodejs / nodejs/node

ESM re-exports from CJS module not included in exports

未关闭
#61,989 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

Version

node-v

Platform
Microsoft Windows NT 10.0.26100.0 x64
Subsystem

No response

What steps will reproduce the bug?
// main.mjs
import * as mod from "./mod.js";
console.log(mod);

// mod.js
module.exports = {
  ...require("./other.js")
};

// other.js
export function test() {}
> node main.mjs  
[Module: null prototype] {
  default: { test: [Function: test] },
  'module.exports': { test: [Function: test] }
}
> deno -A --unstable-detect-cjs main.mjs
[Module: null prototype] {
  default: { test: [Function: test] },
  "module.exports": { test: [Function: test] },
  test: [Function: test]
}
How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

It should detect the "test" export from the ES module.

What do you see instead?

It's missing.

Additional information

No response

贡献指南

打开贡献指南

从这里开始

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

调研方向

使用 node main.mjs 通过 main.mjs、mod.js 和 other.js 重现该问题,然后将 Node 的 namespace 输出与 Deno 示例进行比较。跟踪 Node 对 CommonJS-to-ESM 导出的检测,并验证 other.js 中的测试导出包含在 namespace 中。

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

评估

技术栈
javascript, nodejs
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
48/100

把新 issue 发到你的邮箱

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