node icon indicating copy to clipboard operation
node copied to clipboard

esm: add experimental support for addon modules

Open legendecas opened this issue 1 year ago • 4 comments

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

legendecas avatar Nov 14 '24 01:11 legendecas

Review requested:

  • [ ] @nodejs/gyp
  • [ ] @nodejs/loaders

nodejs-github-bot avatar Nov 14 '24 01:11 nodejs-github-bot

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

aduh95 avatar Nov 14 '24 11:11 aduh95

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:

... and 23 files with indirect coverage changes

: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.

codecov[bot] avatar Nov 27 '24 17:11 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/63746/

nodejs-github-bot avatar Nov 28 '24 13:11 nodejs-github-bot

This needs a rebase.

joyeecheung avatar Dec 12 '24 14:12 joyeecheung

CI: https://ci.nodejs.org/job/node-test-pull-request/64069/

nodejs-github-bot avatar Dec 16 '24 14:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/64070/

nodejs-github-bot avatar Dec 16 '24 15:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/64085/

nodejs-github-bot avatar Dec 17 '24 14:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/64094/

nodejs-github-bot avatar Dec 18 '24 00:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/64110/

nodejs-github-bot avatar Dec 18 '24 22:12 nodejs-github-bot

Rebased to address conflicts.

legendecas avatar Dec 19 '24 23:12 legendecas

CI: https://ci.nodejs.org/job/node-test-pull-request/64132/

nodejs-github-bot avatar Dec 19 '24 23:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/64134/

nodejs-github-bot avatar Dec 20 '24 01:12 nodejs-github-bot

CI is green now, would you mind taking another look at this PR? @nodejs/loaders thanks

legendecas avatar Dec 20 '24 10:12 legendecas

CI is green now, would you mind taking another look at this PR? @nodejs/loaders thanks

I will do this evening

JakobJingleheimer avatar Dec 20 '24 10:12 JakobJingleheimer

Landed in b6df12819da0fd1e1a8dbeb65f5ddc54cb267ddf

nodejs-github-bot avatar Dec 20 '24 11:12 nodejs-github-bot

Can you please send a backport PR for v22.x-staging? There a number of outstanding conflicts in translators.js to resolve

aduh95 avatar Feb 03 '25 11:02 aduh95