mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1079] [MERGED] refactor(entries): drop dead locale helpers and dedupe path normalization #1076
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1076
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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:
main← Head:refactor/cleanup-entry-templates📝 Commits (1)
dfb9ec1refactor(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.tsPR #1069 flagged
parseCookieLocaleFromHeader(already gone — likely removed in #1058),extractLocale, anddetectLocaleFromHeadersas 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 usesresolvePagesI18nRequestfromserver/pages-i18n.tsinstead. Deleted both. (detectLocaleFromHeadersdoes still exist as an unrelated exported function inserver/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 generatedimportstatements — was duplicated 12 times across the entry files. Added a sharednormalizePathSeparators(p)helper next to the existingresolveEntryPathinentries/runtime-entry-module.tsand used it everywhere.resolveEntryPathitself now also delegates to it. Only outer-level (build-time) occurrences were replaced; the in-templatepathname.replace(/\\/$/, "")inside generated code (which runs in a different context) was left alone.Files changed
packages/vinext/src/entries/runtime-entry-module.ts— addednormalizePathSeparatorsexport,resolveEntryPathreuses itpackages/vinext/src/entries/pages-server-entry.ts— deleted deadextractLocale+detectLocaleFromHeaders; replaced 7 path-normalize callspackages/vinext/src/entries/pages-client-entry.ts— replaced 2 path-normalize callspackages/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 callPure 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 passpnpm knip— cleanpnpm fmt --writeon touched files🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.