refactor: extract generateSsrEntry and generateBrowserEntry into entries/#377
Merged
james-elicx merged 1 commit intomainfrom Mar 9, 2026
Merged
Conversation
…ies/ Moves generateSsrEntry (app-ssr-entry.ts) and generateBrowserEntry (app-browser-entry.ts) out of the 3,215-line app-dev-server.ts into a new entries/ directory, as described in issue #253. app-dev-server.ts re-exports both functions so all existing import sites (including entry-templates.test.ts) continue to work without changes. All 10 entry-template snapshot tests pass unchanged — generated output is byte-for-byte identical to before the move.
commit: |
|
Collaborator
Author
|
/bigbonk review |
Contributor
There was a problem hiding this comment.
Clean extraction. I verified the following:
Correctness of the move:
- Diffed the removed function bodies from
app-dev-server.tsagainst the new files line-by-line. The template string contents are byte-identical. The only differences are the function declaration + JSDoc wrappers, which are now in the new files as expected.
Re-export correctness:
app-dev-server.ts:2428-2429re-exports bothgenerateSsrEntryandgenerateBrowserEntry.index.tsimports both from./server/app-dev-server.js(unchanged). The chain works — all existing import sites resolve without changes.
No closure dependencies:
- Both functions are self-contained string-returning generators with no parameters and no references to module-level variables from
app-dev-server.ts. The extraction is safe.
Tests:
- All 10
entry-templates.test.tstests pass (snapshot comparisons of the generated code). - All 209
app-router.test.tstests pass, including the tests at lines 2678-2799 that specifically importgenerateSsrEntry/generateBrowserEntryfromapp-dev-server.jsand inspect their output. - Typecheck passes clean.
No dev/prod parity concerns:
- These functions generate virtual module source code (template strings). They don't contain request handling logic. The prod server and worker entry are unaffected.
Looks good.
Contributor
|
Reviewed and approved PR #377. Here's the summary: Verdict: Approved The extraction is a clean code move with no behavioral changes:
|
james-elicx
added a commit
that referenced
this pull request
Mar 9, 2026
…ntEntry into entries/ Move the three remaining large code generators out of app-dev-server.ts and index.ts into dedicated modules under src/entries/, matching the pattern established by PR #377 for generateSsrEntry and generateBrowserEntry. - entries/app-rsc-entry.ts — generateRscEntry() (~2400 lines) - entries/pages-server-entry.ts — generateServerEntry() (~985 lines) - entries/pages-client-entry.ts — generateClientEntry() (~85 lines) - entries/pages-entry-helpers.ts — shared findFileWithExts() helper app-dev-server.ts and index.ts become thin re-export/delegation wrappers. All 10 entry-template snapshot tests pass unchanged.
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
generateSsrEntryandgenerateBrowserEntryfromserver/app-dev-server.tsinto new dedicated modules underpackages/vinext/src/entries/app-dev-server.tsre-exports them from the new locations, keeping the public API identicalMotivation
Part of the refactor tracked in #253.
app-dev-server.tsis ~3200 lines; moving the two self-contained entry generators (no parameters, no closure dependencies) intoentries/is the cleanest first step.Changes
packages/vinext/src/entries/app-ssr-entry.tsgenerateSsrEntry()packages/vinext/src/entries/app-browser-entry.tsgenerateBrowserEntry()packages/vinext/src/server/app-dev-server.tsFollow-ups (not in this PR)
generateRscEntry(~1860 lines) →entries/app-rsc-entry.tsgenerateServerEntry/generateClientEntryfromindex.ts