Skip to content

esm: end-of-life DEP0151 main index lookup - #65289

Open
anonrig wants to merge 1 commit into
nodejs:mainfrom
anonrig:eol-dep0151
Open

esm: end-of-life DEP0151 main index lookup#65289
anonrig wants to merge 1 commit into
nodejs:mainfrom
anonrig:eol-dep0151

Conversation

@anonrig

@anonrig anonrig commented Aug 14, 2026

Copy link
Copy Markdown
Member

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 a DEP0151 warning now throw ERR_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)

Before After
import 'pkg' with { "type": "module" } and no main/exports — loads index.js with DEP0151 Throws ERR_INVALID_PACKAGE_CONFIG
import 'pkg' with { "type": "module", "main": "index" } — extension search + DEP0151 Throws ERR_INVALID_PACKAGE_CONFIG
import 'pkg' with { "type": "module", "main": "./index.js" } Unchanged
import 'pkg' of a CommonJS package with no main Unchanged

Changes

  • lib/internal/modules/esm/resolve.js: replace emitLegacyIndexDeprecation() with throwIfLegacyIndexESM()
  • doc/api/deprecations.md: mark DEP0151 as End-of-Life
  • doc/api/packages.md / doc/api/esm.md: document the exact-extension requirement
  • Tests: expect ERR_INVALID_PACKAGE_CONFIG instead of a DEP0151 warning

Test plan

  • make lint-js — pass
  • tools/lint-md/lint-md.mjs on changed docs — pass
  • python3 tools/test.py targeted ESM tests — 6/6 pass
  • python3 tools/test.py test/es-module — 243/243 pass

Refs: #37206
Refs: #36918

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/userland-migrations

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>
@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 Aug 14, 2026
@anonrig anonrig added semver-major PRs that contain breaking changes and should be released in the next major version. deprecations Issues and PRs related to deprecations. module Issues and PRs related to the module subsystem. notable-change PRs with changes that should be highlighted in changelogs. labels Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

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.

@anonrig
anonrig requested a review from a team August 14, 2026 17:51
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.32%. Comparing base (f83e7df) to head (343b8b2).
⚠️ Report is 1 commits behind head on main.

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     
Files with missing lines Coverage Δ
lib/internal/modules/esm/resolve.js 99.05% <100.00%> (-0.01%) ⬇️

... and 32 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.

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

Labels

deprecations Issues and PRs related to deprecations. esm Issues and PRs related to the ECMAScript Modules implementation. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants