Repository navigation
fix(javascript): honor module-sync package exports - #1361
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Reviewed d42085f. No blocking issue found in the diff. Adding module-sync to the existing active condition set preserves declared-key order, invalid-configuration propagation, target selection and refusal handling. The owned real-Node tests exercise both import and require, including null/invalid active targets and earlier-condition precedence; the docs also avoid equating static resolution with arbitrary runtime loadability. Main still lacks this active condition, so this is not superseded. I would merge once the required CI/maintainer approval has actually run: this head currently has no check results and GitHub reports BLOCKED. This recommendation is based on code/test review and the PR-recorded Node 22/24 differential evidence; I did not independently rerun that differential suite in this review. |
Summary
Honor Node's
module-syncpackage export condition during static JavaScript application analysis. A package withexports: { "module-sync": "./sync.mjs", "default": "./fallback.cjs" }currently yields a confidently resolvedfallback.cjsrelationship even though the supported Node runtime selectssync.mjs.No linked issue: this small bug was discovered through an owned fixture and reproduced against the compiled CLI and real Node loaders. Searches for
module-syncfound no issue/PR. Related #591, #606, #1181 and #1333 handle order, fallback, exact targets and invalid configurations; this adds the missing active condition without replacing those rules.Problem and expected behavior
Node's conditional exports contract activates
module-syncfor imports and requires. REA'spackageExportConditionsomits it. This also incorrectly bypasses explicit null or invalid targets under that condition and selects a later default.Change and scope
Add
module-syncto the existing active condition set. Preserve declared-order traversal, nested/array selection, exact-file lookup, admission rules and refusal diagnostics. Extend the existing real-Node/filesystem differential tests and document the condition. No dependencies or public API added.Contract and boundary impact
Evidence and regression coverage
9c4a68bc19a0f7d39557e3cc039f5877f6550f63.analyzeandanalyze-javascript-application, 10 successful invocations. Stdout parsed as JSON, exit status was 0, and both import and require relationships matched native resolution. Static analysis succeeds while retaining unresolved/rejected relationships for refused dependencies.{"module_link_kind":"require","specifier":"fixture","resolved_path":"node_modules/fixture/sync.mjs","resolution_status":"resolved"}; base selectednode_modules/fixture/fallback.cjs.For evidence-bearing changes:
Validation performed
Pinned Node 24.18.0 / npm 11.16.0, locally on macOS arm64:
npm ci— passed; 0 audit vulnerabilities.npm run build:cached— passed.npm run test:focused -- tests/boundary/filesystem/javascriptPackagePrecedence.test.ts tests/boundary/filesystem/javascriptPackageExportTargets.test.ts tests/boundary/javascript/packageConditionalExports.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts src/application/javascript/JavaScriptModuleSpecifierPaths.test.ts— 234 passed, no skips.npm run check— all 6 tasks passed; lint reported warnings, 0 errors.npm run check:fast— both typecheck/lint tasks passed; normal commit formatting/lint hooks passed.npm run check:ci— all 8 static tasks passed.npm run docs:check— all 6 tasks passed.npm run verify:test-discovery— all 699 files discovered exactly once.git diff --check— passed.node_modules/.bin/vitest run tests/boundary/filesystem/javascriptPackagePrecedence.test.ts tests/boundary/filesystem/javascriptPackageExportTargets.test.ts— 97 passed, no skips.Hosted CI observation at
d42085fd760f1bd0a0f02e1c7d3737fa670ece2b: run 37983194315 reportsaction_required, with zero jobs executed and no check results. Maintainer action is needed before hosted validation can proceed. The automated review bot separately reports that its review quota is exhausted; no automated review pass is claimed.Compatibility, safety, and release
check:prwere not run; full deterministic coverage belongs to CI for this focused fix.Review checklist
Prepared and verified locally with OpenAI Codex assistance. All listed testing was agent-executed; no human manual verification is claimed. No AI coauthor trailer is used.