Tracking Issue: Syncify the ESM Loader
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.4k
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 272
Mô tả
The code under lib/internal/modules/esm, a.k.a. the ESM loader, contains many functions that are async. We should refactor as many of these as possible, ideally all of them, to be synchronous. This should improve the performance of evaluating ESM code, bringing it roughly on par with the speed of running CommonJS code.
Longer term, once the ESM loader is synchronous and we land the synchronous module customization hooks, we could deprecate monkey-patching the CommonJS loader and merge together the CommonJS and ESM loaders, eliminating duplication: https://github.com/nodejs/node/issues/50356.
This issue will track our progress syncifying the various files and functions of the ESM loader until we can get as much of it to be as synchronous as possible.
The files to be updated, all underlib/internal/modules:
-
run_main.js:asyncRunEntryPointWithESMLoader -
esm/fetch_module.js:fetchWithRedirects -
esm/fetch_module.js:isLocalAddress -
esm/hooks.js:Hooksclass (the async methods here probably don’t need updating as they will be removed once we migrate to the synchronous customization hooks) -
esm/hooks.js:nextHookFactory -
esm/load.js:getSourcehttps://github.com/nodejs/node/pull/57419 -
esm/load.js:defaultLoadhttps://github.com/nodejs/node/pull/57419 -
esm/loader.js:ModuleLoader.eval -
esm/loader.js:ModuleLoader.getModuleJobForImport -
esm/loader.js:ModuleLoader.loadAndTranslate -
esm/loader.js:ModuleLoader.import -
esm/loader.js:ModuleLoader.load -
esm/module_job.js:ModuleJob._link -
esm/module_job.js:ModuleJob._instantiate -
esm/module_job.js:ModuleJob.run -
esm/module_job.js:ModuleJobSync.run -
esm/translators.js:wasmhandler, viatranslators.set('wasm', ... -
esm/utils.js:importModuleDynamicallyCallback -
esm/utils.js:initializeHooks(might not need updating as we will remove this once the synchronous customization hooks land -
esm/worker.js:customizedModuleWorker(might not need updating as we will remove this once the synchronous customization hooks land -
esm/worker.js:handleMessage(might not need updating as we will remove this once the synchronous customization hooks land
@nodejs/loaders @mcollina @JakobJingleheimer @joyeecheung
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với các mục chưa được đánh dấu trong lib/internal/modules, đặc biệt là các hàm được nêu tên trong esm/loader.js và esm/module_job.js, đồng thời đọc đề xuất được liên kết về các hook tùy biến module đồng bộ. Xác định những hàm async nào vẫn nằm trong phạm vi và các hàm gọi chúng phụ thuộc vào chúng như thế nào. Được xem là hoàn tất khi chuyển một tập hợp phù hợp các hàm được liệt kê sang hoạt động đồng bộ mà vẫn duy trì hành vi của trình tải ESM.
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
- Lĩnh vực
- backend, devtools
- Loại issue
- Tái cấu trúc
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100