Skip to content

Conversation

@mdkulkarni2005
Copy link

Background

React Native builds fail because Metro attempts to statically resolve @vercel/oidc, which is not compatible with Metro's module resolution.

Since @vercel/oidc does not expose a main field that Metro understands, the bundler crashes with a module resolution error.

Summary

This PR replaces the static import of @vercel/oidc with a guarded dynamic import inside vercel-environment.ts.

  • Uses lazy import() to prevent Metro from resolving the module at build time
  • Gracefully falls back when @vercel/oidc is unavailable
  • Adds safe error handling to avoid swallowing unrelated runtime errors

Manual Verification

  • Built @ai-sdk/gateway successfully (ESM, CJS, DTS)
  • Installed the packed gateway into a minimal Expo (React Native) project
  • Verified that Metro no longer crashes during bundling
  • Confirmed no breaking behavior in Node/Vercel environments

Closes #12313.

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.

AI SDK v6 Compatibility Issues with React Native and @vercel/oidc Package

1 participant