Summary
Reactfire 4.2.4 and 4.2.5 (current latest) crash on the client in Next.js App Router apps that render a data hook (e.g. useFirestoreDocData). use-sync-external-store/shim (a CJS module) is bundled into our ESM dist, which makes the bundler emit a dynamic require(). In a strict-ESM browser context it throws at module evaluation of the reactfire chunk:
Error: dynamic usage of require is not supported
Any App Router page that loads a reactfire data-hook chunk breaks on the client. Server prerender is unaffected (Node has require).
Affected versions
- 4.2.4, 4.2.5: affected (ship the bundled shim with the dynamic
require).
- 4.2.3: clean (predates the current build toolchain; ESM dist imports
react directly, no require).
Reproduction
- Next.js App Router app on reactfire 4.2.5.
- Render a client component using a data hook, e.g.
useFirestoreDocData.
- Load the page: the browser console throws
Error: dynamic usage of require is not supported at module evaluation.
Root cause
The build-tooling migration (around 4.2.4) began bundling the CJS use-sync-external-store/shim into the ESM output, producing a runtime require() that does not exist in strict ESM.
Fix
Externalize use-sync-external-store/shim so the consumer's bundler resolves it (it is already a runtime dependency). Non-breaking; the shim's React 16/17 fallback is preserved. Fix PR incoming.
Summary
Reactfire 4.2.4 and 4.2.5 (current
latest) crash on the client in Next.js App Router apps that render a data hook (e.g.useFirestoreDocData).use-sync-external-store/shim(a CJS module) is bundled into our ESMdist, which makes the bundler emit a dynamicrequire(). In a strict-ESM browser context it throws at module evaluation of the reactfire chunk:Any App Router page that loads a reactfire data-hook chunk breaks on the client. Server prerender is unaffected (Node has
require).Affected versions
require).reactdirectly, norequire).Reproduction
useFirestoreDocData.Error: dynamic usage of require is not supportedat module evaluation.Root cause
The build-tooling migration (around 4.2.4) began bundling the CJS
use-sync-external-store/shiminto the ESM output, producing a runtimerequire()that does not exist in strict ESM.Fix
Externalize
use-sync-external-store/shimso the consumer's bundler resolves it (it is already a runtime dependency). Non-breaking; the shim's React 16/17 fallback is preserved. Fix PR incoming.