-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bundling of client entry chunks (#2932)
* Fix promise fallback data * fix
- Loading branch information
Showing
9 changed files
with
80 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { SWRConfig } from 'swr' | ||
|
||
function createPromiseData(data: any, timeout: number) { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(data) | ||
}, timeout) | ||
}) | ||
} | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
const fallback = { | ||
'/api/promise': createPromiseData({ value: 'async promise' }, 2000) | ||
} | ||
|
||
return <SWRConfig value={{ fallback }}>{children}</SWRConfig> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use client' | ||
|
||
import useSWR from 'swr' | ||
|
||
export default function Page() { | ||
const { data, isLoading } = useSWR('/api/promise') | ||
|
||
return <div>{isLoading ? 'loading...' : data?.value}</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
experimental: { | ||
serverActions: true, | ||
}, | ||
} | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable testing-library/prefer-screen-queries */ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test.describe('suspense fallback', () => { | ||
test('should wait for promise fallback value to be resolved', async ({ | ||
page | ||
}) => { | ||
await page.goto('./suspense-fallback/promise', { waitUntil: 'commit' }) | ||
await expect(page.getByText('async promise')).toBeVisible() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use client' | ||
|
||
// TODO: fix SWRConfig re-use issue with bundler | ||
import { SWRConfig as S } from '../_internal' | ||
export const SWRConfig = S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { unstable_serialize } from '../core/serialize' | ||
export { SWRConfig } from '../_internal' | ||
export { SWRConfig } from './config' |