Repository navigation
fix: add package.json exports to avoid DEP0151 warning - #6168
Merged
mark-wiemer merged 2 commits intoJul 23, 2026
Merged
Conversation
Add an explicit exports map so Node stops falling back to deprecated default index lookups for ESM package resolution. Keep the wildcard subpath export to preserve existing deep imports and browser bundle accessibility. Fixes: mochajs#6147 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6168 +/- ##
=======================================
Coverage 82.55% 82.55%
=======================================
Files 64 64
Lines 4798 4798
Branches 1074 1045 -29
=======================================
Hits 3961 3961
Misses 837 837 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3 tasks done
JoshuaKGoldberg
approved these changes
Jul 23, 2026
JoshuaKGoldberg
left a comment
Member
There was a problem hiding this comment.
exportsis the modern alternative tomain
This - I'm in favor of preferring the new modern thing.
11 tasks done
This was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
status: accepting prsOverview
Adds an
exportsmap that points the package root to the existing./index.jsentry point and keeps a wildcard subpath export so existing deep imports (e.g.mocha/lib/reporters/*) and browser bundle files remain reachable.Node 22+ emits a
[DEP0151] DeprecationWarningwhen an ES module package is resolved without an explicit"main"or"exports"field. Mocha 12 is now"type": "module", so importing the package root triggered the warning.exportsis the modern alternative tomain, supporting advanced features like pattern-matching and conditional exports.mainis still supported. Because our project did not have eitherexportsormainbefore this, we were implicitly exporting everything, and we must continue to do so to avoid a breaking change. Ref https://nodejs.org/api/packages.html#package-entry-points.In the future, we can restrict what we export for future major versions of Mocha.