rsnext/test/development
OJ Kwon 5b52e7772d
feat(turbopack): support basic next/dynamic (#56389)
Closes WEB-1702

This PR implements initial support for the `next/dynamic` in Turbopack,
more specifically resolving some hydration errors and other components
boot up cases.

Previously, turbopack had partial next/dynamic support via its own mode
(https://github.com/vercel/next.js/pull/56389/files#diff-e1af4f79cb88a73f819a25443d15ed4b1ffabcbb879256caa59b751fad46d7c4L68),
which does a transform against `next/dynamic` wrapped import to embed
dynamically resolvable chunk ids like
(ad42b610c2/packages/next-swc/crates/next-transform-dynamic/tests/fixture/wrapped-import/output-turbo-dev-server.js).

However, since next.js relies on static path to the chunks to the
dynamic import and passing those ids in between client-server to ensure
component load (and avoid hydration errors), it doesn't work out of the
box. This PR changes turbopack's behavior to closely mimic what current
next.js's webpack plugin does, by

1. Traverse the module graph, find out `dynamic(import())`
2. Generate chunks for those imports, creates a partial LoadableManifest
per each imports
3. Merge partial manifest into a single `react-loadable-manifest.json`
4. For the id, use static (Webpack mode) instead of dynamic so we can
embed it in `react-loadable-manifest` as well as next.js can use it to
pass it between server-client context.

I left a small comment to the implementation
(https://github.com/vercel/next.js/pull/56389/files#diff-bf12ed2c69d0bc89a06884779da4ae44967eb8becada031dea12bedef28e2622R155)
for the lifecycle of this feature in case to fix further.

This makes to pass most of the basic next-dynamic related integration
tests, except if the import have webpack specific features like
ad42b610c2/test/development/basic/next-dynamic/pages/dynamic/multiple-modules.js (L5).

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-10-16 10:24:54 +02:00
..
acceptance Turbopack: Implement Server Actions (#53890) 2023-10-04 23:33:21 +00:00
acceptance-app Loose RSC import restrictions for 3rd party packages (#56501) 2023-10-05 23:59:22 +00:00
api-cors-with-rewrite fix(#11930): rewritten api routes can correctly handle cors in dev mode (#38937) 2022-07-29 21:39:43 -05:00
app-dir Loose types of app routes return value (#55849) 2023-09-25 11:34:21 +02:00
app-hmr remove HMR polling in favor of more targeted events (#54406) 2023-08-23 16:25:57 -07:00
app-render-error-log Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
basic feat(turbopack): support basic next/dynamic (#56389) 2023-10-16 10:24:54 +02:00
client-dev-overlay fix: error overlay hijacking application focus (safari) (#53693) 2023-08-08 21:45:03 +02:00
correct-tsconfig-defaults chore(test): fix flaky tsconfig.json test (#53132) 2023-07-24 14:33:55 -07:00
dotenv-default-expansion Ensure next.url is used instead of next.appPort (#44163) 2022-12-19 13:29:50 -08:00
experimental-https-server test(integration): fix --turbo tests fixture setup (#55293) 2023-09-18 17:46:07 +00:00
gssp-notfound Ensure next.url is used instead of next.appPort (#44163) 2022-12-19 13:29:50 -08:00
jsconfig-path-reloading Fixes performance problems due to TaskScopes (#55721) 2023-09-28 09:40:21 +02:00
middleware-errors Polish error icon for error log (#55618) 2023-09-20 14:56:34 +00:00
middleware-warnings refactor tests for readability (#51051) 2023-06-21 19:47:21 +00:00
next-font Logging improvements (#55298) 2023-09-13 15:27:02 +02:00
pages-dir Move client-navigation test to test/development (#55888) 2023-09-24 11:38:53 +02:00
project-directory-with-styled-jsx-suffix fix: allow user directory with styled-jsx prefix in next dev (#41484) 2022-10-19 19:01:48 +00:00
repeated-dev-edits Add test checking that repeated edits won't cause hydration issues (#44189) 2022-12-21 14:17:50 +01:00
tsconfig-path-reloading Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
typescript-auto-install test(integration): fix --turbo tests fixture setup (#55293) 2023-09-18 17:46:07 +00:00
watch-config-file Logging improvements (#55298) 2023-09-13 15:27:02 +02:00
webpack-issuer-deprecation-warning More Turbopack fixes (#56275) 2023-10-02 09:42:32 +02:00