Skip to content

Conversation

@maniktyagi04
Copy link

Fixes #31481

This fixes a bug where CJS reexport resolution was using incorrect
export conditions. The code was using a hardcoded array with the 'deno'
condition, but should use REQUIRE_CONDITIONS which contains 'require'
and 'node' conditions, consistent with other require-based resolution.

This addresses the FIXME comment in analyze.rs that noted the
conditions were likely incorrect.This fixes a bug where CJS reexport resolution was using incorrect export conditions. The code was using a hardcoded array with 'deno' condition, but should use REQUIRE_CONDITIONS which contains 'require' and 'node' conditions, consistent with other require-based resolution.

This addresses the FIXME comment in analyze.rs that noted the conditions were likely incorrect.

@CLAassistant
Copy link

CLAassistant commented Dec 3, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Walkthrough

The change replaces inline hard-coded condition arrays with a centralized REQUIRE_CONDITIONS constant across two call sites in the reexports analysis in libs/node_resolver/analyze.rs. It adds use crate::REQUIRE_CONDITIONS and keeps control flow, error handling, and the resolved kind (NodeResolutionKind::Execution) unchanged.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing a hardcoded array with REQUIRE_CONDITIONS for CJS reexport resolution.
Description check ✅ Passed The description clearly explains the bug fix, references the linked issue, and outlines what was changed and why.
Linked Issues check ✅ Passed The PR directly addresses all objectives from issue #31481: replacing hardcoded conditions with REQUIRE_CONDITIONS and removing the incorrect 'deno' condition from CJS resolution.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective: replacing inline condition arrays with REQUIRE_CONDITIONS in CJS reexport resolution, with no unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3a212b and 1fe5fab.

📒 Files selected for processing (1)
  • libs/node_resolver/analyze.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/node_resolver/analyze.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This fixes a bug where CJS reexport resolution was using incorrect
export conditions. The code was using a hardcoded array with 'deno'
condition, but should use REQUIRE_CONDITIONS which contains 'require'
and 'node' conditions, consistent with other require-based resolution.

This addresses the FIXME comment in analyze.rs that noted the
conditions were likely incorrect.
@maniktyagi04 maniktyagi04 force-pushed the fix-cjs-reexport-conditions branch from a3a212b to 1fe5fab Compare December 3, 2025 07:08
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

Do you have a test that was failing before and now passes?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(node): CJS reexport resolution uses incorrect export conditions

3 participants