Skip to content

Conversation

@Lordfirespeed
Copy link
Contributor

@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
Contributor 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.

@codecov
Copy link

codecov bot commented Apr 9, 2025

Codecov Report

Attention: Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.22%. Comparing base (b197355) to head (41d80f0).
Report is 222 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/main/worker_thread.js 92.85% 1 Missing ⚠️
lib/internal/modules/esm/loader.js 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57804      +/-   ##
==========================================
- Coverage   90.23%   90.22%   -0.02%     
==========================================
  Files         633      633              
  Lines      186818   186844      +26     
  Branches    36668    36682      +14     
==========================================
- Hits       168578   168575       -3     
- Misses      11036    11045       +9     
- Partials     7204     7224      +20     
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.94% <100.00%> (+0.02%) ⬆️
lib/internal/worker.js 99.82% <100.00%> (-0.01%) ⬇️
lib/internal/main/worker_thread.js 94.40% <92.85%> (-0.08%) ⬇️
lib/internal/modules/esm/loader.js 95.98% <80.00%> (-0.09%) ⬇️

... and 36 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
Contributor 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?

@joyeecheung joyeecheung mentioned this pull request Apr 15, 2025
@Lordfirespeed
Copy link
Contributor Author

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

@Lordfirespeed
Copy link
Contributor Author

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

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina added notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version. labels Apr 18, 2025
@github-actions
Copy link
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @mcollina.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 18, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 18, 2025
@nodejs-github-bot
Copy link
Collaborator

@targos
Copy link
Member

targos commented Apr 18, 2025

There's a test for import.meta.main === false, but not for true, I think?

@LiviaMedeiros
Copy link
Member

There's a test for import.meta.main === false, but not for true, I think?

There is:

assert.strictEqual(import.meta.main, true);

But it would still be nice to cover more cases, e.g.:

  • worker threads
  • child process (exec, fork)
  • --eval

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the backport-requested-v22.x PRs awaiting manual backport to the v22.x-staging branch. label Jun 10, 2025
@aduh95
Copy link
Contributor

aduh95 commented Jun 10, 2025

test/parallel/test-worker-data-url.js is failing on v22.x with this change. Manual backport PR would be required if we want it on v22.x release line.

@Lordfirespeed
Copy link
Contributor Author

@aduh95 I'm happy to do the work for the v22 backport. Is there a section of the contributing docs I should look at for guidance?

@aduh95
Copy link
Contributor

aduh95 commented Jun 10, 2025

There's

## Submitting a backport pull request

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

Labels

backport-requested-v22.x PRs awaiting manual backport to the v22.x-staging branch. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import.meta.main