From 88e2d3d1800343f5c5a347cf17804fc576d96c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 16:06:50 +0200 Subject: [PATCH 01/15] Missing subsets error -> warning --- packages/font/src/google/loader.ts | 17 +++++++++++++---- test/unit/google-font-loader.test.ts | 15 --------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/font/src/google/loader.ts b/packages/font/src/google/loader.ts index 758815be8c599..173318093543b 100644 --- a/packages/font/src/google/loader.ts +++ b/packages/font/src/google/loader.ts @@ -1,6 +1,10 @@ import type { AdjustFontFallback, FontLoader } from 'next/font' // @ts-ignore import { calculateSizeAdjustValues } from 'next/dist/server/font-utils' +// @ts-ignore +import * as Log from 'next/dist/build/output/log' +// @ts-ignore +import chalk from 'next/dist/compiled/chalk' import { fetchCSSFromGoogleFonts, fetchFontFile, @@ -19,10 +23,15 @@ const downloadGoogleFonts: FontLoader = async ({ emitFontFile, }) => { if (!config?.subsets) { - throw new Error( - 'Please specify subsets for `@next/font/google` in your `next.config.js`' + Log.warn( + `${chalk.bold('@next/font/google')} is missing ${chalk.bold( + 'options.subsets' + )} in your ${chalk.bold( + 'next.config.js' + )}. Please specify subsets, otherwise no fonts will be preloaded.` ) } + const subsets = config?.subsets || [] const { fontFamily, @@ -63,7 +72,7 @@ const downloadGoogleFonts: FontLoader = async ({ if (googleFontFileUrl) { fontFiles.push({ googleFontFileUrl, - preloadFontFile: !!preload && config.subsets.includes(currentSubset), + preloadFontFile: !!preload && subsets.includes(currentSubset), }) } } @@ -121,7 +130,7 @@ const downloadGoogleFonts: FontLoader = async ({ sizeAdjust: `${sizeAdjust}%`, } } catch { - console.error( + Log.error( `Failed to find font override values for font \`${fontFamily}\`` ) } diff --git a/test/unit/google-font-loader.test.ts b/test/unit/google-font-loader.test.ts index 8d69df45b676d..4b15723270d3d 100644 --- a/test/unit/google-font-loader.test.ts +++ b/test/unit/google-font-loader.test.ts @@ -201,21 +201,6 @@ describe('@next/font/google loader', () => { `) }) - test('Missing config with subsets', async () => { - await expect( - loader({ - functionName: 'Inter', - data: [], - config: undefined, - emitFontFile: jest.fn(), - resolve: jest.fn(), - fs: {} as any, - }) - ).rejects.toThrowErrorMatchingInlineSnapshot( - `"Please specify subsets for \`@next/font/google\` in your \`next.config.js\`"` - ) - }) - test('Missing function name', async () => { await expect( loader({ From 25bcf7edc0960a1e1699948ed11bd5e036f09adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 16:07:27 +0200 Subject: [PATCH 02/15] Add default config if @next/font is installed --- packages/next/server/config.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index 88fb42dd095b6..550e29410913c 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -23,6 +23,7 @@ import { } from '../shared/lib/image-config' import { loadEnvConfig } from '@next/env' import { gte as semverGte } from 'next/dist/compiled/semver' +import { getPackageVersion } from '../lib/get-package-version' export { DomainLocale, NextConfig, normalizeConfig } from './config-shared' @@ -818,6 +819,37 @@ export default async function loadConfig( : canonicalBase) || '' } + // Add official font loaders by default if they're installed + const nextFontVersion = await getPackageVersion({ + cwd: dir, + name: '@next/font', + }) + if (nextFontVersion) { + const googleFontLoader = { + loader: '@next/font/google', + } + const localFontLoader = { + loader: '@next/font/local', + } + if (!userConfig.experimental.fontLoaders) { + userConfig.experimental.fontLoaders = [] + } + if ( + !userConfig.experimental.fontLoaders.find( + ({ loader }: any) => loader === '@next/font/goggle' + ) + ) { + userConfig.experimental.fontLoaders.push(googleFontLoader) + } + if ( + !userConfig.experimental.fontLoaders.find( + ({ loader }: any) => loader === '@next/font/local' + ) + ) { + userConfig.experimental.fontLoaders.push(localFontLoader) + } + } + return assignDefaults({ configOrigin: relative(dir, path), configFile: path, From bf4aceda0f537d6f00ad8d3cf7e615440b8e5e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 16:07:37 +0200 Subject: [PATCH 03/15] Improve warnings --- packages/font/google/index.js | 8 +++++++- packages/font/local/index.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/font/google/index.js b/packages/font/google/index.js index f3d7e7c80ab0a..3c326b1771b60 100644 --- a/packages/font/google/index.js +++ b/packages/font/google/index.js @@ -1 +1,7 @@ -throw new Error('@next/font/google is not correctly configured') +let message = '@next/font/google failed to run.' +if (process.env.NODE_ENV === 'development') { + message += + '\nIf you just installed `@next/font`, please try rerunning `next dev`' +} + +throw new Error(message) diff --git a/packages/font/local/index.js b/packages/font/local/index.js index bc2f598aaa23d..fc28e702b9e8f 100644 --- a/packages/font/local/index.js +++ b/packages/font/local/index.js @@ -1 +1,7 @@ -throw new Error('@next/font/local is not correctly configured') +let message = '@next/font/local failed to run.' +if (process.env.NODE_ENV === 'development') { + message += + '\nIf you just installed `@next/font`, please try rerunning `next dev`' +} + +throw new Error(message) From 39efb2be8ffe9e4d709fb000e81d5fa851355085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 16:17:46 +0200 Subject: [PATCH 04/15] Listen for option changes in loader --- .../webpack/loaders/next-font-loader/index.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/next/build/webpack/loaders/next-font-loader/index.ts b/packages/next/build/webpack/loaders/next-font-loader/index.ts index 6edc12b4dddc6..1d59e59e14771 100644 --- a/packages/next/build/webpack/loaders/next-font-loader/index.ts +++ b/packages/next/build/webpack/loaders/next-font-loader/index.ts @@ -1,10 +1,12 @@ import type { FontLoader } from '../../../../font' +import { promises as fs } from 'fs' import path from 'path' import loaderUtils from 'next/dist/compiled/loader-utils3' import postcssFontLoaderPlugn from './postcss-font-loader' import { promisify } from 'util' import chalk from 'next/dist/compiled/chalk' +import { CONFIG_FILES } from '../../../../shared/lib/constants' export default async function nextFontLoader(this: any) { const fontLoaderSpan = this.currentTraceSpan.traceChild('next-font-loader') @@ -17,6 +19,24 @@ export default async function nextFontLoader(this: any) { postcss: getPostcss, } = this.getOptions() + const nextConfigPaths = CONFIG_FILES.map((config) => + path.join(this.rootContext, config) + ) + // Add next.config.js as a dependency, loaders must rerun in case options changed + await Promise.all( + nextConfigPaths.map(async (configPath) => { + const hasConfig = await fs.access(configPath).then( + () => true, + () => false + ) + if (hasConfig) { + this.addDependency(configPath) + } else { + this.addMissingDependency(configPath) + } + }) + ) + const emitFontFile = (content: Buffer, ext: string, preload: boolean) => { const opts = { context: this.rootContext, content } const interpolatedName = loaderUtils.interpolateName( From 23673a52c3f601e24e17bd0d7237acf119ba424c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 16:18:10 +0200 Subject: [PATCH 05/15] Improve resolving of local files --- packages/font/src/local/utils.ts | 2 +- packages/next/build/webpack/loaders/next-font-loader/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/font/src/local/utils.ts b/packages/font/src/local/utils.ts index 541517da28f3c..90cdf807e15d1 100644 --- a/packages/font/src/local/utils.ts +++ b/packages/font/src/local/utils.ts @@ -60,7 +60,7 @@ export function validateData(functionName: string, data: any): FontOptions { throw new Error(`Unexpected file \`${src}\``) } - const family = /.+\/(.+?)\./.exec(src)![1] + const family = /(.*\/)?(.+?)\.(woff|woff2|eot|ttf|otf)$/.exec(src)![2] if (Array.isArray(declarations)) { declarations.forEach((declaration) => { diff --git a/packages/next/build/webpack/loaders/next-font-loader/index.ts b/packages/next/build/webpack/loaders/next-font-loader/index.ts index 1d59e59e14771..de340cddd0d55 100644 --- a/packages/next/build/webpack/loaders/next-font-loader/index.ts +++ b/packages/next/build/webpack/loaders/next-font-loader/index.ts @@ -75,7 +75,7 @@ export default async function nextFontLoader(this: any) { path.dirname( path.join(this.rootContext, relativeFilePathFromRoot) ), - src + src.startsWith('.') ? src : `./${src}` ), fs: this.fs, }) From 769973f3a2f956a0c13abef2ca185c44dcd8712b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 16:31:39 +0200 Subject: [PATCH 06/15] Tests --- test/e2e/app-dir/next-font/fonts/index.js | 6 +++--- .../e2e/app-dir/next-font/fonts/{ => test}/font5.woff2 | 0 .../e2e/app-dir/next-font/fonts/{ => test}/font6.woff2 | 0 test/e2e/app-dir/next-font/next.config.js | 5 ----- .../next-font/font-loader-in-document/next.config.js | 10 ---------- 5 files changed, 3 insertions(+), 18 deletions(-) rename test/e2e/app-dir/next-font/fonts/{ => test}/font5.woff2 (100%) rename test/e2e/app-dir/next-font/fonts/{ => test}/font6.woff2 (100%) delete mode 100644 test/e2e/next-font/font-loader-in-document/next.config.js diff --git a/test/e2e/app-dir/next-font/fonts/index.js b/test/e2e/app-dir/next-font/fonts/index.js index 55074a79d13cc..26477e3ec7377 100644 --- a/test/e2e/app-dir/next-font/fonts/index.js +++ b/test/e2e/app-dir/next-font/fonts/index.js @@ -1,6 +1,6 @@ import localFont from '@next/font/local' -export const font1 = localFont({ src: './font1.woff2', variable: '--font-1' }) +export const font1 = localFont({ src: 'font1.woff2', variable: '--font-1' }) export const font2 = localFont({ src: './font2.woff2', variable: '--font-2' }) export const font3 = localFont({ src: './font3.woff2', @@ -9,8 +9,8 @@ export const font3 = localFont({ }) export const font4 = localFont({ src: './font4.woff2', weight: '100' }) export const font5 = localFont({ - src: './font5.woff2', + src: './test/font5.woff2', style: 'italic', preload: false, }) -export const font6 = localFont({ src: './font6.woff2' }) +export const font6 = localFont({ src: 'test/font6.woff2' }) diff --git a/test/e2e/app-dir/next-font/fonts/font5.woff2 b/test/e2e/app-dir/next-font/fonts/test/font5.woff2 similarity index 100% rename from test/e2e/app-dir/next-font/fonts/font5.woff2 rename to test/e2e/app-dir/next-font/fonts/test/font5.woff2 diff --git a/test/e2e/app-dir/next-font/fonts/font6.woff2 b/test/e2e/app-dir/next-font/fonts/test/font6.woff2 similarity index 100% rename from test/e2e/app-dir/next-font/fonts/font6.woff2 rename to test/e2e/app-dir/next-font/fonts/test/font6.woff2 diff --git a/test/e2e/app-dir/next-font/next.config.js b/test/e2e/app-dir/next-font/next.config.js index fd841b325c948..cfa3ac3d7aa94 100644 --- a/test/e2e/app-dir/next-font/next.config.js +++ b/test/e2e/app-dir/next-font/next.config.js @@ -1,10 +1,5 @@ module.exports = { experimental: { appDir: true, - fontLoaders: [ - { - loader: '@next/font/local', - }, - ], }, } diff --git a/test/e2e/next-font/font-loader-in-document/next.config.js b/test/e2e/next-font/font-loader-in-document/next.config.js deleted file mode 100644 index 3f4a776b7f409..0000000000000 --- a/test/e2e/next-font/font-loader-in-document/next.config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - experimental: { - fontLoaders: [ - { - loader: '@next/font/google', - options: { subsets: ['latin'] }, - }, - ], - }, -} From f87a91c2a84e7bf6a8e49867961d6e509884ca4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 17:10:41 +0200 Subject: [PATCH 07/15] message --- packages/font/google/index.js | 2 +- packages/font/local/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/font/google/index.js b/packages/font/google/index.js index 3c326b1771b60..6caac589bbef6 100644 --- a/packages/font/google/index.js +++ b/packages/font/google/index.js @@ -1,7 +1,7 @@ let message = '@next/font/google failed to run.' if (process.env.NODE_ENV === 'development') { message += - '\nIf you just installed `@next/font`, please try rerunning `next dev`' + '\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.' } throw new Error(message) diff --git a/packages/font/local/index.js b/packages/font/local/index.js index fc28e702b9e8f..af5c3f1358057 100644 --- a/packages/font/local/index.js +++ b/packages/font/local/index.js @@ -1,7 +1,7 @@ let message = '@next/font/local failed to run.' if (process.env.NODE_ENV === 'development') { message += - '\nIf you just installed `@next/font`, please try rerunning `next dev`' + '\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.' } throw new Error(message) From 05278b09419cab0d73fa6c7ca980122fe57d2f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 17:20:08 +0200 Subject: [PATCH 08/15] comment --- packages/next/server/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index 550e29410913c..41405adfe66f1 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -819,7 +819,7 @@ export default async function loadConfig( : canonicalBase) || '' } - // Add official font loaders by default if they're installed + // Add @next/font loaders by default if they're installed const nextFontVersion = await getPackageVersion({ cwd: dir, name: '@next/font', From 6980c900e0f610b4db24166c4045f9e24f178af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 17:31:00 +0200 Subject: [PATCH 09/15] .experimental check --- packages/next/server/config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index 41405adfe66f1..fcf0010a41289 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -831,6 +831,9 @@ export default async function loadConfig( const localFontLoader = { loader: '@next/font/local', } + if (!userConfig.experimental) { + userConfig.experimental = {} + } if (!userConfig.experimental.fontLoaders) { userConfig.experimental.fontLoaders = [] } From 8b478ab2e77aea875950a7d0e7eddbbcd9451b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 18:01:51 +0200 Subject: [PATCH 10/15] Fix type --- packages/next/server/config-shared.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/server/config-shared.ts b/packages/next/server/config-shared.ts index 942f5d41e514e..9e81357dab704 100644 --- a/packages/next/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -162,7 +162,7 @@ export interface ExperimentalConfig { // A list of packages that should always be transpiled and bundled in the server transpilePackages?: string[] - fontLoaders?: [{ loader: string; options?: any }] + fontLoaders?: Array<{ loader: string; options?: any }> webVitalsAttribution?: Array } From e88fb5dc2ecdc32c6531814f05c1ff02d0998c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 18:07:17 +0200 Subject: [PATCH 11/15] Fix test --- test/e2e/app-dir/next-font/fonts/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/app-dir/next-font/fonts/index.js b/test/e2e/app-dir/next-font/fonts/index.js index 26477e3ec7377..d9d8746396cef 100644 --- a/test/e2e/app-dir/next-font/fonts/index.js +++ b/test/e2e/app-dir/next-font/fonts/index.js @@ -1,7 +1,7 @@ import localFont from '@next/font/local' -export const font1 = localFont({ src: 'font1.woff2', variable: '--font-1' }) -export const font2 = localFont({ src: './font2.woff2', variable: '--font-2' }) +export const font1 = localFont({ src: './font1.woff2', variable: '--font-1' }) +export const font2 = localFont({ src: 'font2.woff2', variable: '--font-2' }) export const font3 = localFont({ src: './font3.woff2', weight: '900', From 998a0365bd5da61eafd22f637e425e982dbddffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 18:20:42 +0200 Subject: [PATCH 12/15] skip devdep --- packages/next/lib/get-package-version.ts | 2 +- packages/next/server/config.ts | 77 +++++++++++++----------- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/packages/next/lib/get-package-version.ts b/packages/next/lib/get-package-version.ts index a924adc2cabb1..636faf7eb215d 100644 --- a/packages/next/lib/get-package-version.ts +++ b/packages/next/lib/get-package-version.ts @@ -10,7 +10,7 @@ type PackageJsonDependencies = { let cachedDeps: Promise -function getDependencies({ +export function getDependencies({ cwd, }: { cwd: string diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index fcf0010a41289..d09f6e3534a39 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -23,7 +23,7 @@ import { } from '../shared/lib/image-config' import { loadEnvConfig } from '@next/env' import { gte as semverGte } from 'next/dist/compiled/semver' -import { getPackageVersion } from '../lib/get-package-version' +import { getDependencies } from '../lib/get-package-version' export { DomainLocale, NextConfig, normalizeConfig } from './config-shared' @@ -77,6 +77,46 @@ export function setHttpClientAndAgentOptions(options: NextConfig) { ;(global as any).__NEXT_HTTPS_AGENT = new HttpsAgent(options.httpAgentOptions) } +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({ + cwd: dir, + }) + ).dependencies['@next/font'] + + if (hasNextFontDependency) { + const googleFontLoader = { + loader: '@next/font/google', + } + const localFontLoader = { + loader: '@next/font/local', + } + if (!config.experimental) { + config.experimental = {} + } + if (!config.experimental.fontLoaders) { + config.experimental.fontLoaders = [] + } + if ( + !config.experimental.fontLoaders.find( + ({ loader }: any) => loader === '@next/font/goggle' + ) + ) { + config.experimental.fontLoaders.push(googleFontLoader) + } + if ( + !config.experimental.fontLoaders.find( + ({ loader }: any) => loader === '@next/font/local' + ) + ) { + config.experimental.fontLoaders.push(localFontLoader) + } + } +} + function assignDefaults(userConfig: { [key: string]: any }) { const configFileName = userConfig.configFileName if (typeof userConfig.exportTrailingSlash !== 'undefined') { @@ -819,40 +859,6 @@ export default async function loadConfig( : canonicalBase) || '' } - // Add @next/font loaders by default if they're installed - const nextFontVersion = await getPackageVersion({ - cwd: dir, - name: '@next/font', - }) - if (nextFontVersion) { - const googleFontLoader = { - loader: '@next/font/google', - } - const localFontLoader = { - loader: '@next/font/local', - } - if (!userConfig.experimental) { - userConfig.experimental = {} - } - if (!userConfig.experimental.fontLoaders) { - userConfig.experimental.fontLoaders = [] - } - if ( - !userConfig.experimental.fontLoaders.find( - ({ loader }: any) => loader === '@next/font/goggle' - ) - ) { - userConfig.experimental.fontLoaders.push(googleFontLoader) - } - if ( - !userConfig.experimental.fontLoaders.find( - ({ loader }: any) => loader === '@next/font/local' - ) - ) { - userConfig.experimental.fontLoaders.push(localFontLoader) - } - } - return assignDefaults({ configOrigin: relative(dir, path), configFile: path, @@ -884,5 +890,6 @@ export default async function loadConfig( const completeConfig = assignDefaults(defaultConfig) as NextConfigComplete completeConfig.configFileName = configFileName setHttpClientAndAgentOptions(completeConfig) + await setFontLoaderDefaults(completeConfig, dir) return completeConfig } From 22e8892d07710ba2688b331cabfeb3b51e1e73f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 18:24:58 +0200 Subject: [PATCH 13/15] msg --- packages/font/google/index.js | 2 +- packages/font/local/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/font/google/index.js b/packages/font/google/index.js index 6caac589bbef6..b86140fd452a3 100644 --- a/packages/font/google/index.js +++ b/packages/font/google/index.js @@ -1,4 +1,4 @@ -let message = '@next/font/google failed to run.' +let message = '@next/font/google failed to run or is incorrectly configured.' if (process.env.NODE_ENV === 'development') { message += '\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.' diff --git a/packages/font/local/index.js b/packages/font/local/index.js index af5c3f1358057..c2eda14c0128f 100644 --- a/packages/font/local/index.js +++ b/packages/font/local/index.js @@ -1,4 +1,4 @@ -let message = '@next/font/local failed to run.' +let message = '@next/font/local failed to run or is incorrectly configured.' if (process.env.NODE_ENV === 'development') { message += '\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.' From 0b602c10c1dd6e63972993e3fb4ac8f7d40c9114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 18:50:12 +0200 Subject: [PATCH 14/15] Fix test --- test/e2e/next-font/font-loader-in-document-error.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/e2e/next-font/font-loader-in-document-error.test.ts b/test/e2e/next-font/font-loader-in-document-error.test.ts index 7e6d39cd5d610..8c4dc13951665 100644 --- a/test/e2e/next-font/font-loader-in-document-error.test.ts +++ b/test/e2e/next-font/font-loader-in-document-error.test.ts @@ -17,9 +17,6 @@ describe('font-loader-in-document-error', () => { next = await createNext({ files: { pages: new FileRef(join(__dirname, 'font-loader-in-document/pages')), - 'next.config.js': new FileRef( - join(__dirname, 'font-loader-in-document/next.config.js') - ), }, dependencies: { '@next/font': 'canary', From c962187345aa29dcc820fbc940e0e57dd093257a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Fri, 21 Oct 2022 19:25:45 +0200 Subject: [PATCH 15/15] fix tests --- packages/next/server/config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index d09f6e3534a39..8f61b210d3945 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -859,12 +859,14 @@ export default async function loadConfig( : canonicalBase) || '' } - return assignDefaults({ + const completeConfig = assignDefaults({ configOrigin: relative(dir, path), configFile: path, configFileName, ...userConfig, }) as NextConfigComplete + await setFontLoaderDefaults(completeConfig, dir) + return completeConfig } else { const configBaseName = basename(CONFIG_FILES[0], extname(CONFIG_FILES[0])) const nonJsPath = findUp.sync(