Skip to content
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

module: unify TypeScript and .mjs handling in CommonJS #55590

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Oct 29, 2024

This refactors the CommonJS loading a bit to create a center point that handles source loading (loadSource) and make format detection more consistent to pave the way for future synchronous hooks.

  • Handle .mjs in the .js handler, similar to how .cjs has been handled.
  • Generate the legacy ERR_REQUIRE_ESM in a getRequireESMError() for both .mts and require(esm) handling (when it's disabled).

Refs: nodejs/loaders#198

This refactors the CommonJS loading a bit to create a center point
that handles source loading (`loadSource`) and make format detection
more consistent to pave the way for future synchronous hooks.

- Handle .mjs in the .js handler, similar to how .cjs has been handled.
- Generate the legacy ERR_REQUIRE_ESM in a getRequireESMError() for
  both .mts and require(esm) handling (when it's disabled).
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Oct 29, 2024
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 29, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 29, 2024
@nodejs-github-bot
Copy link
Collaborator

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.43%. Comparing base (e160e54) to head (47244a0).
Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #55590   +/-   ##
=======================================
  Coverage   88.43%   88.43%           
=======================================
  Files         654      654           
  Lines      187674   187698   +24     
  Branches    36124    36135   +11     
=======================================
+ Hits       165969   165997   +28     
+ Misses      14952    14944    -8     
- Partials     6753     6757    +4     
Files with missing lines Coverage Δ
lib/internal/modules/cjs/loader.js 97.83% <100.00%> (+0.24%) ⬆️

... and 19 files with indirect coverage changes

@nodejs-github-bot
Copy link
Collaborator

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

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Oct 30, 2024
Copy link
Member

@marco-ippolito marco-ippolito left a comment

Choose a reason for hiding this comment

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

LGTM

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 31, 2024
@nodejs-github-bot nodejs-github-bot merged commit d080f0d into nodejs:main Oct 31, 2024
72 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in d080f0d

RafaelGSS pushed a commit that referenced this pull request Nov 1, 2024
This refactors the CommonJS loading a bit to create a center point
that handles source loading (`loadSource`) and make format detection
more consistent to pave the way for future synchronous hooks.

- Handle .mjs in the .js handler, similar to how .cjs has been handled.
- Generate the legacy ERR_REQUIRE_ESM in a getRequireESMError() for
  both .mts and require(esm) handling (when it's disabled).

PR-URL: #55590
Refs: nodejs/loaders#198
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
louwers pushed a commit to louwers/node that referenced this pull request Nov 2, 2024
This refactors the CommonJS loading a bit to create a center point
that handles source loading (`loadSource`) and make format detection
more consistent to pave the way for future synchronous hooks.

- Handle .mjs in the .js handler, similar to how .cjs has been handled.
- Generate the legacy ERR_REQUIRE_ESM in a getRequireESMError() for
  both .mts and require(esm) handling (when it's disabled).

PR-URL: nodejs#55590
Refs: nodejs/loaders#198
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants