[PR #157] fix: resolve directory imports for next/font shims #358

Open
opened 2026-05-06 12:39:24 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/157
Author: @hoangnv170752
Created: 2/27/2026
Status: 🔄 Open

Base: mainHead: main


📝 Commits (1)

  • 635c9b8 fix: resolve directory imports for next/font shims

📊 Changes

1 file changed (+10 additions, -0 deletions)

View changed files

📝 packages/vinext/src/index.ts (+10 -0)

📄 Description

1/ Summary

  • Fix directory imports for next/font/local and next/font/google when imported from third-party packages like geist
  • Add resolveId hook handling for imports without .js extension that Vite's ESM resolution rejects
    2/ Problem
  • Libraries like geist import next/font/local as a directory:
    import localFont from "next/font/local"
  • This fails in Vite's ESM mode with:
Directory import '/node_modules/next/font/local' is not supported resolving ES modules
Did you mean to import "next/font/local/index.js"?

The existing resolve.alias only works for user code, not for dependencies in node_modules.
3/ Solution

  • Extend the resolveId hook to catch directory-style imports (without .js extension) and resolve them through the shim map, similar to the existing handling for .js extension imports.

🔄 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/157 **Author:** [@hoangnv170752](https://github.com/hoangnv170752) **Created:** 2/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`635c9b8`](https://github.com/cloudflare/vinext/commit/635c9b8846178826fa8cb9ad84f50b7a31081865) fix: resolve directory imports for next/font shims ### 📊 Changes **1 file changed** (+10 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+10 -0) </details> ### 📄 Description 1/ Summary - Fix directory imports for next/font/local and next/font/google when imported from third-party packages like geist - Add resolveId hook handling for imports without .js extension that Vite's ESM resolution rejects 2/ Problem - Libraries like geist import next/font/local as a directory: `import localFont from "next/font/local" ` - This fails in Vite's ESM mode with: ``` Directory import '/node_modules/next/font/local' is not supported resolving ES modules Did you mean to import "next/font/local/index.js"? ``` The existing resolve.alias only works for user code, not for dependencies in node_modules. 3/ Solution - Extend the resolveId hook to catch directory-style imports (without .js extension) and resolve them through the shim map, similar to the existing handling for .js extension imports. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#358
No description provided.