[PR #591] [MERGED] fix: respect pageExtensions in prerender and exclude _ prefixed api files #693

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

📋 Pull Request Information

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

Base: mainHead: fix/page-extensions-routing-parity


📝 Commits (4)

  • 7f46900 fix: respect pageExtensions in prerender and exclude _ prefixed api files
  • da203cd PR #591 reviewed: 1 bug found, rest LGTM
  • 0657cf5 remove files
  • 7c668a8 fix: pass pageExtensions to appRouter in prerender; harden afterEach cache cleanup

📊 Changes

6 files changed (+184 additions, -11 deletions)

View changed files

📝 packages/vinext/src/build/report.ts (+1 -1)
📝 packages/vinext/src/build/run-prerender.ts (+3 -3)
📝 packages/vinext/src/cli.ts (+8 -5)
📝 packages/vinext/src/routing/pages-router.ts (+6 -1)
📝 tests/build-report.test.ts (+142 -1)
📝 tests/page-extensions-routing.test.ts (+24 -0)

📄 Description

Summary

  • run-prerender.ts: pagesRouter/apiRouter were called without pageExtensions, so the prerender phase always scanned with default extensions (tsx,ts,jsx,js) regardless of next.config.js. Now passes config.pageExtensions.
  • cli.ts: Hoisted resolveNextConfig so nextConfig.pageExtensions is forwarded to printBuildReport (previously the result was discarded inline).
  • pages-router.ts (scanApiRoutes): Added _-prefix exclude to match Next.js behaviour — pages/api/_helpers.ts was becoming a /api/_helpers route.
  • report.ts: Tightened printBuildReport signature — pageExtensions is now required (not optional), making callers explicit.

Testing

  • New test in tests/page-extensions-routing.test.ts: verifies _-prefixed files in pages/api/ are excluded.
  • Existing tests in tests/build-report.test.ts (added in prior work): verify printBuildReport respects pageExtensions for both App and Pages Router.
  • All 157 affected tests passing locally.

Notes

With default pageExtensions: ["tsx","ts","jsx","js"], a file like home.spec.tsx in pages/ will still become a route — same as Next.js itself. The correct user-side fix for colocation is pageExtensions: ["page.tsx"], which vinext now respects end-to-end.


🔄 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/591 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/19/2026 **Status:** ✅ Merged **Merged:** 3/19/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/page-extensions-routing-parity` --- ### 📝 Commits (4) - [`7f46900`](https://github.com/cloudflare/vinext/commit/7f46900f608586fd8909c2ae811645213e1d7972) fix: respect pageExtensions in prerender and exclude _ prefixed api files - [`da203cd`](https://github.com/cloudflare/vinext/commit/da203cd6001887e0cec73fdf5e0b8f0f688d0c0f) PR #591 reviewed: 1 bug found, rest LGTM - [`0657cf5`](https://github.com/cloudflare/vinext/commit/0657cf582154589e36954ea646817d640d45b791) remove files - [`7c668a8`](https://github.com/cloudflare/vinext/commit/7c668a8e9ecbd5812d7de98e64129f1526176d44) fix: pass pageExtensions to appRouter in prerender; harden afterEach cache cleanup ### 📊 Changes **6 files changed** (+184 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/build/report.ts` (+1 -1) 📝 `packages/vinext/src/build/run-prerender.ts` (+3 -3) 📝 `packages/vinext/src/cli.ts` (+8 -5) 📝 `packages/vinext/src/routing/pages-router.ts` (+6 -1) 📝 `tests/build-report.test.ts` (+142 -1) 📝 `tests/page-extensions-routing.test.ts` (+24 -0) </details> ### 📄 Description ## Summary - **`run-prerender.ts`**: `pagesRouter`/`apiRouter` were called without `pageExtensions`, so the prerender phase always scanned with default extensions (`tsx,ts,jsx,js`) regardless of `next.config.js`. Now passes `config.pageExtensions`. - **`cli.ts`**: Hoisted `resolveNextConfig` so `nextConfig.pageExtensions` is forwarded to `printBuildReport` (previously the result was discarded inline). - **`pages-router.ts` (`scanApiRoutes`)**: Added `_`-prefix exclude to match Next.js behaviour — `pages/api/_helpers.ts` was becoming a `/api/_helpers` route. - **`report.ts`**: Tightened `printBuildReport` signature — `pageExtensions` is now required (not optional), making callers explicit. ## Testing - New test in `tests/page-extensions-routing.test.ts`: verifies `_`-prefixed files in `pages/api/` are excluded. - Existing tests in `tests/build-report.test.ts` (added in prior work): verify `printBuildReport` respects `pageExtensions` for both App and Pages Router. - All 157 affected tests passing locally. ## Notes With **default** `pageExtensions: ["tsx","ts","jsx","js"]`, a file like `home.spec.tsx` in `pages/` will still become a route — same as Next.js itself. The correct user-side fix for colocation is `pageExtensions: ["page.tsx"]`, which vinext now respects end-to-end. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:09:35 +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#693
No description provided.