Files
Jiachi LiuandGitHub df77964e3d Preload chunks for next/dynamic in suspense mode (#37245)
When using `next/dynamic` with `suspense: true`, the API will opt into `React.lazy` with react 18. But previously it doesn't preload the dynamic chunks. This pr will include the chunks into initial html for faster hydration instead of loading the chunk until the script is executed. This makes `next/dynamic` has a significant difference from `React.lazy` api

x-ref: https://github.com/vercel/next.js/issues/37197#issuecomment-1138496911
x-ref: https://github.com/vercel/next.js/pull/37244
2022-05-27 20:11:34 +00:00

10 lines
146 B
JavaScript

import dynamic from 'next/dynamic'
const Foo = dynamic(() => import('../components/foo'))
export default () => (
<div>
<Foo />
</div>
)