Skip to content

sooraj-shukla/next-font-issue

Repository files navigation

Next Font Issue

In the current canary version of Next.js, importing Next.js fonts in any buildable Next.js library is not supported. Attempting to do so will result in a build failure, with an error indicating that the fonts are not exported from the package.

Use Cases

  1. Creating a custom theme library for various Next.js applications.
  2. Utilizing buildable libraries to enable incremental building capabilities.

Libraries in this repo

Library Buildable Comments
providers No The Next.js app compiles successfully [with this library](./apps/next-app/src/app/layout.tsx).
providers-buildable Yes The library fails to build successfully due to the font issue.

Building the Next.js App

To build the Next.js app, run the following commands:

pnpm install
nx build next-app

Notice that the app builds successfully with the Next.js canary version. This is because the application uses the font provider from a non-buildable library and does not import anything from the buildable library.

Building the "providers-buildable" library

Run the following commands to build the library:

pnpm install
nx build providers-buildable

Notice that the library imports the "Inter" Google font from "next/font" and observe the error caused by this import.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published