esm: add experimental support for addon modules
Add experimental support to loading .node extension modules in ESM.
An addon exports two names default and module.exports, as same as import(cjs) where
its export names can not be preparsed. Addon export names can not be inferred until it is evaluated.
Fixes: https://github.com/nodejs/node/issues/40541 Fixes: https://github.com/nodejs/node/issues/55821
Review requested:
- [ ] @nodejs/gyp
- [ ] @nodejs/loaders
The commit message does not meet our guidelines, the word after the subsystem should be an infinitive verb. I suggest esm: add experimental support for addon modules
Codecov Report
:x: Patch coverage is 86.73469% with 13 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 88.54%. Comparing base (990497c) to head (0169b9c).
:warning: Report is 1968 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| lib/internal/modules/esm/translators.js | 85.22% | 13 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #55844 +/- ##
==========================================
- Coverage 88.55% 88.54% -0.02%
==========================================
Files 657 657
Lines 190295 190377 +82
Branches 36542 36552 +10
==========================================
+ Hits 168511 168564 +53
- Misses 14969 14991 +22
- Partials 6815 6822 +7
| Files with missing lines | Coverage Δ | |
|---|---|---|
| lib/internal/modules/esm/formats.js | 98.64% <100.00%> (+0.09%) |
:arrow_up: |
| lib/internal/modules/esm/load.js | 91.94% <100.00%> (+0.10%) |
:arrow_up: |
| src/node_options.cc | 88.00% <100.00%> (+0.01%) |
:arrow_up: |
| src/node_options.h | 98.30% <100.00%> (+<0.01%) |
:arrow_up: |
| lib/internal/modules/esm/translators.js | 91.50% <85.22%> (-1.44%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
CI: https://ci.nodejs.org/job/node-test-pull-request/63746/
This needs a rebase.
CI: https://ci.nodejs.org/job/node-test-pull-request/64069/
CI: https://ci.nodejs.org/job/node-test-pull-request/64070/
CI: https://ci.nodejs.org/job/node-test-pull-request/64085/
CI: https://ci.nodejs.org/job/node-test-pull-request/64094/
CI: https://ci.nodejs.org/job/node-test-pull-request/64110/
Rebased to address conflicts.
CI: https://ci.nodejs.org/job/node-test-pull-request/64132/
CI: https://ci.nodejs.org/job/node-test-pull-request/64134/
CI is green now, would you mind taking another look at this PR? @nodejs/loaders thanks
CI is green now, would you mind taking another look at this PR? @nodejs/loaders thanks
I will do this evening
Landed in b6df12819da0fd1e1a8dbeb65f5ddc54cb267ddf
Can you please send a backport PR for v22.x-staging? There a number of outstanding conflicts in translators.js to resolve