Skip to content

fix(ssr): ignore runtime renderer import in Vite#2288

Merged
james-elicx merged 1 commit into
mainfrom
codex/fix-runtime-renderer-vite-import
Jun 23, 2026
Merged

fix(ssr): ignore runtime renderer import in Vite#2288
james-elicx merged 1 commit into
mainfrom
codex/fix-runtime-renderer-vite-import

Conversation

@james-elicx

Copy link
Copy Markdown
Member

Summary

  • mark the runtime-resolved React development renderer import with @vite-ignore
  • prevent Vite import analysis from warning about a path that intentionally cannot be statically analyzed

Why

loadStaticPrerender() resolves React's internal development renderer from the installed react-dom package at runtime. Vite sees the computed import when consuming vinext's built SSR runtime and reports that it cannot analyze the dynamic import.

Validation

  • vp check packages/vinext/src/server/app-ssr-entry.ts
  • vp run vinext#build
  • confirmed packages/vinext/dist/server/app-ssr-entry.js preserves the /* @vite-ignore */ directive immediately inside import()

@pkg-pr-new

pkg-pr-new Bot commented Jun 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2288
npm i https://pkg.pr.new/vinext@2288

commit: 8148aed

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
workers-cache preview production
web preview production

@github-actions

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 8148aed against base 516107c using alternating same-runner rounds. Next.js was unchanged and skipped.

1 improved · 0 regressed · 5 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 117.2 KB 117.2 KB ⚫ -0.0%
Client entry size (gzip) vinext 112.6 KB 112.6 KB ⚫ -0.0%
Dev server cold start vinext 2.46 s 2.37 s 🟢 -3.8%
Production build time vinext 2.88 s 2.90 s ⚫ +0.9%
RSC entry closure size (gzip) vinext 92.8 KB 92.8 KB ⚫ +0.0%
Server bundle size (gzip) vinext 156.6 KB 156.6 KB ⚫ +0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: fix(ssr): ignore runtime renderer import in Vite

Verdict: LGTM ✅

The change is minimal, correct, and well-targeted.

What I verified

  • The fix is appropriate. loadStaticPrerender() builds devRendererPath at runtime via path.join(reactDomDir, "cjs/react-dom-server.edge.development.js") (app-ssr-entry.ts:127). This specifier is genuinely non-statically-analyzable, so Vite's import-analysis warning is a false positive. /* @vite-ignore */ is Vite's documented mechanism for exactly this case, and it's placed correctly inside the import() call.
  • No other imports need the same treatment. The only other dynamic imports in this file (react-dom/static.edge, node:module, node:path) all use static string literals, so they're already analyzable and correctly left untouched.
  • No dev/prod parity concern. This renderer-loading logic is unique to app-ssr-entry.ts; dev-server.ts / prod-server.ts / worker-entry.ts don't replicate it, so there's nothing else to keep in sync.
  • vp check passes on the modified file (format, lint, types all clean).
  • Build claim confirmed. Ran vp run vinext#build and the directive is preserved in dist/server/app-ssr-entry.js immediately inside the import(), so downstream consumers of the built SSR runtime won't see the warning either.

Notes (non-blocking)

  • This only suppresses the warning; the runtime fallback path itself is unchanged. The fragility of reaching into React's internal CJS layout is already documented in the surrounding comment, so no action needed.

No issues found. Safe to merge.

@ask-bonk

ask-bonk Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review posted to PR #2288.

Summary

PR #2288 makes a one-line change: adding /* @vite-ignore */ to the runtime-computed dynamic import in loadStaticPrerender() (app-ssr-entry.ts:128).

Verdict: LGTM ✅ — no issues found.

What I verified:

  • Correct fix — the import specifier (path.join(reactDomDir, "cjs/react-dom-server.edge.development.js")) is genuinely non-static, so Vite's warning is a false positive; @vite-ignore is the right tool, placed correctly inside import().
  • No missed imports — the other dynamic imports in the file all use static literals and correctly don't need the directive.
  • No parity concern — this renderer-loading logic is unique to app-ssr-entry.ts.
  • vp check passes (format/lint/types clean).
  • Build claim confirmed — ran vp run vinext#build and the @vite-ignore directive is preserved in dist/server/app-ssr-entry.js inside the import(), matching the PR's validation notes.

Safe to merge.

github run

@james-elicx james-elicx merged commit 0d5a9e5 into main Jun 23, 2026
58 checks passed
@james-elicx james-elicx deleted the codex/fix-runtime-renderer-vite-import branch June 23, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant