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

Font description and error messages #41764

Merged
merged 4 commits into from Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'
)