Skip to content

Commit

Permalink
fix: rm stringify for renderOpts.images
Browse files Browse the repository at this point in the history
  • Loading branch information
JuniorTour committed Feb 7, 2022
1 parent 0da4ba9 commit 3ac014a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/next/client/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ let {
imageConfigDefault

function setImageConfig(imagesConfig: ImageConfigComplete) {
if (!imagesConfig || process.env.__NEXT_IMAGE_OPTS) return
if (!imagesConfig) return

configDeviceSizes = imagesConfig.deviceSizes
configImageSizes = imagesConfig.imageSizes
Expand Down
5 changes: 3 additions & 2 deletions packages/next/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { MIDDLEWARE_ROUTE } from '../lib/constants'
import { addRequestMeta, getRequestMeta } from './request-meta'
import { createHeaderRoute, createRedirectRoute } from './server-route-utils'
import { PrerenderManifest } from '../build'
import { ImageConfigComplete } from './image-config'

export type FindComponentsResult = {
components: LoadComponentsReturnType
Expand Down Expand Up @@ -145,7 +146,7 @@ export default abstract class Server {
ampOptimizerConfig?: { [key: string]: any }
basePath: string
optimizeFonts: boolean
images: string
images: ImageConfigComplete
fontManifest?: FontManifest
optimizeImages: boolean
disableOptimizedLoading?: boolean
Expand Down Expand Up @@ -295,7 +296,7 @@ export default abstract class Server {
customServer: customServer === true ? true : undefined,
ampOptimizerConfig: this.nextConfig.experimental.amp?.optimizer,
basePath: this.nextConfig.basePath,
images: JSON.stringify(this.nextConfig.images),
images: this.nextConfig.images,
optimizeFonts: !!this.nextConfig.optimizeFonts && !dev,
fontManifest:
this.nextConfig.optimizeFonts && !dev
Expand Down
7 changes: 3 additions & 4 deletions packages/next/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import RenderResult from './render-result'
import isError from '../lib/is-error'
import { readableStreamTee } from './web/utils'
import { ImageConfigContext } from '../shared/lib/image-config-context'
import { ImageConfigComplete } from './image-config'

let optimizeAmp: typeof import('./optimize-amp').default
let getFontDefinitionFromManifest: typeof import('./font-utils').getFontDefinitionFromManifest
Expand Down Expand Up @@ -233,7 +234,7 @@ export type RenderOptsPartial = {
serverComponents?: boolean
customServer?: boolean
crossOrigin?: string
images: string
images: ImageConfigComplete
}

export type RenderOpts = LoadComponentsReturnType & RenderOptsPartial
Expand Down Expand Up @@ -716,9 +717,7 @@ export async function renderToHTML(
value={(moduleName) => reactLoadableModules.push(moduleName)}
>
<StyleRegistry registry={jsxStyleRegistry}>
<ImageConfigContext.Provider
value={images ? JSON.parse(images) : null}
>
<ImageConfigContext.Provider value={images}>
{children}
</ImageConfigContext.Provider>
</StyleRegistry>
Expand Down

0 comments on commit 3ac014a

Please sign in to comment.