Skip to content

fix: add main field to pro packages for legacy resolver compatibility#2256

Merged
ihabadham merged 1 commit intomasterfrom
ihabadham/fix/add-main-field-to-pro-packages
Dec 26, 2025
Merged

fix: add main field to pro packages for legacy resolver compatibility#2256
ihabadham merged 1 commit intomasterfrom
ihabadham/fix/add-main-field-to-pro-packages

Conversation

@ihabadham
Copy link
Copy Markdown
Collaborator

@ihabadham ihabadham commented Dec 26, 2025

Summary

  • Adds main field to react-on-rails-pro package.json pointing to lib/ReactOnRails.full.js
  • Adds main field to react-on-rails-pro-node-renderer package.json pointing to lib/ReactOnRailsProNodeRenderer.js

This ensures compatibility with legacy module resolvers like eslint-import-resolver-node and eslint-import-resolver-babel-module that use the resolve npm package, which doesn't support Node.js conditional exports.

Without the main field, these resolvers produce false positive "Unable to resolve path to module" errors even though imports work correctly at runtime.

Test plan

  • Verify the main field paths match the default export in each package's exports field
  • Confirm ESLint import resolver no longer produces false positives for pro package imports

Fixes #2255

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated package configuration for the React on Rails Pro packages to improve module resolution.

✏️ Tip: You can customize this high-level summary in your review settings.

Add the `main` field to react-on-rails-pro and react-on-rails-pro-node-renderer
package.json files to ensure compatibility with legacy module resolvers like
eslint-import-resolver-node and eslint-import-resolver-babel-module.

These resolvers use the `resolve` npm package which doesn't support Node.js
conditional exports, causing false positive "Unable to resolve path to module"
errors even though the imports work at runtime.

Fixes #2255

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 26, 2025

Walkthrough

Two Pro packages received a main field in their package.json files to enable compatibility with ESLint resolvers that rely on the resolve npm package, which does not support Node.js conditional exports and only recognizes the main field.

Changes

Cohort / File(s) Summary
Package Configuration
packages/react-on-rails-pro/package.json, packages/react-on-rails-pro-node-renderer/package.json
Added main field pointing to compiled entry points (lib/ReactOnRails.full.js and lib/ReactOnRailsProNodeRenderer.js respectively). Preserves existing exports field for modern bundlers while providing fallback for legacy resolvers.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested labels

bug, review-needed

Suggested reviewers

  • AbanoubGhadban

Poem

🐰 A main field here, a main field there,
Now ESLint can find us everywhere!
Both Pro packages, shining bright,
Legacy tools see the light. ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding main field to pro packages for legacy resolver compatibility.
Linked Issues check ✅ Passed The changes fully satisfy all objectives: main fields added to both pro packages pointing to correct lib files matching their exports' default paths.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue requirements; only main field additions to two package.json files with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ihabadham/fix/add-main-field-to-pro-packages

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.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Dec 26, 2025

Code Review - PR #2256

Summary

This PR adds the main field to both Pro packages for compatibility with legacy module resolvers. The change is well-justified, minimal, and low-risk.


✅ Strengths

1. Well-Documented Rationale

2. Consistency with Existing Patterns

  • Matches the open-source react-on-rails package which already has both main and exports
  • The main field values correctly point to the same default exports:
    • react-on-rails-pro: lib/ReactOnRails.full.js matches exports['.'].default
    • react-on-rails-pro-node-renderer: lib/ReactOnRailsProNodeRenderer.js matches exports['.'].default

3. Zero Breaking Changes

  • Modern tools (Node.js 12.20+, webpack, Vite) will continue using exports
  • Legacy tools get a fallback via main
  • This is purely additive - no existing behavior changes

⚠️ Required Testing (Per CLAUDE.md)

According to the project's testing guidelines in CLAUDE.md, build script changes require manual verification:

Critical Tests to Run:

# 1. Test clean install (MOST CRITICAL - simulates CI)
rm -rf node_modules
pnpm install -r --frozen-lockfile

# 2. Test build artifacts are created correctly
pnpm run build

# 3. Verify the paths exist as specified in package.json
ls -la packages/react-on-rails-pro/lib/ReactOnRails.full.js
ls -la packages/react-on-rails-pro-node-renderer/lib/ReactOnRailsProNodeRenderer.js

# 4. Test yalc publish (critical for local development)
pnpm run yalc:publish

# 5. Test package scripts work
cd packages/react-on-rails-pro && pnpm run prepare
cd ../react-on-rails-pro-node-renderer && pnpm run prepare

Why this matters:

  • The main field is used by package managers and resolvers
  • If the path is wrong, installs will fail silently for some users
  • CLAUDE.md warns: "Path reference issues can break yalc publish silently"

📋 Test Plan Checklist

The PR's test plan should be completed:

  • Verify the main field paths match the default export in each package's exports field ✅ (verified by review)
  • Confirm ESLint import resolver no longer produces false positives for pro package imports (needs manual testing)

Additional recommended tests:

  • Run pnpm run build and verify artifacts exist at specified paths
  • Test pnpm run yalc:publish succeeds
  • Test installation in a project using eslint-import-resolver-node

🔍 Minor Observations

Path Verification

The paths look correct based on the source files:

  • packages/react-on-rails-pro/src/ReactOnRails.full.tslib/ReactOnRails.full.js
  • packages/react-on-rails-pro-node-renderer/src/ReactOnRailsProNodeRenderer.tslib/ReactOnRailsProNodeRenderer.js

Both packages have prepare scripts that build these files if missing.

Documentation Impact

Consider updating these if they mention module resolution:

  • Package README files (if they exist)
  • Main documentation about importing Pro packages

🎯 Verdict

LGTM with testing requirements

The code change is correct and follows best practices. Before merging:

  1. ✅ Complete the test plan checklist above
  2. ✅ Ensure CI passes (especially install and build steps)
  3. ✅ Manually verify pnpm run yalc:publish works

This is exactly the right fix for the ESLint resolver compatibility issue.


References

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react-on-rails/client bundled (gzip) 62.5 KB (0%)
react-on-rails/client bundled (gzip) (time) 62.5 KB (0%)
react-on-rails/client bundled (brotli) 53.66 KB (0%)
react-on-rails/client bundled (brotli) (time) 53.66 KB (0%)
react-on-rails-pro/client bundled (gzip) 63.45 KB (0%)
react-on-rails-pro/client bundled (gzip) (time) 63.45 KB (0%)
react-on-rails-pro/client bundled (brotli) 54.53 KB (0%)
react-on-rails-pro/client bundled (brotli) (time) 54.53 KB (0%)
registerServerComponent/client bundled (gzip) 127.35 KB (0%)
registerServerComponent/client bundled (gzip) (time) 127.35 KB (0%)
registerServerComponent/client bundled (brotli) 61.39 KB (0%)
registerServerComponent/client bundled (brotli) (time) 61.39 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) 121.96 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) (time) 121.96 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) 56.66 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) (time) 56.66 KB (0%)

@ihabadham ihabadham merged commit 4dcb8fc into master Dec 26, 2025
28 checks passed
@ihabadham ihabadham deleted the ihabadham/fix/add-main-field-to-pro-packages branch December 26, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add main field to react-on-rails-pro and react-on-rails-pro-node-renderer package.json

1 participant