Skip to content
Source
Sign inSign up
TanStack/ai

@tanstack/ai packages cannot be resolved by Metro bundler due to ESM-only exports #308

ClosedGoestaHuppenbauer(GitHub profile, opens in a new tab) opened this issue 1 comment

TanStack AI version

0.5.1

Framework/Library version

Expo SDK 52, Metro bundler, React Native

Describe the bug and the steps to reproduce it

All @tanstack/ai packages use ESM-only exports (only import condition in exports map). Metro bundler in React Native/Expo cannot resolve them, including subpath exports like ./adapters. This affects both client-side bundling and API route bundling even with unstable_enablePackageExports: true and unstable_conditionNames configured.

Cannot resolve @tanstack/ai/adapters

Workaround: Manually add default condition to all exports in node_modules/@tanstack/ai/package.json:

json"./adapters": {
  "types": "./dist/esm/activities/index.d.ts",
  "default": "./dist/esm/activities/index.js",
  "import": "./dist/esm/activities/index.js"
}

Fix required: Add require or default condition to all package exports.

Snack

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

Yes, I think I know how to fix it and will discuss it in the comments of this issue

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. we have an example app using metro + expo on latest main, use it as a reference and see if this is still an issue, i managed to create a working expo app without cjs! if i'm wrong please lmk and feel free to re-open

  2. AlemTuzlak closed this

Sign in to join this conversation.