nandorojo / solito

🧍‍♂️ React Native + Next.js, unified.
https://solito.dev
MIT License
3.54k stars 181 forks source link

Nextjs font loader is not working #345

Closed navanshu closed 1 year ago

navanshu commented 1 year ago

I tried using a google font from @next/font but I am getting this error, I think this has something to do with the webpack or swc. I am using solito with tailwindcss.

  x Font loader calls must be assigned to a const
    ,-[/config/workspace/website/apps/next/pages/_app.tsx:22:1]
 22 |     import { jsx as _jsx } from "react/jsx-runtime";
 23 |     import { jsxs as _jsxs } from "react/jsx-runtime";
 24 |     import { Fragment as _Fragment } from "react/jsx-runtime";
 25 | ,-> var ssp = Source_Sans_Pro({
 26 | |     subsets: ['latin'],
 27 | |     weight: '400'
 28 | `-> });
 29 |     
 30 |     function MyApp(_ref) {
 31 |       var Component = _ref.Component,

TLDR, the compiler is converting const into vars, which makes nextjs throw it as an error.

The actual code looks like this.

import { Source_Sans_Pro } from '@next/font/google'

const ssp = Source_Sans_Pro({
  subsets: ['latin'],
  weight: '400',
})
nandorojo commented 1 year ago

honestly don’t think this is a solito related issue. sounds like something you should open on next.js

navanshu commented 1 year ago

Okay thanks for guiding me.