Unverified Commit 10e7d452 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Font description and error messages (#41764)

Improve font error messages and readme

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 78bf0a79
# `@next/font` # `@next/font`
Experimental `@next/font` package `@next/font` includes built-in automatic self-hosting for any font file. This means you can optimally load web fonts with zero layout shift, thanks to the underlying CSS size-adjust property used.
This new font system also allows you to conveniently use all Google Fonts with performance and privacy in mind. CSS and font files are downloaded at build time and self-hosted with the rest of your static assets. No requests are sent to Google by the browser.
[Read more](https://nextjs.org/docs/optimizing/fonts)
...@@ -248,7 +248,10 @@ fn expr_to_json(expr: &Expr) -> Result<Value, ()> { ...@@ -248,7 +248,10 @@ fn expr_to_json(expr: &Expr) -> Result<Value, ()> {
} }
lit => HANDLER.with(|handler| { lit => HANDLER.with(|handler| {
handler handler
.struct_span_err(lit.span(), "Unexpected value") .struct_span_err(
lit.span(),
"Font loader values must be explicitly written literals.",
)
.emit(); .emit();
Err(()) Err(())
}), }),
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
: ^^ : ^^
`---- `----
x Unexpected value x Font loader values must be explicitly written literals.
,-[input.js:7:1] ,-[input.js:7:1]
7 | const a = ABeeZee({ variant: [i1] }) 7 | const a = ABeeZee({ variant: [i1] })
: ^^ : ^^
`---- `----
x Unexpected value x Font loader values must be explicitly written literals.
,-[input.js:10:1] ,-[input.js:10:1]
10 | const a = ABeeZee({ variant: () => {} }) 10 | const a = ABeeZee({ variant: () => {} })
: ^^^^^^^^ : ^^^^^^^^
......
throw new Error(
'You tried to import `next/font/google`, did you mean `@next/font/google`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
)
throw new Error(
'You tried to import `next/font`, did you mean `@next/font`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
)
throw new Error(
'You tried to import `next/font/local`, did you mean `@next/font/local`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment