nodejs / nodejs/node

[Node 20] ESM Loaders no longer have `process.argv` access

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

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

loaders stale
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

20.x

Platform

Darwin MacBook-Pro-2.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?
// foo.mjs
console.log('argv:', process.argv);

// bar.mjs
console.log('hello from bar', process.version);

Run:

$ node --loader ./foo.mjs bar.mjs --hello=world

Output:

$ node --loader ./foo.mjs bar.mjs --hello=world
# (node:37260) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
# (Use `node --trace-warnings ...` to show where the warning was created)
# argv: [
#   '/.../.volta/tools/image/node/18.12.1/bin/node',
#   '/.../bar.mjs',
#  '--hello=world'
# ]
# hello from bar v18.12.1

$ volta install node@20.2.0 # or any 20.x
$ node --loader ./foo.mjs bar.mjs --hello=world
# (node:37288) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
# (Use `node --trace-warnings ...` to show where the warning was created)
# argv: [ '/.../.volta/tools/image/node/20.2.0/bin/node' ]
# hello from bar v20.2.0
How often does it reproduce? Is there a required condition?

Every time.

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

Have access to process.argv

What do you see instead?

Doesn't receive any arguments beyond node path

Additional information

This is a breaking change introduced by #44710 & it was not listed in the PR notes.

Additionally, this breaking change wasn't listed in the 20.x Changelog

As indicated by https://github.com/nodejs/node/pull/44710#issuecomment-1609957745, the knowledge of this impact is assumed based on the user understanding (& awareness) of loaders now being off main thread.

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

Bắt đầu bằng cách tái hiện các lệnh Node 18.x và 20.x được nêu trong issue với foo.mjs và bar.mjs. Đọc thảo luận được liên kết #44710 và phần Custom ESM Loader Hooks trong doc/changelogs/CHANGELOG_V20.md để hiểu hành vi dự kiến. Công việc được coi là hoàn tất khi giải quyết được hồi quy process.argv hoặc ghi lại breaking change đã được xác nhận trong các ghi chú phát hành phù hợp.

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, node.js
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
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/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.