Skip to content

Commit

Permalink
Making optimizefonts backward compatible, work with either bool or ob…
Browse files Browse the repository at this point in the history
…j config
  • Loading branch information
janicklas-ralph committed Sep 15, 2022
1 parent cb2837f commit 4d55860
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Expand Up @@ -226,7 +226,7 @@ export class FontStylesheetGatheringPlugin {
for (let promiseIndex in fontDefinitionPromises) {
let css = await fontDefinitionPromises[promiseIndex]

if (this.optimizeFonts.experimentalAdjustFallbacks) {
if (this.optimizeFonts?.experimentalAdjustFallbacks) {
css += getFontOverrideCss(fontStylesheets[promiseIndex], css)
}

Expand Down
6 changes: 3 additions & 3 deletions packages/next/pages/_document.tsx
Expand Up @@ -420,7 +420,7 @@ export class Head extends Component<HeadProps> {
)
})

if (process.env.NODE_ENV !== 'development' && optimizeFonts.inlineFonts) {
if (process.env.NODE_ENV !== 'development' && optimizeFonts?.inlineFonts) {
cssLinkElements = this.makeStylesheetInert(
cssLinkElements
) as ReactElement[]
Expand Down Expand Up @@ -657,7 +657,7 @@ export class Head extends Component<HeadProps> {

if (
process.env.NODE_ENV !== 'development' &&
optimizeFonts.inlineFonts &&
optimizeFonts?.inlineFonts &&
!(process.env.NEXT_RUNTIME !== 'edge' && inAmpMode)
) {
children = this.makeStylesheetInert(children)
Expand Down Expand Up @@ -754,7 +754,7 @@ export class Head extends Component<HeadProps> {
/>

{children}
{optimizeFonts.inlineFonts && <meta name="next-font-preconnect" />}
{optimizeFonts?.inlineFonts && <meta name="next-font-preconnect" />}

{process.env.NEXT_RUNTIME !== 'edge' && inAmpMode && (
<>
Expand Down
3 changes: 2 additions & 1 deletion packages/next/shared/lib/html-context.ts
@@ -1,6 +1,7 @@
import type { BuildManifest } from '../../server/get-page-files'
import type { ServerRuntime } from 'next/types'
import type { NEXT_DATA } from './utils'
import type { FontConfig } from '../../server/font-utils'

import { createContext } from 'react'

Expand Down Expand Up @@ -36,7 +37,7 @@ export type HtmlProps = {
head?: Array<JSX.Element | null>
crossOrigin?: string
optimizeCss?: any
optimizeFonts?: any
optimizeFonts?: FontConfig
nextScriptWorkers?: boolean
runtime?: ServerRuntime
hasConcurrentFeatures?: boolean
Expand Down

0 comments on commit 4d55860

Please sign in to comment.