[1.4.6] Deployments to Cloudflare break after upgrading from v1.4.5 to v1.4.6
I asked Opus 4.5 to create a patch, and this is the summary:
Root Cause
In better-auth v1.4.6, the bundler (rolldown) generates a helper chunk (
chunk-DieNfLhd.mjs) that contains:This chunk is now imported by
get-migration-CDvYpogu.mjs (which wasn't the case in v1.4.5) to get __export and __reExport helpers.The problem is that in Cloudflare Workers, import.meta.url is undefined, causing
createRequire(undefined) to throw:TypeError: The argument 'path' must be a file URL object, a file URL string, or an absolute path string. Received 'undefined'The Fix
Created a patch file patches/better-auth@1.4.6.patch that:
- Adds a fallback for
import.meta.url:var __import_meta_url = typeof import.meta.url === 'string' ? import.meta.url : 'file:///'; - Uses this safe fallback instead of raw
import.meta.url:var __require = createRequire(__import_meta_url);
import.meta.url is undefined, while still working correctly in Node.js environments.