Metro Bundler Fails to Resolve Subpath Exports from platejs and @platejs/core in React Native/Expo #4458
-
DescriptionMetro bundler (used by Expo/React Native) fails to resolve subpath exports from Reproduction URLhttps://github.com/guillempuche/workspace Reproduction steps1. Clone the repository: `git clone https://github.com/guillempuche/workspace`
2. Install dependencies: `yarn install`
3. Run the Expo web app: `yarn workspace @workspace/apps-expo web`
4. See error: `Unable to resolve "platejs/react" from "apps/expo/src/app/editor.tsx"` Plate version49.0.19 Slate React version0.117.1 Screenshots![]() LogsWeb Bundling failed 6188ms apps/expo/index.ts (1225 modules)
Unable to resolve "platejs/react" from "apps/expo/src/app/editor.tsx"
When trying to import from `@platejs/core/react` after installing it directly:
Web Bundling failed 6328ms apps/expo/index.ts (1225 modules)
Unable to resolve "@platejs/core/react" from "apps/expo/src/app/editor.tsx" BrowsersFirefox |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @guillempuche! I'm Dosu and I’m helping the plate team. Metro (used by Expo/React Native) doesn't support the package.json "exports" field or subpath exports, which is why imports like There isn't official support or a documented workaround for using Plate with Metro/Expo. To work around this, you could try importing directly from the built file paths (like Right now, Metro's lack of support for subpath exports is a fundamental blocker for using Plate in React Native/Expo projects. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
Metro bundler (used by Expo/React Native) doesn't fully support the There’s no official workaround in Plate docs or code for Metro. Some general community workarounds for similar issues include: using patch-package to rewrite imports, copying files manually, or hacking Metro’s resolver, but these are not straightforward and may break with updates. TypeScript config tweaks (like Right now, Plate does not support Metro/Expo out of the box due to this limitation. If you need Plate in React Native/Expo, you’d need to experiment with custom Metro config or manual file copying, but there’s no documented, stable solution yet. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
Adding Previously I had |
Beta Was this translation helpful? Give feedback.
Adding
unstable_enablePackageExports: true
inmetro.config.js
(see Metro Bundler docs) successfully resolves the subpath export issue, allowing theplatejs
and@platejs/core
libraries to load correctly in React Native/Expo applications. Recommendation from @TylorS 🙏.Previously I had
unstable_enablePackageExports: false
because the Tamagui UI library caused problems in the past (tamagui/tamagui#3396 (comment)). I'll test it more to confirm that Tamagui and Plate works together.