Skip to content

Commit

Permalink
Font description and error messages (#41764)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Hannes Bornö committed Oct 25, 2022
1 parent 78bf0a7 commit 10e7d45
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/font/README.md
@@ -1,3 +1,7 @@
# `@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)
Expand Up @@ -248,7 +248,10 @@ fn expr_to_json(expr: &Expr) -> Result<Value, ()> {
}
lit => HANDLER.with(|handler| {
handler
.struct_span_err(lit.span(), "Unexpected value")
.struct_span_err(
lit.span(),
"Font loader values must be explicitly written literals.",
)
.emit();
Err(())
}),
Expand Down
Expand Up @@ -5,13 +5,13 @@
: ^^
`----

x Unexpected value
x Font loader values must be explicitly written literals.
,-[input.js:7:1]
7 | const a = ABeeZee({ variant: [i1] })
: ^^
`----

x Unexpected value
x Font loader values must be explicitly written literals.
,-[input.js:10:1]
10 | const a = ABeeZee({ variant: () => {} })
: ^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions packages/next/font/google/index.js
@@ -0,0 +1,3 @@
throw new Error(
'You tried to import `next/font/google`, did you mean `@next/font/google`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
)
3 changes: 3 additions & 0 deletions packages/next/font/index.js
@@ -0,0 +1,3 @@
throw new Error(
'You tried to import `next/font`, did you mean `@next/font`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
)
3 changes: 3 additions & 0 deletions packages/next/font/local/index.js
@@ -0,0 +1,3 @@
throw new Error(
'You tried to import `next/font/local`, did you mean `@next/font/local`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
)

0 comments on commit 10e7d45

Please sign in to comment.