fix(ssr): ignore runtime renderer import in Vite#2288
Merged
Conversation
commit: |
Contributor
|
Contributor
Performance benchmarksCompared 1 improved · 0 regressed · 5 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
Member
Author
|
/bigbonk review for issues |
Contributor
There was a problem hiding this comment.
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()buildsdevRendererPathat runtime viapath.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 theimport()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.tsdon't replicate it, so there's nothing else to keep in sync. vp checkpasses on the modified file (format, lint, types all clean).- Build claim confirmed. Ran
vp run vinext#buildand the directive is preserved indist/server/app-ssr-entry.jsimmediately inside theimport(), 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.
Contributor
|
Review posted to PR #2288. SummaryPR #2288 makes a one-line change: adding Verdict: LGTM ✅ — no issues found. What I verified:
Safe to merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@vite-ignoreWhy
loadStaticPrerender()resolves React's internal development renderer from the installedreact-dompackage 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.tsvp run vinext#buildpackages/vinext/dist/server/app-ssr-entry.jspreserves the/* @vite-ignore */directive immediately insideimport()