esm: end-of-life DEP0151 main index lookup - #65289
Open
anonrig wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
ES module main entry resolution now requires an explicit "exports" or "main" field with the exact file extension. The legacy index.js and extension-searching lookups that previously succeeded with a DEP0151 warning now throw ERR_INVALID_PACKAGE_CONFIG. This is a semver-major change. It is triggered by `import 'pkg'` when the resolved package entry is an ES module and either has no "main"/"exports" field or has a "main" value that omits the file extension. CommonJS packages are unaffected. Refs: nodejs#37206 Refs: nodejs#36918 Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Contributor
|
The
notable-change
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65289 +/- ##
==========================================
+ Coverage 90.31% 90.32% +0.01%
==========================================
Files 751 751
Lines 249956 249953 -3
Branches 47204 47207 +3
==========================================
+ Hits 225745 225770 +25
+ Misses 15612 15563 -49
- Partials 8599 8620 +21
🚀 New features to boost your workflow:
|
jsumners-nr
approved these changes
Aug 14, 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.
Description
End-of-Life for DEP0151: main index lookup and extension searching for ES module
import 'pkg'resolution.All ES module main entry point resolutions now require an explicit
"exports"or"main"entry with the exact file extension. The lookups that previously succeeded with aDEP0151warning now throwERR_INVALID_PACKAGE_CONFIG.CommonJS packages are unchanged and can still use index lookup and extension searching.
Why
DEP0151 has been a runtime deprecation since v16.0.0 (documentation-only since v15.8.0 / v14.18.0). Resolving an ES module should always use an exact path, including file name and extension.
Behavior change (semver-major)
import 'pkg'with{ "type": "module" }and nomain/exports— loadsindex.jswithDEP0151ERR_INVALID_PACKAGE_CONFIGimport 'pkg'with{ "type": "module", "main": "index" }— extension search +DEP0151ERR_INVALID_PACKAGE_CONFIGimport 'pkg'with{ "type": "module", "main": "./index.js" }import 'pkg'of a CommonJS package with nomainChanges
lib/internal/modules/esm/resolve.js: replaceemitLegacyIndexDeprecation()withthrowIfLegacyIndexESM()doc/api/deprecations.md: mark DEP0151 as End-of-Lifedoc/api/packages.md/doc/api/esm.md: document the exact-extension requirementERR_INVALID_PACKAGE_CONFIGinstead of aDEP0151warningTest plan
make lint-js— passtools/lint-md/lint-md.mjson changed docs — passpython3 tools/test.pytargeted ESM tests — 6/6 passpython3 tools/test.py test/es-module— 243/243 passRefs: #37206
Refs: #36918