[PR #1006] [MERGED] fix: replace relative shim imports with bare specifier vinext/shims/X (#1001) #1017

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

📋 Pull Request Information

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

Base: mainHead: fix/1001-relative-shim-imports


📝 Commits (3)

  • 823c67d fix: replace relative shim imports with bare specifier vinext/shims/X (#1001)
  • 343ef9f fix: address review feedback for relative shim imports (#1006)
  • 58079ea replace test with oxlint plugin

📊 Changes

40 files changed (+355 additions, -77 deletions)

View changed files

oxlint-plugins/prefer-import-alias.js (+251 -0)
📝 packages/vinext/src/build/prerender.ts (+2 -2)
📝 packages/vinext/src/cache.ts (+1 -1)
📝 packages/vinext/src/client/vinext-next-data.ts (+1 -1)
📝 packages/vinext/src/cloudflare/kv-cache-handler.ts (+5 -2)
📝 packages/vinext/src/config/next-config.ts (+2 -2)
📝 packages/vinext/src/global.d.ts (+1 -1)
📝 packages/vinext/src/index.ts (+1 -1)
📝 packages/vinext/src/server/app-browser-entry.ts (+3 -3)
📝 packages/vinext/src/server/app-browser-state.ts (+2 -2)
📝 packages/vinext/src/server/app-middleware.ts (+2 -2)
📝 packages/vinext/src/server/app-page-boundary-render.ts (+4 -4)
📝 packages/vinext/src/server/app-page-cache.ts (+1 -1)
📝 packages/vinext/src/server/app-page-dispatch.ts (+5 -5)
📝 packages/vinext/src/server/app-page-head.ts (+1 -1)
📝 packages/vinext/src/server/app-page-render.ts (+1 -1)
📝 packages/vinext/src/server/app-page-route-wiring.tsx (+4 -4)
📝 packages/vinext/src/server/app-prerender-endpoints.ts (+1 -1)
📝 packages/vinext/src/server/app-prerender-static-params.ts (+1 -1)
📝 packages/vinext/src/server/app-route-handler-cache.ts (+1 -1)

...and 20 more files

📄 Description

Fixes #1001

Summary

  • Rewrote 67 relative from "../shims/X.js" imports across 34 source files to use the package's bare specifier from "vinext/shims/X"
  • Added .tsconfig paths mapping so TypeScript resolves shim types to source (avoids type mismatch between dist/ and src/ module graphs for type checking)
  • Added vitest project-level resolve.alias for vinext/shims → source (prevents separate module graph instances in unit tests without the full RSC plugin)
  • Added ./dist/shims/*.js and ./dist/shims/internal/*.js to package.json exports as a safety net for absolute-path resolution
  • Added regression test tests/shim-imports.test.ts that asserts no relative shim imports exist in source

Root cause

@vitejs/plugin-rsc's packageSources tracking only fires for bare specifier imports. Relative imports ("../shims/slot.js") never populate the map, so the RSC plugin takes a broken fallback path that generates absolute filesystem paths — which fail against the package's exports field gate in standard Vite 8.

Test plan

  • New test: tests/shim-imports.test.ts — scans all source files for relative shim imports, verified to catch all 67 instances before the fix
  • Full test suite: 4656 pass, 0 test failures (1 pre-existing flaky timeout in pages-router.test.ts unrelated to this change)
  • Type check: passes on 460 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/1006 **Author:** [@Divkix](https://github.com/Divkix) **Created:** 5/1/2026 **Status:** ✅ Merged **Merged:** 5/2/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/1001-relative-shim-imports` --- ### 📝 Commits (3) - [`823c67d`](https://github.com/cloudflare/vinext/commit/823c67d1cec343e29d7ce769c7c4a89784ef8279) fix: replace relative shim imports with bare specifier vinext/shims/X (#1001) - [`343ef9f`](https://github.com/cloudflare/vinext/commit/343ef9f04b0368d20299db7d1e2c6196b80c0a21) fix: address review feedback for relative shim imports (#1006) - [`58079ea`](https://github.com/cloudflare/vinext/commit/58079ea8420a99bf23decdf118a2d1b6974c49b4) replace test with oxlint plugin ### 📊 Changes **40 files changed** (+355 additions, -77 deletions) <details> <summary>View changed files</summary> ➕ `oxlint-plugins/prefer-import-alias.js` (+251 -0) 📝 `packages/vinext/src/build/prerender.ts` (+2 -2) 📝 `packages/vinext/src/cache.ts` (+1 -1) 📝 `packages/vinext/src/client/vinext-next-data.ts` (+1 -1) 📝 `packages/vinext/src/cloudflare/kv-cache-handler.ts` (+5 -2) 📝 `packages/vinext/src/config/next-config.ts` (+2 -2) 📝 `packages/vinext/src/global.d.ts` (+1 -1) 📝 `packages/vinext/src/index.ts` (+1 -1) 📝 `packages/vinext/src/server/app-browser-entry.ts` (+3 -3) 📝 `packages/vinext/src/server/app-browser-state.ts` (+2 -2) 📝 `packages/vinext/src/server/app-middleware.ts` (+2 -2) 📝 `packages/vinext/src/server/app-page-boundary-render.ts` (+4 -4) 📝 `packages/vinext/src/server/app-page-cache.ts` (+1 -1) 📝 `packages/vinext/src/server/app-page-dispatch.ts` (+5 -5) 📝 `packages/vinext/src/server/app-page-head.ts` (+1 -1) 📝 `packages/vinext/src/server/app-page-render.ts` (+1 -1) 📝 `packages/vinext/src/server/app-page-route-wiring.tsx` (+4 -4) 📝 `packages/vinext/src/server/app-prerender-endpoints.ts` (+1 -1) 📝 `packages/vinext/src/server/app-prerender-static-params.ts` (+1 -1) 📝 `packages/vinext/src/server/app-route-handler-cache.ts` (+1 -1) _...and 20 more files_ </details> ### 📄 Description Fixes #1001 ## Summary - Rewrote 67 relative `from "../shims/X.js"` imports across 34 source files to use the package's bare specifier `from "vinext/shims/X"` - Added `.tsconfig` `paths` mapping so TypeScript resolves shim types to source (avoids type mismatch between `dist/` and `src/` module graphs for type checking) - Added vitest project-level `resolve.alias` for `vinext/shims` → source (prevents separate module graph instances in unit tests without the full RSC plugin) - Added `./dist/shims/*.js` and `./dist/shims/internal/*.js` to package.json exports as a safety net for absolute-path resolution - Added regression test `tests/shim-imports.test.ts` that asserts no relative shim imports exist in source ## Root cause `@vitejs/plugin-rsc`'s `packageSources` tracking only fires for bare specifier imports. Relative imports (`"../shims/slot.js"`) never populate the map, so the RSC plugin takes a broken fallback path that generates absolute filesystem paths — which fail against the package's `exports` field gate in standard Vite 8. ## Test plan - New test: `tests/shim-imports.test.ts` — scans all source files for relative shim imports, verified to catch all 67 instances before the fix - Full test suite: 4656 pass, 0 test failures (1 pre-existing flaky timeout in `pages-router.test.ts` unrelated to this change) - Type check: passes on 460 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: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#1017
No description provided.