-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Environment
better-auth-firestore: 1.1.2better-auth: 1.4.19- Runtime: Node.js (via Vite dev server /
@hono/vite-dev-server) - Module type: ESM (
"type": "module")
Problem
When importing better-auth-firestore in a strict ESM environment (Node.js with "type": "module"), the following error occurs:
Cannot find module '.../better-auth-firestore/dist/firebase-adapter'
imported from .../better-auth-firestore/dist/index.js
Root Cause
dist/index.js uses bare relative imports without .js extensions:
// dist/index.js (current — broken in ESM)
export { firestoreAdapter } from "./firebase-adapter";
export { initFirestore } from "./firestore";
export { generateIndexSetupUrl, getIndexConfig } from "./setup";
export * from "./types";Node.js ESM requires explicit file extensions for relative imports. Without .js, resolution fails.
The same issue exists in dist/firebase-adapter.js:
import { initFirestore } from "./firestore"; // should be "./firestore.js"Fix
Add .js extensions to all relative imports in the dist/ files:
// dist/index.js (fixed)
export { firestoreAdapter } from "./firebase-adapter.js";
export { initFirestore } from "./firestore.js";
export { generateIndexSetupUrl, getIndexConfig } from "./setup.js";
export * from "./types.js";// dist/firebase-adapter.js (fixed)
import { initFirestore } from "./firestore.js";This is typically fixed in the library's tsconfig.json by setting moduleResolution to "node16" or "bundler", which causes TypeScript to emit explicit .js extensions in output files. Alternatively, configure the bundler (tsup, esbuild, etc.) to preserve or add extensions on relative imports.
Workaround
Applied a pnpm patch to add .js extensions manually until this is fixed upstream.