Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: The issue in importing fonts in buildable next.js libraries #66889

Open
wants to merge 10 commits into
base: canary
Choose a base branch
from

Conversation

sooraj-shukla
Copy link

What?

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.
I've created a fresh repository where the issue can be reproduced by following the instructions in the README.

image

Why?

There are following use cases of having a buildable library

  1. Creating a custom theme library for various Next.js applications.
  2. Utilizing buildable libraries to enable incremental building capabilities in monorepos (For example, when using Nx's incremental builds).

How?

The barrel files in next/fonts didn't export the fonts which was the root cause of the issue.

Fixes #51476

@ijjk
Copy link
Member

ijjk commented Jun 14, 2024

Allow CI Workflow Run

  • approve CI run for commit: 1b3648f

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@sooraj-shukla sooraj-shukla changed the title bugfix: fix the issue in importing the fonts in buildable next.js lib… bugfix: fix the issue in importing the fonts in buildable next.js libraries Jun 14, 2024
@sooraj-shukla sooraj-shukla changed the title bugfix: fix the issue in importing the fonts in buildable next.js libraries Fix: The issue in importing fonts in buildable next.js libraries Jun 14, 2024
@sooraj-shukla
Copy link
Author

Could someone please take a look at this small change and suggest me if there is something else that I should do so that this gets merged? It's solving an existing issue in next/font due to which few people are not able to create next.js libraries where using font is required, for example, a theme library.

Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, could you add a test case for this that fails without this change?

@sooraj-shukla
Copy link
Author

Hi, could you add a test case for this that fails without this change?

Sure, thanks for the feedback. Will work adding the test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exporting next/font into separate library throws Webpack compile error
2 participants