Skip to content

Commit bb200b9

Browse files
author
Hannes Bornö
authored
@next/font error messages (vercel#42689)
Fix wrong links. Add specific error message if Next.js version < 13. ## 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 build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 5e55c3c commit bb200b9

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

packages/font/google/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
// Validate next version
2+
const semver = require('next/dist/compiled/semver')
3+
if (semver.lt(require('next/package.json').version, '13.0.0')) {
4+
throw new Error('`@next/font` is only available in Next.js 13 and newer.')
5+
}
6+
17
let message = '@next/font/google failed to run or is incorrectly configured.'
28
if (process.env.NODE_ENV === 'development') {
39
message +=
410
'\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
511
}
612

13+
message += `\n\nRead more: https://nextjs.org/docs/basic-features/font-optimization`
14+
715
throw new Error(message)

packages/font/local/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
// Validate next version
2+
const semver = require('next/dist/compiled/semver')
3+
if (semver.lt(require('next/package.json').version, '13.0.0')) {
4+
throw new Error('`@next/font` is only available in Next.js 13 and newer.')
5+
}
6+
17
let message = '@next/font/local failed to run or is incorrectly configured.'
28
if (process.env.NODE_ENV === 'development') {
39
message +=
410
'\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
511
}
612

13+
message += `\n\nRead more: https://nextjs.org/docs/basic-features/font-optimization`
14+
715
throw new Error(message)

packages/next/font/google/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
throw new Error(
2-
'You tried to import `next/font/google`, did you mean `@next/font/google`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
2+
'You tried to import `next/font/google`, did you mean `@next/font/google`?\nRead more: https://nextjs.org/docs/basic-features/font-optimization'
33
)

packages/next/font/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
throw new Error(
2-
'You tried to import `next/font`, did you mean `@next/font`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
2+
'You tried to import `next/font`, did you mean `@next/font`?\nRead more: https://nextjs.org/docs/basic-features/font-optimization'
33
)

packages/next/font/local/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
throw new Error(
2-
'You tried to import `next/font/local`, did you mean `@next/font/local`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
2+
'You tried to import `next/font/local`, did you mean `@next/font/local`?\nRead more: https://nextjs.org/docs/basic-features/font-optimization'
33
)

0 commit comments

Comments
 (0)