Repository navigation
Conversation
Signed-off-by: Rudy Celekli <[email protected]>
The declared-order fix selected targets against {default, import|require},
but Node's active set for the resolver that owns installed packages also
includes "node" and "node-addons". Ordering only means something against the
full active set, so a package declaring {"node", "import"} resolved to the
wrong target, and a package declaring only {"import"} reported no target
where Node resolves ./node.cjs.
Nested condition objects and fallback arrays are also valid Node targets.
They are now flattened in Node's own order: a condition object stops at its
first active key, so a null or unmatched nested target ends the search, while
an array skips the entries it cannot resolve and concatenates the rest. Node
does not fall through a target whose file is absent, so the first flattened
target stands and its absence is reported rather than skipped.
A valid exports map that matches no active condition is reported as external
with the declared condition names, and one that selects an unsupported nested
or array target no longer borrows the "not valid package JSON" reason.
The differential test installs a real package and resolves the same bare
specifier through Node and through REA, mirroring file presence between the
filesystem and the inventory. 18 of the 25 cases fail without this change.
|
Pushed Three things were left, all reachable through the function this PR changes: 1. Ordering was applied to a partial condition set. The active set is
2. Nested condition objects and array fallbacks were reported as malformed. Both are valid Node inputs. Flattening them needed care about where Node stops:
3. The test now mirrors file presence between the real filesystem and the inventory and asserts REA's leaf equals Node's stdout, pinning both sides. 18 of its 25 cases fail against the pre-change file. One thing I did not change, since your PR body already scopes it out: subpath maps are still only resolved via the |
|
Thanks for extending the active condition set and adding the real Node comparisons. I reviewed and preserved those additions after this merged. The additional controls found two remaining distinctions in that expanded path: a nested condition object with no match should allow the next outer condition, whereas an explicit null target blocks it; array fallback should skip invalid targets, stop at the first usable target, and retain the final invalid-versus-null outcome if none succeeds. I prepared the focused follow-up in #606, preserving your admission checks and existing diagnostics. Five of the 34 actual Node controls failed on merged main before that follow-up; all 34 plus the 28 application path-resolution tests pass afterward. |
|
Thanks, @rudycelekli, for your work on “fix(javascript): honor package exports condition order.” I appreciate your contribution to REA. |
* fix(javascript): honor package exports condition order Signed-off-by: Rudy Celekli <[email protected]> * fix(javascript): resolve exports against Node's full condition set The declared-order fix selected targets against {default, import|require}, but Node's active set for the resolver that owns installed packages also includes "node" and "node-addons". Ordering only means something against the full active set, so a package declaring {"node", "import"} resolved to the wrong target, and a package declaring only {"import"} reported no target where Node resolves ./node.cjs. Nested condition objects and fallback arrays are also valid Node targets. They are now flattened in Node's own order: a condition object stops at its first active key, so a null or unmatched nested target ends the search, while an array skips the entries it cannot resolve and concatenates the rest. Node does not fall through a target whose file is absent, so the first flattened target stands and its absence is reported rather than skipped. A valid exports map that matches no active condition is reported as external with the declared condition names, and one that selects an unsupported nested or array target no longer borrows the "not valid package JSON" reason. The differential test installs a real package and resolves the same bare specifier through Node and through REA, mirroring file presence between the filesystem and the inventory. 18 of the 25 cases fail without this change. * style: apply Prettier to the conditional exports differential test --------- Signed-off-by: Rudy Celekli <[email protected]> Co-authored-by: morluto <[email protected]>
Summary
Select supported default/import/require package export conditions in declared insertion order. Real source-owned installed-package Node import and require subprocesses prove default-before-specific selects default; no expansion of unsupported nested/array conditions.
No tracking issue: this is a focused correctness regression found through production-seam reproduction.
Problem and expected behavior
Module relationship selection now respects supported condition insertion order; nested and array-condition coverage remains as before.
Change and scope
The change stays in the owning adapter/application stage and corrects existing behavior without adding tools or broadening provider coverage.
Contract and boundary impact
Evidence and regression coverage
Two base-revision mismatches; 30 focused tests pass. Real installed-package Node import and require subprocesses select the earlier default condition.
Tests exercise production parsing, filesystem, HTTP, or browser seams, without module mocks. Evidence above is executed; unverified platform/provider coverage is stated explicitly.
Validation performed
All required local gates passed on the signed commit:
npm run check:prnpm run check:cinpm run verify:packagenpm pack --dry-runDevelopment runtime: Node.js 24.18.0 and npm 11.16.0. Upstream CI is separate from these local results.
Compatibility, safety, and release
No migration or package dependency changes. Real Hopper/Ghidra verification was not run; this patch does not change those providers. Remaining proof limits are stated above. The final diff contains source and tests only.
Prepared with AI assistance.