Skip to content

esm: implement import.meta.main #57804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Lordfirespeed
Copy link

@Lordfirespeed Lordfirespeed commented Apr 9, 2025

Implements #57226

This PR supersedes #32223

Fixes: #57226

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Apr 9, 2025
@Lordfirespeed
Copy link
Author

Lordfirespeed commented Apr 9, 2025

@ljharb I would appreciate your review on this r.e. performance - I am particularly concerned about my changes in lib/internal/modules/esm/translators.js, since I'm not familiar with implications of assignment to a JS object associated with a native object.

Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.24%. Comparing base (ada4abf) to head (80e167a).
Report is 49 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57804      +/-   ##
==========================================
+ Coverage   90.21%   90.24%   +0.03%     
==========================================
  Files         630      630              
  Lines      185518   185680     +162     
  Branches    36383    36398      +15     
==========================================
+ Hits       167360   167573     +213     
+ Misses      11033    11000      -33     
+ Partials     7125     7107      -18     
Files with missing lines Coverage Δ
lib/internal/modules/esm/initialize_import_meta.js 100.00% <100.00%> (ø)
lib/internal/modules/esm/translators.js 91.59% <100.00%> (+0.01%) ⬆️
lib/internal/modules/esm/utils.js 98.93% <100.00%> (+0.02%) ⬆️

... and 46 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.

@Lordfirespeed
Copy link
Author

@ljharb I've moved the assignment into compileSourceTextModule, but I'm a bit confused

I think I can see where the cache is populated, but not where it is hit in compileSourceTextModule (unless it's in CPP?)
That leads me to think the cache gets hit at some point before the standard moduleStrategy function is used, which would mean moving the assignment either has no effect or is detrimental.

What am I missing?

Co-authored-by: Jordan Harband <[email protected]>
@Lordfirespeed
Copy link
Author

I think CI should pass now. make -j$(nproc) test is passing locally.

@Lordfirespeed
Copy link
Author

I checked locally, it seems the test no longer fails with unusual character names using a relative import path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import.meta.main
7 participants