[GH-ISSUE #8268] [BUG] @better-auth/expo: createRequire(import.meta.url) breaks Hermes (React Native) #28361

Closed
opened 2026-04-17 19:47:17 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @marcospgp on GitHub (Mar 1, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8268

Description

@better-auth/expo@1.5.0 ships a rolldown build artifact in dist/client.mjs that uses createRequire(import.meta.url). Hermes (React Native's JavaScript engine) does not support import.meta, causing a build-time error:

SyntaxError: `import.meta` is not supported in Hermes.

Reproduction

  1. Install @better-auth/expo@1.5.0 in an Expo SDK 55 project
  2. Import expoClient from @better-auth/expo/client
  3. Run Metro bundler for iOS
  4. Build fails at dist/client.mjs line 10: var __require = /* @__PURE__ */ createRequire(import.meta.url)

Root Cause

Rolldown's CJS interop injects createRequire(import.meta.url) as a runtime helper. This is a Node.js-only API — it doesn't exist in Hermes, browser, or other non-Node runtimes.

The __require variable is only used once (line 256) as a fallback for dynamically loading expo-web-browser after await import() fails. Since expo-web-browser is a standard Expo dependency, the dynamic import always succeeds in React Native — making the createRequire path dead code in this context.

This is the same root cause as #6690 and #6665 (Cloudflare Workers), which were closed with environment-specific workarounds rather than a build-level fix. Hermes is another non-Node runtime affected by the same pattern.

Workaround

Patching dist/client.mjs to remove the createRequire import, the rolldown runtime block, and the __require fallback resolves the issue without affecting functionality.

Environment

  • @better-auth/expo: 1.5.0
  • better-auth: 1.5.0
  • Expo SDK: 55
  • React Native: 0.83.2
  • Hermes: enabled (default)
Originally created by @marcospgp on GitHub (Mar 1, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8268 ## Description `@better-auth/expo@1.5.0` ships a rolldown build artifact in `dist/client.mjs` that uses `createRequire(import.meta.url)`. Hermes (React Native's JavaScript engine) does not support `import.meta`, causing a build-time error: ``` SyntaxError: `import.meta` is not supported in Hermes. ``` ## Reproduction 1. Install `@better-auth/expo@1.5.0` in an Expo SDK 55 project 2. Import `expoClient` from `@better-auth/expo/client` 3. Run Metro bundler for iOS 4. Build fails at `dist/client.mjs` line 10: `var __require = /* @__PURE__ */ createRequire(import.meta.url)` ## Root Cause Rolldown's CJS interop injects `createRequire(import.meta.url)` as a runtime helper. This is a Node.js-only API — it doesn't exist in Hermes, browser, or other non-Node runtimes. The `__require` variable is only used once (line 256) as a fallback for dynamically loading `expo-web-browser` after `await import()` fails. Since `expo-web-browser` is a standard Expo dependency, the dynamic import always succeeds in React Native — making the `createRequire` path dead code in this context. ## Related Issues This is the same root cause as #6690 and #6665 (Cloudflare Workers), which were closed with environment-specific workarounds rather than a build-level fix. Hermes is another non-Node runtime affected by the same pattern. ## Workaround Patching `dist/client.mjs` to remove the `createRequire` import, the rolldown runtime block, and the `__require` fallback resolves the issue without affecting functionality. ## Environment - `@better-auth/expo`: 1.5.0 - `better-auth`: 1.5.0 - Expo SDK: 55 - React Native: 0.83.2 - Hermes: enabled (default)
GiteaMirror added the lockedbug labels 2026-04-17 19:47:18 -05:00
Author
Owner

@YasserMountij commented on GitHub (Mar 1, 2026):

Same issue :

Android Bundling failed 4062ms node_modules\expo-router\entry.js (2706 modules)  
 ERROR  SyntaxError: C:\Users\Me\Desktop\Project\mobile\node_modules\@better-auth\expo\dist\client.mjs: `import.meta` is not supported in Hermes. Enable the polyfill `unstable_transformImportMeta` in babel-preset-expo to use this syntax.
   8 |
   9 | //#region \0rolldown/runtime.js
> 10 | var __require = /* @__PURE__ */ createRequire(import.meta.url);
     |                                               ^^^^^^^^^^^
<!-- gh-comment-id:3981042696 --> @YasserMountij commented on GitHub (Mar 1, 2026): Same issue : ``` Android Bundling failed 4062ms node_modules\expo-router\entry.js (2706 modules) ERROR SyntaxError: C:\Users\Me\Desktop\Project\mobile\node_modules\@better-auth\expo\dist\client.mjs: `import.meta` is not supported in Hermes. Enable the polyfill `unstable_transformImportMeta` in babel-preset-expo to use this syntax. 8 | 9 | //#region \0rolldown/runtime.js > 10 | var __require = /* @__PURE__ */ createRequire(import.meta.url); | ^^^^^^^^^^^ ```
Author
Owner

@himself65 commented on GitHub (Mar 2, 2026):

Please try 1.5.1-beta

<!-- gh-comment-id:3981716837 --> @himself65 commented on GitHub (Mar 2, 2026): Please try 1.5.1-beta
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28361