Description
After running opennextjs-cloudflare build (v1.20.2) with Next.js 15.5.22 and NODE_ENV=production, the resulting Worker bundle at .open-next/server-functions/default/handler.mjs contains ~2.4 MB of development-only artifacts that appear to be dead weight in production.
Artifacts found in production bundle
| Path |
Raw Size |
Notes |
next-devtools/index.js |
822 KB |
Dev tooling — should not be in prod |
react-dom-server.edge.development.js |
425 KB |
.development.js variant |
react-dom-server.browser.development.js |
424 KB |
.development.js variant |
react-dom-server-legacy.browser.development.js |
395 KB |
.development.js variant |
react.development.js |
present |
.development.js variant |
react-jsx-runtime.development.js |
present |
.development.js variant |
Total dev-only weight: ~2.4 MB raw
Impact
- Bundle is at ~85% of Workers' 3 MB compressed ceiling (2.5 MB gzipped of the 3 MB limit on the paid plan). These artifacts consume most of the remaining headroom.
- Cold-start amplification — every byte of the bundle is parsed on isolate cold start. Removing ~2.4 MB of dead code would measurably reduce cold-start latency.
- No production code path executes these files — verified by grepping the handler for references. They appear to be bundled defensively or included by the build pipeline without a production/development gate.
Reproduction
npx @opennextjs/cloudflare build # NODE_ENV=production (the default)
# Inspect the output:
find .open-next/server-functions/default -name "*.development.*" -o -name "next-devtools" | head -20
ls -lh .open-next/server-functions/default/node_modules/next-devtools/
du -sh .open-next/server-functions/default/handler.mjs
gzip -c .open-next/server-functions/default/handler.mjs | wc -c
Question
Is this intentional (some runtime code path conditionally loads these), or is it a bundling oversight that could be gated on NODE_ENV? Is there a configuration flag to exclude them?
Environment
@opennextjs/cloudflare: 1.20.2
next: 15.5.22
- Node: 22.x
- OS: Linux (WSL2)
- Cloudflare Workers paid plan
Description
After running
opennextjs-cloudflare build(v1.20.2) with Next.js 15.5.22 andNODE_ENV=production, the resulting Worker bundle at.open-next/server-functions/default/handler.mjscontains ~2.4 MB of development-only artifacts that appear to be dead weight in production.Artifacts found in production bundle
next-devtools/index.jsreact-dom-server.edge.development.js.development.jsvariantreact-dom-server.browser.development.js.development.jsvariantreact-dom-server-legacy.browser.development.js.development.jsvariantreact.development.js.development.jsvariantreact-jsx-runtime.development.js.development.jsvariantTotal dev-only weight: ~2.4 MB raw
Impact
Reproduction
Question
Is this intentional (some runtime code path conditionally loads these), or is it a bundling oversight that could be gated on
NODE_ENV? Is there a configuration flag to exclude them?Environment
@opennextjs/cloudflare: 1.20.2next: 15.5.22