GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: explain fallback arrays in package exports targets by manusingh090 · Pull Request #67393 · nodejs/node

Conversation

@manusingh090

@manusingh090 manusingh090 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

The "exports" field definition lists string[] as an accepted type, but
packages.md never explains how an array of targets is resolved. This has
led people to assume an array falls back to the next file when the first
one does not exist (see the linked issue), which is not what happens.

This adds a "Target fallback arrays" section after "Nested conditions"
that documents:

  • an array can be used anywhere a target is accepted, in both "exports"
    and "imports", and items are tried in order;
  • an item is skipped only if it is an invalid target or a conditions
    object with no matching condition;
  • file existence is not checked, so a valid first target that points to a
    missing file fails instead of falling through to the next item;
  • an empty array means the subpath is not exported, and if every item is
    invalid the last error is thrown.

The wording follows PACKAGE_TARGET_RESOLVE in esm.md and
resolvePackageTarget() in lib/internal/modules/esm/resolve.js.

Verification

Tested with a small package in node_modules on Node.js ,
using both require() and import():

exports target Result
["./nope.js", "./b.js"] module not found
["../outside.js", "./b.js"] loads ./b.js
[{ "browser": "./nope.js" }, "./b.js"] loads ./b.js
[] ERR_PACKAGE_PATH_NOT_EXPORTED
["../x.js", "../y.js"] ERR_INVALID_PACKAGE_TARGET

node tools/lint-md/lint-md.mjs doc/api/packages.md passes.

AI disclosure

I used an AI coding assistant to help read the resolver code and draft the
text. I reviewed the section against the resolver source and ran the tests
above myself.

Fixes: #58600

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@manusingh090
doc: explain fallback arrays in package exports targets
ef0d61a
The "exports" field type lists `string[]`, but the packages
documentation never describes how an array of targets is resolved.
Document that items are tried in order, that only invalid targets and
unmatched conditions are skipped, and that a missing file does not
cause the next item to be tried.

Fixes: nodejs#58600
Signed-off-by: Manjeet Singh <[email protected]>
@nodejs-github-bot

nodejs-github-bot commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to Node.js documentation. label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

  • the guide for first-time contributors
  • the contribution and automation policies
  • the pull request guide
  • the AI use policy
  • the Code of Conduct

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ljharb
ljharb approved these changes Nov 10, 2026
View reviewed changes

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jsumners-nr
jsumners-nr approved these changes Nov 11, 2026
View reviewed changes
JakobJingleheimer
JakobJingleheimer approved these changes Nov 11, 2026
View reviewed changes
@JakobJingleheimer JakobJingleheimer added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 11, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 4ad8171 into nodejs:main Nov 12, 2026
25 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in 4ad8171

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 12, 2026
aduh95 pushed a commit that referenced this pull request Nov 16, 2026
@manusingh090 @aduh95
doc: explain fallback arrays in package exports targets
e396cb0
The "exports" field type lists `string[]`, but the packages
documentation never describes how an array of targets is resolved.
Document that items are tried in order, that only invalid targets and
unmatched conditions are skipped, and that a missing file does not
cause the next item to be tried.

Fixes: #58600
Signed-off-by: Manjeet Singh <[email protected]>
PR-URL: #67393
Reviewed-By: Jordan Harband <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 16, 2026
2026-11-16, Version 27.0.0-alpha.0.1.1 (Alpha) #67515
Merged
aduh95 pushed a commit that referenced this pull request Nov 17, 2026
@manusingh090 @aduh95
doc: explain fallback arrays in package exports targets
c6e2cc4
The "exports" field type lists `string[]`, but the packages
documentation never describes how an array of targets is resolved.
Document that items are tried in order, that only invalid targets and
unmatched conditions are skipped, and that a missing file does not
cause the next item to be tried.

Fixes: #58600
Signed-off-by: Manjeet Singh <[email protected]>
PR-URL: #67393
Reviewed-By: Jordan Harband <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@manusingh090 @gabylb
doc: explain fallback arrays in package exports targets
ca903c6
The "exports" field type lists `string[]`, but the packages
documentation never describes how an array of targets is resolved.
Document that items are tried in order, that only invalid targets and
unmatched conditions are skipped, and that a missing file does not
cause the next item to be tried.

Fixes: nodejs#58600
Signed-off-by: Manjeet Singh <[email protected]>
PR-URL: nodejs#67393
Reviewed-By: Jordan Harband <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ljharb ljharb ljharb approved these changes
@JakobJingleheimer JakobJingleheimer JakobJingleheimer approved these changes
+1 more reviewer
@jsumners-nr jsumners-nr jsumners-nr approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

doc Issues and PRs related to Node.js documentation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Missing documentation for exports alternative paths

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@manusingh090 @nodejs-github-bot @ljharb @JakobJingleheimer @jsumners-nr
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.