nodejs / nodejs/node

ESM re-exports from CJS module not included in exports

Đang mở
#61,989 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

loaders
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.3k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
283

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện vấn đề với main.mjs, mod.js và other.js bằng node main.mjs, sau đó so sánh đầu ra namespace của Node với ví dụ Deno. Theo dõi việc Node phát hiện export CommonJS-to-ESM và xác minh rằng export kiểm thử từ other.js được bao gồm trong namespace.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, nodejs
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.