Skip to content

Conversation

@mark-wiemer
Copy link
Member

PR Checklist

Overview

mjs files were sometimes loaded like cjs files despite their extension. In some versions of Node (including Node 20.19.4) this causes breaking issues caught by our tests. A separate PR will bump Node versions in CI.

Copy link

@trentm trentm left a comment

Choose a reason for hiding this comment

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

FWIW, this LGTM. :)

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

I would want to give the Node.js folks a chance to respond here just to be safe.

@mark-wiemer
Copy link
Member Author

@JoshuaKGoldberg what would the Node folks respond with? The documentation is clear that files with mjs are sent to the ESM loader, so we should do the same.

@JoshuaKGoldberg
Copy link
Member

🤷 No specific requests, just that I know they were working on this with us recently. I would feel off making non-trivial logic changes without including them.

@trentm
Copy link

trentm commented Aug 19, 2025

the Node folks

By "the Node folks", do you mean for example @legendecas who was involved with the recent #5366 changes?

Copy link
Contributor

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Would you mind updating the test in https://github.com/mochajs/mocha/blob/main/test/integration/compiler-esm.spec.js as well?

I think the test might be ineffective to catch the case described in #5425.

@mark-wiemer
Copy link
Member Author

mark-wiemer commented Aug 23, 2025

+1 to test coverage, not sure how I missed that!

Edit: lolol I was the one that opened this PR, I thought someone else wrote this code. Expect an updated test soon :)

@mark-wiemer
Copy link
Member Author

@legendecas, thanks for calling out test coverage, I think the new tests are good but I'd appreciate your review. I refactored existing ones to use a helper function so that the new tests don't triply-duplicate code.

Copy link
Contributor

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Looks great to me! I like the test flow, it's very clear. ✨

@JoshuaKGoldberg
Copy link
Member

By the way:

✅ All checks have passed

This is lovely to see in PRs again. 🥲

@mark-wiemer
Copy link
Member Author

Failures are just Coveralls, going to merge this one :) (we will be moving to Codecov, ref #5436 )

@mark-wiemer mark-wiemer merged commit a947b9b into main Aug 30, 2025
89 of 93 checks passed
@mark-wiemer mark-wiemer deleted the fix-5425 branch August 30, 2025 04:11
kmalakoff added a commit to kmalakoff/tsds-mocha that referenced this pull request Dec 4, 2025
kmalakoff added a commit to kmalakoff/tsds-mocha that referenced this pull request Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug: .mjs test files can be loaded with require() which breaks custom module loaders

5 participants