Skip to content

Commit

Permalink
Revert "Remove extra suspense boundary for default next/dynamic" (ver…
Browse files Browse the repository at this point in the history
…cel#65309)

Reverting temporarily while we investigate a bug where the page crashes
due to the missing `Suspense`.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1714691721631339)

Reverts vercel#64716

Closes NEXT-3307
  • Loading branch information
ijjk authored May 3, 2024
1 parent 025f5b6 commit 64ef34e
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 58 deletions.
1 change: 0 additions & 1 deletion packages/next/src/shared/lib/dynamic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export type DynamicOptions<P = {}> = LoadableGeneratedOptions & {
loadableGenerated?: LoadableGeneratedOptions
ssr?: boolean
/**
* TODO: remove this in next major version v15
* @deprecated `suspense` prop is not required anymore
*/
suspense?: boolean
Expand Down
9 changes: 3 additions & 6 deletions packages/next/src/shared/lib/lazy-dynamic/loadable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense, Fragment, lazy } from 'react'
import { Suspense, lazy } from 'react'
import { BailoutToCSR } from './dynamic-bailout-to-csr'
import type { ComponentModule } from './types'
import { PreloadCss } from './preload-css'
Expand Down Expand Up @@ -48,10 +48,7 @@ function Loadable(options: LoadableOptions) {
<Loading isLoading={true} pastDelay={true} error={null} />
) : null

const isSSR = opts.ssr
const Wrap = isSSR ? Fragment : Suspense
const wrapProps = isSSR ? {} : { fallback: fallbackElement }
const children = isSSR ? (
const children = opts.ssr ? (
<>
{/* During SSR, we need to preload the CSS from the dynamic component to avoid flash of unstyled content */}
{typeof window === 'undefined' ? (
Expand All @@ -65,7 +62,7 @@ function Loadable(options: LoadableOptions) {
</BailoutToCSR>
)

return <Wrap {...wrapProps}>{children}</Wrap>
return <Suspense fallback={fallbackElement}>{children}</Suspense>
}

LoadableComponent.displayName = 'LoadableComponent'
Expand Down
12 changes: 0 additions & 12 deletions test/e2e/app-dir/dynamic/app/default/dynamic-component.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/e2e/app-dir/dynamic/app/default/page.js

This file was deleted.

23 changes: 1 addition & 22 deletions test/e2e/app-dir/dynamic/dynamic.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'

describe('app dir - next/dynamic', () => {
const { next, isNextStart, isNextDev, skipped } = nextTestSetup({
const { next, isNextStart, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
Expand Down Expand Up @@ -58,26 +57,6 @@ describe('app dir - next/dynamic', () => {
expect($('h1').text()).toBe('hello')
})

it('should not render loading by default', async () => {
const $ = await next.render$('/default')
expect($('#dynamic-component').text()).not.toContain('loading')
})

if (isNextDev) {
it('should directly raise error when dynamic component error on server', async () => {
const pagePath = 'app/default/dynamic-component.js'
const page = await next.readFile(pagePath)
await next.patchFile(
pagePath,
page.replace('const isDevTest = false', 'const isDevTest = true')
)
await retry(async () => {
const { status } = await next.fetch('/default')
expect(status).toBe(500)
})
})
}

describe('no SSR', () => {
it('should not render client component imported through ssr: false in client components in edge runtime', async () => {
// noSSR should not show up in html
Expand Down

0 comments on commit 64ef34e

Please sign in to comment.