Skip to content

Commit

Permalink
Default font config fix (#42235)
Browse files Browse the repository at this point in the history
Fixes typo and makes sure both loaders always have a default value.

## 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)
  • Loading branch information
Hannes Bornö committed Oct 31, 2022
1 parent b7ea0a5 commit cc0c85e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
6 changes: 2 additions & 4 deletions packages/next/server/config.ts
Expand Up @@ -90,8 +90,6 @@ export function setHttpClientAndAgentOptions(config: NextConfig) {
}

async function setFontLoaderDefaults(config: NextConfigComplete, dir: string) {
if (config.experimental?.fontLoaders) return

// Add @next/font loaders by default if they're installed
const hasNextFontDependency = (
await getDependencies({
Expand All @@ -114,14 +112,14 @@ async function setFontLoaderDefaults(config: NextConfigComplete, dir: string) {
}
if (
!config.experimental.fontLoaders.find(
({ loader }: any) => loader === '@next/font/goggle'
({ loader }: any) => loader === googleFontLoader.loader
)
) {
config.experimental.fontLoaders.push(googleFontLoader)
}
if (
!config.experimental.fontLoaders.find(
({ loader }: any) => loader === '@next/font/local'
({ loader }: any) => loader === localFontLoader.loader
)
) {
config.experimental.fontLoaders.push(localFontLoader)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/app-dir/next-font/next.config.js
@@ -1,5 +1,6 @@
module.exports = {
experimental: {
appDir: true,
fontLoaders: [],
},
}
3 changes: 1 addition & 2 deletions test/e2e/next-font/basepath/next.config.js
Expand Up @@ -3,8 +3,7 @@ module.exports = {
experimental: {
fontLoaders: [
{
loader: '@next/font/google',
options: { subsets: ['latin'] },
loader: '@next/font/local',
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/next-font/basepath/pages/index.js
@@ -1,5 +1,5 @@
import { Open_Sans } from '@next/font/google'
const openSans = Open_Sans()
const openSans = Open_Sans({ subsets: ['latin'] })

export default function Inter() {
return <p className={openSans.className}>Hello world</p>
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/next-font/with-font-declarations-file/next.config.js
Expand Up @@ -5,9 +5,6 @@ module.exports = {
loader: '@next/font/google',
options: { subsets: ['latin'] },
},
{
loader: '@next/font/local',
},
],
},
}

0 comments on commit cc0c85e

Please sign in to comment.