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
reflex export fails with rx.code_block due to ESM/CJS interop in react-syntax-highlighter #6054
Describe the bug
After upgrading to Reflex 0.8.23, using rx.code_block causes reflex export to fail due to an ESM/CJS interop error originating from react-syntax-highlighter.
This issue does not occur in development mode and only reproduces during the export (production build) step.
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/refractor/lib/core.js
from .../node_modules/react-syntax-highlighter/dist/cjs/prism-light.js not supported.
at Object.<anonymous> (.../node_modules/react-syntax-highlighter/dist/cjs/prism-light.js:9:13)
...
error: script "export" exited with code 1
It seems to be patch-version dependent, which likely explains why it doesn’t reproduce consistently.
On my side:
It works on Node 24.12.0 and Node 22.21.1
It fails on Node 22.11.0 and Node 21.7.3
The failure only occurs during reflex export, not in development mode
From the logs, the difference comes from SSR externalization during the export build. In the failing cases, react-syntax-highlighter is externalized and ends up being resolved by the Node SSR runtime, which then hits a CJS → ESM interop issue (refractor).
The purpose of this PR is to avoid delegating this resolution to the Node SSR runtime during export builds and let the bundler handle the ESM/CJS interop consistently. That’s why the proposed change limits ssr.noExternal to the build step only.
I’m happy to share debug logs or more environment details if that would be helpful.
Activity
fix: avoid ERR_REQUIRE_ESM during reflex export with rx.code_block
adhami3310 commentedon Dec 19, 2025
i cannot reproduce this :/ not sure what i specifically have that's different
daeunnniii commentedon Dec 22, 2025
Thanks for checking.
It seems to be patch-version dependent, which likely explains why it doesn’t reproduce consistently.
On my side:
reflex export, not in development modeFrom the logs, the difference comes from SSR externalization during the export build. In the failing cases,
react-syntax-highlighteris externalized and ends up being resolved by the Node SSR runtime, which then hits a CJS → ESM interop issue (refractor).The purpose of this PR is to avoid delegating this resolution to the Node SSR runtime during export builds and let the bundler handle the ESM/CJS interop consistently. That’s why the proposed change limits
ssr.noExternalto the build step only.I’m happy to share debug logs or more environment details if that would be helpful.
masenf commentedon May 22, 2026
Minimum node version supported by reflex is bumped to 22.12.0 to avoid this issue entirely.
Confirmed bug is not present in 22.12.0 23.0.0 and 24.0.0