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

@next/font error: Font loaders must be called and assigned to a const in the module scope #199

Closed
meakbiyik opened this issue Mar 8, 2023 · 2 comments

Comments

@meakbiyik
Copy link

Hi, thanks for the wonderful module that allows using covreage with next.js defaults! I have a bug that prevents me from using this plugin though: when using @next/font with the following code

import '../styles/globals.css';
import type { AppProps } from 'next/app';
import { Roboto } from '@next/font/google';

const roboto = Roboto({
  weight: ['400', '500', '700'],
  subsets: ['latin'],
});

export default function App({ Component, pageProps }: AppProps) {
  return (
      <Component {...pageProps} className={roboto.className} />
  );
}

adding the plugin gives the following error in compilation:

Font loaders must be called and assigned to a const in the module scope

Any help is appreciated!

@s0hv
Copy link

s0hv commented Mar 10, 2023

I had the same error and fixed it by putting /* istanbul ignore next */ on the line before const roboto = Roboto(...)

@meakbiyik
Copy link
Author

That works wonderfully, thanks a lot! I did not know that istanbul ignore comments were respected by this plugin, it might be a good idea to note this in the README.

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

No branches or pull requests

2 participants