Skip to content

deps: replace part of acorn with amaro - #66051

Open
avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:amaro-acorn
Open

avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:amaro-acorn

Conversation

@avivkeller

@avivkeller avivkeller commented Sep 16, 2026

Copy link
Copy Markdown
Member

We can't 100% remove Acorn just yet, there a few kinks to be worked around, but we can replace some of it, which this PR does.

When 100% done, this should improve the speed of assertions, highlighting, and reduce the size of the Node.js bundle.

cc @marco-ippolito

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/security-wg
  • @nodejs/startup
  • @nodejs/typescript

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Sep 16, 2026
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.23%. Comparing base (18a9ba5) to head (e539d4c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66051   +/-   ##
=======================================
  Coverage   90.23%   90.23%           
=======================================
  Files         789      789           
  Lines      270613   270527   -86     
  Branches    51801    51783   -18     
=======================================
- Hits       244186   244120   -66     
+ Misses      16885    16877    -8     
+ Partials     9542     9530   -12     
Files with missing lines Coverage Δ
lib/internal/bootstrap/realm.js 97.10% <100.00%> (+0.11%) ⬆️
lib/internal/errors/error_source.js 75.78% <100.00%> (-6.77%) ⬇️
lib/internal/repl/completion.js 91.71% <100.00%> (+0.74%) ⬆️
lib/internal/repl/transform.js 54.85% <100.00%> (+0.78%) ⬆️
lib/internal/repl/utils.js 96.88% <100.00%> (-0.05%) ⬇️
src/node_builtins.cc 77.49% <ø> (ø)

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marco-ippolito

marco-ippolito commented Sep 16, 2026

Copy link
Copy Markdown
Member

Can you include benchmarks result from this PR?

@aduh95

aduh95 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Why are there changes in deps/amaro? Those should land as a separate commit, ideally generated by GHA

Comment on lines +459 to +470
function resolveRelativeInDeps(request, parentId) {
const { posix } = requireBuiltin('path');
const id = posix.join(posix.dirname(parentId), request);
// Builtin ids do not carry the file extension.
if (StringPrototypeEndsWith(id, '.js')) {
return StringPrototypeSlice(id, 0, -3);
}
if (StringPrototypeEndsWith(id, '.mjs')) {
return StringPrototypeSlice(id, 0, -4);
}
return id;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we vendor a bundle instead? Doing dynamic resolution is probably expansive, I don't think it's worth it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vendoring a bundle (of Amaro) makes it larger since one of our requirements was having a separate entrypoint for Node.js and non-Node.js consumers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about patching the files to rewrite the require calls? BTW we can forgo the .mjs one as we do not support ESM for builtins modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants