Problem
Metro (Expo SDK 57 / expo export) fails to resolve import { Uniwind } from "uniwind" with:
Error: While trying to resolve module `uniwind` from file `.../_layout.tsx`,
the package `.../node_modules/uniwind/package.json` was successfully found.
However, this package itself specifies a `main` module field that could not be resolved
(`.../node_modules/uniwind/index`).
packages/uniwind/package.json (v1.12.0, and the Uniwind Pro payload) has an exports map but no top-level main or react-native field. Metro then defaults main to index, which does not exist.
This is the same class of failure as facebook/metro#1424.
Expo's resolver also matches exports conditions in key order. The "." map currently starts with "style": "./uniwind.css", then "types", then "browser", and only later "react-native". If package exports are skipped or fail, there is no main fallback.
Repro context
We hit this in a pnpm workspace that also has a second app depending on public uniwind, while another app aliases Uniwind Pro:
"uniwind": "npm:uniwind-pro@^1.7.0"
With publicHoistPattern: "*", Node's require("uniwind/metro") can walk past the Pro installer stub and load the public package. Metro then bundles against the stub/payload that has no main.
Suggested fix
In packages/uniwind/package.json:
"main": "./src/index.ts",
"react-native": "./src/index.ts"
(using the same path as exports["."].react-native)
Optionally put "react-native" before "style" in the "." exports map so Expo's key-order matching prefers the native entry.
Happy to send a PR if that's useful.
Problem
Metro (Expo SDK 57 /
expo export) fails to resolveimport { Uniwind } from "uniwind"with:packages/uniwind/package.json(v1.12.0, and the Uniwind Pro payload) has anexportsmap but no top-levelmainorreact-nativefield. Metro then defaultsmaintoindex, which does not exist.This is the same class of failure as facebook/metro#1424.
Expo's resolver also matches
exportsconditions in key order. The"."map currently starts with"style": "./uniwind.css", then"types", then"browser", and only later"react-native". If package exports are skipped or fail, there is nomainfallback.Repro context
We hit this in a pnpm workspace that also has a second app depending on public
uniwind, while another app aliases Uniwind Pro:With
publicHoistPattern: "*", Node'srequire("uniwind/metro")can walk past the Pro installer stub and load the public package. Metro then bundles against the stub/payload that has nomain.Suggested fix
In
packages/uniwind/package.json:(using the same path as
exports["."].react-native)Optionally put
"react-native"before"style"in the"."exports map so Expo's key-order matching prefers the native entry.Happy to send a PR if that's useful.