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
Can't use optional dynamic import with Cloudflare presets #3903
Running build with any Cloudflare preset and a dynamic import, such as:
try{awaitimport('doesnt-exist');}catch{console.log('this is fine');}
Errors saying it can't resolve doesnt-exist.
Generally bundlers have a proper handling for dynamic imports with try-catches around them, and normally Nitro does indeed handle those properly from what I've seen, but when using the Cloudflare presets it doesn't seem to work.
Additional context
This is originally an issue in compatibility with Resend's Node SDK resend/resend-node#772.
Logs
> nitro build
✔ Generated public .output/public nitro 9:15:40 AM
ℹ Building Nitro Server (preset: cloudflare-module, compatibility date: 2025-02-23) nitro 9:15:41 AM
[nitro 9:15:42 AM] ERROR Error: Cannot resolve "@react-email/render" from "/home/projects/vbwijkajko.github/server/routes/index.ts" and externals are not allowed!
undefined
[9:15:42 AM] ERROR Cannot resolve "@react-email/render" from "/server/routes/index.ts" and externals are not allowed!
at Object.resolveId (node_modules/nitropack/dist/rollup/index.mjs:2026:17)
[9:15:42 AM] ERROR Cannot resolve "@react-email/render" from "/server/routes/index.ts" and externals are not allowed!
Fixed in v3 — a try/catch dynamic import of a missing module builds fine with the cloudflare-module preset now that externals handling was overhauled (#3799), and the import is left as-is in the output.
Activity
coderabbitai commentedon Dec 29, 2025
🔗 Similar Issues
Related Issues
emitFile({ type: 'asset' })#3577🔗 Related PRs
#3799 - refactor!: overhaul externals support [merged]
#3834 - feat(cloudflare): support
exports.cloudflare.ts[merged]#3854 - refactor(vite): keep SSR bundle external dependencies [merged]
#3877 - refactor: improve vfs [merged]
#3886 - fix: use
modulecondition and main fields for bundling [merged]👤 Suggested Assignees
Enable issue planning
To enable issue planning, add the following to your
.coderabbit.yaml:You can then request a plan by commenting
@coderabbitai planon any issue.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
serhii-chernenko commentedon Feb 2, 2026
had the same. as a temp solution:
gabrielmfern commentedon Feb 2, 2026
@serhii-chernenko Where did you add that to? Your project?
Changing the version of
@react-email/renderfixed it for you?serhii-chernenko commentedon Feb 2, 2026
@gabrielmfern not changing version. just added to
peerDependenciesinpackage.json.I'm upgrading packages right now in my repo:
https://github.com/besidka/besidka/commits/main/
It's not pushed yet but will do soon
pi0x commentedon Sep 7, 2026
Fixed in v3 — a try/catch dynamic import of a missing module builds fine with the cloudflare-module preset now that externals handling was overhauled (#3799), and the import is left as-is in the output.
Triaged with AI assistance.