[PR #584] [MERGED] feat: full next/compat/router support and fix vinext check scanner for shimmed modules #686

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

📋 Pull Request Information

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

Base: mainHead: opencode/brave-moon


📝 Commits (6)

  • beffd1a feat: full next/compat/router support and fix check scanner for shimmed modules
  • b8136c5 test: update entry-templates snapshots for compat-router-test fixture page
  • 04311ff remove type assertion
  • acdf82c fix: add declare module for next/compat/router to fixture next-shims.d.ts files
  • fcda8d9 fix: add declare module for next/compat/router to internal next-shims.d.ts
  • 26257f9 pin to vp setup 1.0.0

📊 Changes

16 files changed (+279 additions, -58 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -1)
📝 packages/vinext/src/check.ts (+11 -0)
📝 packages/vinext/src/shims/compat-router.ts (+2 -1)
📝 packages/vinext/src/shims/internal/router-context.ts (+2 -1)
📝 packages/vinext/src/shims/next-shims.d.ts (+6 -0)
📝 packages/vinext/src/shims/router.ts (+1 -1)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+57 -54)
📝 tests/check.test.ts (+36 -0)
tests/fixtures/app-basic/app/components/compat-router-widget.tsx (+27 -0)
tests/fixtures/app-basic/app/nextjs-compat/compat-router/page.tsx (+10 -0)
📝 tests/fixtures/app-basic/next-shims.d.ts (+29 -0)
tests/fixtures/pages-basic/components/compat-router-widget.tsx (+27 -0)
📝 tests/fixtures/pages-basic/next-shims.d.ts (+29 -0)
tests/fixtures/pages-basic/pages/compat-router-test.tsx (+10 -0)
📝 tests/nextjs-compat/hooks.test.ts (+18 -0)
📝 tests/pages-router.test.ts (+13 -0)

📄 Description

Summary

  • Type safety: export NextRouter interface from shims/router.ts; useRouter() in shims/compat-router.ts now has a proper NextRouter | null return type instead of any.
  • vinext check accuracy: add next/compat/router, next/form, next/web-vitals, and next/constants to IMPORT_SUPPORT in check.ts — these were all shimmed and working but incorrectly flagged as unsupported/unrecognized by the scanner.
  • Integration test coverage: add CompatRouterWidget fixture components and pages in both pages-basic and app-basic fixtures, with integration tests in tests/pages-router.test.ts and tests/nextjs-compat/hooks.test.ts.
  • Unit tests: extend tests/check.test.ts with four new assertions covering the newly-registered imports.

Changes

File Change
packages/vinext/src/shims/router.ts Export NextRouter interface
packages/vinext/src/shims/compat-router.ts Add NextRouter | null return type to useRouter()
packages/vinext/src/check.ts Add next/compat/router, next/form, next/web-vitals, next/constants to IMPORT_SUPPORT
tests/check.test.ts 4 new unit tests for the above imports
tests/pages-router.test.ts Integration test: next/compat/router in Pages Router
tests/nextjs-compat/hooks.test.ts Integration test: next/compat/router in App Router
tests/fixtures/*/compat-router-* Fixture components and pages for integration tests

Testing

vp test tests/check.test.ts          # 76 tests, all pass
vp test tests/pages-router.test.ts   # includes new compat/router integration test
vp test tests/nextjs-compat/hooks.test.ts  # includes new App Router compat/router test

🔄 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/584 **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:** `opencode/brave-moon` --- ### 📝 Commits (6) - [`beffd1a`](https://github.com/cloudflare/vinext/commit/beffd1a0105a6c732acf82def4cb5e3a8aac08bf) feat: full next/compat/router support and fix check scanner for shimmed modules - [`b8136c5`](https://github.com/cloudflare/vinext/commit/b8136c5e5b2411411fe013ad538ce37f83c259da) test: update entry-templates snapshots for compat-router-test fixture page - [`04311ff`](https://github.com/cloudflare/vinext/commit/04311ff392577b6781a9c4fd3a79d432866814ba) remove type assertion - [`acdf82c`](https://github.com/cloudflare/vinext/commit/acdf82cd3dddbd42ab2aa3303172b405eefee8e9) fix: add declare module for next/compat/router to fixture next-shims.d.ts files - [`fcda8d9`](https://github.com/cloudflare/vinext/commit/fcda8d931fb4cc6d7ff3d8a41db6995672595864) fix: add declare module for next/compat/router to internal next-shims.d.ts - [`26257f9`](https://github.com/cloudflare/vinext/commit/26257f970db84eb1f2fbe1783ee6739ec8654df9) pin to vp setup 1.0.0 ### 📊 Changes **16 files changed** (+279 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -1) 📝 `packages/vinext/src/check.ts` (+11 -0) 📝 `packages/vinext/src/shims/compat-router.ts` (+2 -1) 📝 `packages/vinext/src/shims/internal/router-context.ts` (+2 -1) 📝 `packages/vinext/src/shims/next-shims.d.ts` (+6 -0) 📝 `packages/vinext/src/shims/router.ts` (+1 -1) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+57 -54) 📝 `tests/check.test.ts` (+36 -0) ➕ `tests/fixtures/app-basic/app/components/compat-router-widget.tsx` (+27 -0) ➕ `tests/fixtures/app-basic/app/nextjs-compat/compat-router/page.tsx` (+10 -0) 📝 `tests/fixtures/app-basic/next-shims.d.ts` (+29 -0) ➕ `tests/fixtures/pages-basic/components/compat-router-widget.tsx` (+27 -0) 📝 `tests/fixtures/pages-basic/next-shims.d.ts` (+29 -0) ➕ `tests/fixtures/pages-basic/pages/compat-router-test.tsx` (+10 -0) 📝 `tests/nextjs-compat/hooks.test.ts` (+18 -0) 📝 `tests/pages-router.test.ts` (+13 -0) </details> ### 📄 Description ## Summary - **Type safety**: export `NextRouter` interface from `shims/router.ts`; `useRouter()` in `shims/compat-router.ts` now has a proper `NextRouter | null` return type instead of `any`. - **`vinext check` accuracy**: add `next/compat/router`, `next/form`, `next/web-vitals`, and `next/constants` to `IMPORT_SUPPORT` in `check.ts` — these were all shimmed and working but incorrectly flagged as unsupported/unrecognized by the scanner. - **Integration test coverage**: add `CompatRouterWidget` fixture components and pages in both `pages-basic` and `app-basic` fixtures, with integration tests in `tests/pages-router.test.ts` and `tests/nextjs-compat/hooks.test.ts`. - **Unit tests**: extend `tests/check.test.ts` with four new assertions covering the newly-registered imports. ## Changes | File | Change | |---|---| | `packages/vinext/src/shims/router.ts` | Export `NextRouter` interface | | `packages/vinext/src/shims/compat-router.ts` | Add `NextRouter \| null` return type to `useRouter()` | | `packages/vinext/src/check.ts` | Add `next/compat/router`, `next/form`, `next/web-vitals`, `next/constants` to `IMPORT_SUPPORT` | | `tests/check.test.ts` | 4 new unit tests for the above imports | | `tests/pages-router.test.ts` | Integration test: `next/compat/router` in Pages Router | | `tests/nextjs-compat/hooks.test.ts` | Integration test: `next/compat/router` in App Router | | `tests/fixtures/*/compat-router-*` | Fixture components and pages for integration tests | ## Testing ``` vp test tests/check.test.ts # 76 tests, all pass vp test tests/pages-router.test.ts # includes new compat/router integration test vp test tests/nextjs-compat/hooks.test.ts # includes new App Router compat/router test ``` --- <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:33 +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#686
No description provided.