You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
App Router crash: reactfire 4.2.4/4.2.5 throw "dynamic usage of require is not supported" on the client #759
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.
Activity
test: pin release gate behavior, fix two detection gaps
fix: close five gaps in the release gate found in review
feat: add an entry-point load test (#765 item 3)
ci: verify the packed package with publint, attw and size-limit
ci: verify the packed package with publint, attw and size-limit
ci: drop the entry-point load check, keep publint and attw