[PR #259] [CLOSED] refactor: extract template string code generation into entries/ modules #424

Closed
opened 2026-05-06 12:39:44 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/259
Author: @yunus25jmi1
Created: 3/5/2026
Status: Closed

Base: mainHead: refactor/extract-entry-templates


📝 Commits (1)

  • a75a261 refactor: extract template string code generation into entries/ modules

📊 Changes

9 files changed (+14510 additions, -4324 deletions)

View changed files

packages/vinext/src/entries/app-browser-entry.ts (+326 -0)
packages/vinext/src/entries/app-rsc-entry.ts (+2501 -0)
packages/vinext/src/entries/app-ssr-entry.ts (+448 -0)
packages/vinext/src/entries/pages-client-entry.ts (+120 -0)
packages/vinext/src/entries/pages-server-entry.ts (+989 -0)
📝 packages/vinext/src/index.ts (+6 -1062)
📝 packages/vinext/src/server/app-dev-server.ts (+9 -3262)
tests/__snapshots__/entry-templates.test.ts.snap (+9935 -0)
tests/entry-templates.test.ts (+176 -0)

📄 Description

Summary

Extract the 5 template string code generation functions from \index.ts\ and \pp-dev-server.ts\ into dedicated modules under \packages/vinext/src/entries/.

Changes

New files (\packages/vinext/src/entries/)

File Function Lines
\pp-rsc-entry.ts\ \generateRscEntry()\ + \AppRouterConfig\ 2135
\pp-ssr-entry.ts\ \generateSsrEntry()\ 410
\pp-browser-entry.ts\ \generateBrowserEntry()\ 284
\pages-server-entry.ts\ \generateServerEntry()\ 857
\pages-client-entry.ts\ \generateClientEntry()\ 87

Modified files

  • **\pp-dev-server.ts**: Replaced 3034 lines with a 12-line re-export barrel (maintains backward API compatibility)
  • **\index.ts**: Removed ~1238 lines of inline generators; imports from \ntries/\ modules; call sites pass explicit params instead of relying on closure variables

Pages Router closure conversion

\generateServerEntry\ and \generateClientEntry\ were closures inside \ inext()\ that captured \pagesDir,
extConfig, and \middlewarePath. Converted to explicit function parameters.

Tests

  • **\ ests/entry-templates.test.ts**: 9 snapshot tests covering all 5 generators + the re-export barrel

Verification

  • Typecheck: pass
  • Lint: pass
  • Vitest: all tests pass (6 pre-existing failures unrelated to this change)

Closes #253


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/259 **Author:** [@yunus25jmi1](https://github.com/yunus25jmi1) **Created:** 3/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `refactor/extract-entry-templates` --- ### 📝 Commits (1) - [`a75a261`](https://github.com/cloudflare/vinext/commit/a75a2616eded8efa598072507a9a1e34c7372995) refactor: extract template string code generation into entries/ modules ### 📊 Changes **9 files changed** (+14510 additions, -4324 deletions) <details> <summary>View changed files</summary> ➕ `packages/vinext/src/entries/app-browser-entry.ts` (+326 -0) ➕ `packages/vinext/src/entries/app-rsc-entry.ts` (+2501 -0) ➕ `packages/vinext/src/entries/app-ssr-entry.ts` (+448 -0) ➕ `packages/vinext/src/entries/pages-client-entry.ts` (+120 -0) ➕ `packages/vinext/src/entries/pages-server-entry.ts` (+989 -0) 📝 `packages/vinext/src/index.ts` (+6 -1062) 📝 `packages/vinext/src/server/app-dev-server.ts` (+9 -3262) ➕ `tests/__snapshots__/entry-templates.test.ts.snap` (+9935 -0) ➕ `tests/entry-templates.test.ts` (+176 -0) </details> ### 📄 Description ## Summary Extract the 5 template string code generation functions from \index.ts\ and \pp-dev-server.ts\ into dedicated modules under \packages/vinext/src/entries/\. ## Changes ### New files (\packages/vinext/src/entries/\) | File | Function | Lines | |------|----------|-------| | \pp-rsc-entry.ts\ | \generateRscEntry()\ + \AppRouterConfig\ | 2135 | | \pp-ssr-entry.ts\ | \generateSsrEntry()\ | 410 | | \pp-browser-entry.ts\ | \generateBrowserEntry()\ | 284 | | \pages-server-entry.ts\ | \generateServerEntry()\ | 857 | | \pages-client-entry.ts\ | \generateClientEntry()\ | 87 | ### Modified files - **\pp-dev-server.ts\**: Replaced 3034 lines with a 12-line re-export barrel (maintains backward API compatibility) - **\index.ts\**: Removed ~1238 lines of inline generators; imports from \ntries/\ modules; call sites pass explicit params instead of relying on closure variables ### Pages Router closure conversion \generateServerEntry\ and \generateClientEntry\ were closures inside \ inext()\ that captured \pagesDir\, \ extConfig\, and \middlewarePath\. Converted to explicit function parameters. ### Tests - **\ ests/entry-templates.test.ts\**: 9 snapshot tests covering all 5 generators + the re-export barrel ### Verification - Typecheck: pass - Lint: pass - Vitest: all tests pass (6 pre-existing failures unrelated to this change) Closes #253 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39:44 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#424
No description provided.