[PR #1079] [MERGED] refactor(entries): drop dead locale helpers and dedupe path normalization #1076

Closed
opened 2026-05-06 13:11:52 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/1079
Author: @james-elicx
Created: 5/5/2026
Status: Merged
Merged: 5/5/2026
Merged by: @james-elicx

Base: mainHead: refactor/cleanup-entry-templates


📝 Commits (1)

  • dfb9ec1 refactor(entries): drop dead locale helpers and dedupe path normalization

📊 Changes

5 files changed (+31 additions, -54 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+3 -3)
📝 packages/vinext/src/entries/app-rsc-manifest.ts (+2 -1)
📝 packages/vinext/src/entries/pages-client-entry.ts (+3 -2)
📝 packages/vinext/src/entries/pages-server-entry.ts (+8 -45)
📝 packages/vinext/src/entries/runtime-entry-module.ts (+15 -3)

📄 Description

Summary

Two small cleanups in the codegen-template entry files. Follow-up to #1058 and #1069.

Drop dead locale helpers in pages-server-entry.ts

PR #1069 flagged parseCookieLocaleFromHeader (already gone — likely removed in #1058), extractLocale, and detectLocaleFromHeaders as suspected dead code in the generated Pages Router server entry. Verified across the entire repo (sources, tests, fixtures, generated template strings) that the two remaining helpers (extractLocale, detectLocaleFromHeaders) had no callers — the entry uses resolvePagesI18nRequest from server/pages-i18n.ts instead. Deleted both. (detectLocaleFromHeaders does still exist as an unrelated exported function in server/dev-server.ts, with its own tests — that one is untouched.)

Dedupe path-separator normalization

The path.replace(/\\/g, "/") idiom — used to convert Windows-style backslash separators when embedding absolute paths into generated import statements — was duplicated 12 times across the entry files. Added a shared normalizePathSeparators(p) helper next to the existing resolveEntryPath in entries/runtime-entry-module.ts and used it everywhere. resolveEntryPath itself now also delegates to it. Only outer-level (build-time) occurrences were replaced; the in-template pathname.replace(/\\/$/, "") inside generated code (which runs in a different context) was left alone.

Files changed

  • packages/vinext/src/entries/runtime-entry-module.ts — added normalizePathSeparators export, resolveEntryPath reuses it
  • packages/vinext/src/entries/pages-server-entry.ts — deleted dead extractLocale + detectLocaleFromHeaders; replaced 7 path-normalize calls
  • packages/vinext/src/entries/pages-client-entry.ts — replaced 2 path-normalize calls
  • packages/vinext/src/entries/app-rsc-entry.ts — replaced 2 path-normalize calls (inside the outer return-template's ${...} interpolations, which evaluate at build time)
  • packages/vinext/src/entries/app-rsc-manifest.ts — replaced 1 path-normalize call

Pure refactor + dead-code removal, no behavior change.

Test plan

  • pnpm vp test run tests/app-router.test.ts tests/pages-router.test.ts — all 700 tests pass
  • pnpm knip — clean
  • pnpm fmt --write on touched files

🔄 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/1079 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 5/5/2026 **Status:** ✅ Merged **Merged:** 5/5/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `refactor/cleanup-entry-templates` --- ### 📝 Commits (1) - [`dfb9ec1`](https://github.com/cloudflare/vinext/commit/dfb9ec141881eae6fe39d7c78242d02392ed5cc1) refactor(entries): drop dead locale helpers and dedupe path normalization ### 📊 Changes **5 files changed** (+31 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+3 -3) 📝 `packages/vinext/src/entries/app-rsc-manifest.ts` (+2 -1) 📝 `packages/vinext/src/entries/pages-client-entry.ts` (+3 -2) 📝 `packages/vinext/src/entries/pages-server-entry.ts` (+8 -45) 📝 `packages/vinext/src/entries/runtime-entry-module.ts` (+15 -3) </details> ### 📄 Description ## Summary Two small cleanups in the codegen-template entry files. Follow-up to #1058 and #1069. ### Drop dead locale helpers in `pages-server-entry.ts` PR #1069 flagged `parseCookieLocaleFromHeader` (already gone — likely removed in #1058), `extractLocale`, and `detectLocaleFromHeaders` as suspected dead code in the generated Pages Router server entry. Verified across the entire repo (sources, tests, fixtures, generated template strings) that the two remaining helpers (`extractLocale`, `detectLocaleFromHeaders`) had no callers — the entry uses `resolvePagesI18nRequest` from `server/pages-i18n.ts` instead. Deleted both. (`detectLocaleFromHeaders` does still exist as an unrelated *exported* function in `server/dev-server.ts`, with its own tests — that one is untouched.) ### Dedupe path-separator normalization The `path.replace(/\\/g, "/")` idiom — used to convert Windows-style backslash separators when embedding absolute paths into generated `import` statements — was duplicated 12 times across the entry files. Added a shared `normalizePathSeparators(p)` helper next to the existing `resolveEntryPath` in `entries/runtime-entry-module.ts` and used it everywhere. `resolveEntryPath` itself now also delegates to it. Only outer-level (build-time) occurrences were replaced; the in-template `pathname.replace(/\\/$/, "")` inside generated code (which runs in a different context) was left alone. ## Files changed - `packages/vinext/src/entries/runtime-entry-module.ts` — added `normalizePathSeparators` export, `resolveEntryPath` reuses it - `packages/vinext/src/entries/pages-server-entry.ts` — deleted dead `extractLocale` + `detectLocaleFromHeaders`; replaced 7 path-normalize calls - `packages/vinext/src/entries/pages-client-entry.ts` — replaced 2 path-normalize calls - `packages/vinext/src/entries/app-rsc-entry.ts` — replaced 2 path-normalize calls (inside the outer return-template's `${...}` interpolations, which evaluate at build time) - `packages/vinext/src/entries/app-rsc-manifest.ts` — replaced 1 path-normalize call Pure refactor + dead-code removal, no behavior change. ## Test plan - [x] `pnpm vp test run tests/app-router.test.ts tests/pages-router.test.ts` — all 700 tests pass - [x] `pnpm knip` — clean - [x] `pnpm fmt --write` on touched files --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:52 +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#1076
No description provided.