fix: add Metro main/react-native fallbacks for the root entry - #683
antoinerousseau wants to merge 1 commit into
Conversation
Metro still consults `react-native` / `main` when it skips `exports`. Without those fields it looks for `index`, which does not exist. List `react-native` first in the `.` export map so native resolution wins condition matching. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe package metadata now defines ChangesPackage entry resolution
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
| "style": "./uniwind.css", | ||
| "source": "src/index", | ||
| "react-native": "./src/index.ts", | ||
| "main": "./dist/common/index.js", |
There was a problem hiding this comment.
When a legacy Node-compatible resolver uses the new main fallback, it loads dist/common/index.js. That file is generated as CommonJS, but the enclosing package declares "type": "module", so Node treats the .js file as ESM and require() cannot load it. As a result, consumers relying on the new fallback still cannot import the root package. Emit the artifact as .cjs or give dist/common a package manifest declaring "type": "commonjs".
Summary
Metro still consults
react-native/mainwhen it does not useexports(file-map miss, installer stub, older resolvers). Without those fields it defaultsmaintoindex, which this package does not ship:react-nativeto./src/index.ts(same asexports["."].react-native).mainto./dist/common/index.js(same asexports["."].default).react-nativefirst in the"."export map so condition matching prefers the native entry.Fixes the OSS side of #682 (and the same error in #679).
This does not replace #570's origin pin, and it cannot change Uniwind Pro 1.7 (closed source / separate payload). Pro still needs that pin backported; apps that hoist a second
uniwindmay still need to loaduniwind/metrofrom the Pro copy.Test plan
import { Uniwind } from "uniwind"bundles with Expo SDK 57 / Metro whenexportsis skipped (noindexfallback).src/index.tsviareact-native/ exports.dist/common/index.jsviamain/default.Made with Cursor
Summary by CodeRabbit
Bug Fixes
Documentation