Repository navigation
fix(javascript): prefer package entrypoints over directory indexes - #575
Merged
morluto merged 1 commit intoOct 5, 2026
Conversation
Collaborator
Author
|
@codex review |
9 tasks done
2 tasks done
darsrc
pushed a commit
to darsrc/rea
that referenced
this pull request
Oct 10, 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.
Summary
Resolve declared JavaScript package entrypoints before directory index fallbacks. A package containing both
main: "actual.cjs"andindex.jscurrently produces a high-confidence graph edge toindex.js, while Node resolvesactual.cjs.Found during a repository audit; no existing issue describes this ordering error.
Change and scope
main: ".", missing legacy-main fallback, cycle diagnostics when no fallback exists, and artifact-container isolation.The existing recursive artifact-package lookup remains as a compatibility heuristic after legacy file/index fallbacks are exhausted. This is a bounded precedence correction; parity with Node is established for the fixture cases rather than claimed for every loader feature.
Problem and evidence
Real filesystem fixtures compare REA's reconstructed require edges against Node's
require.resolve. The matrix covers declared main and exports, bare versus relative requests, self-directory main, missing legacy main, nested-directory indexes, root-index fallback, and cycles with a root index. The expected ordering follows the CommonJS loader algorithm.On unchanged base
52bf709bcefb17ab07e1f9c47c5fadf5eca9bd4e, the final regression matrix has 12 failures and 29 passing controls. The corrected matrix passes. Independent re-review also verified relative missing exports and foreign-container behavior.Contract and boundary impact
Validation performed
npm run check:ci: all seven static tasks passed.npm run docs:check: passed; TypeDoc reported 202 existing warnings and no errors.npm run verify:package: Linux package/install, CLI, and MCP verifier passed.npm pack --dry-run --json: passed.git diff --check: passed.npm run check:pr: static stages passed; final rebased full suite reported 1,812 passed, 40 failed, and 1 skipped. All 40 failures in the same seven native bridge suites reproduce on unchanged52bf709. This environment rejects Unix-domain socket listeners withEPERM, causing startup failures/timeouts. No tests or permission checks were relaxed.Compatibility and release
No schema migration. Node v24.19.0 was used for the real resolution oracle; target modules were not executed for graph construction. No real Hopper/Ghidra verification was performed because native providers are unchanged. Broader conditional-export, package-subpath, and loader-equivalence work remains outside this change.
Review checklist