-
Notifications
You must be signed in to change notification settings - Fork 27.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hydration mismatch caused by next/dynamic
when src
folder and babel
are used
#64741
Comments
We are also running into this issue. |
Also seeing this. I think this is the change that introduced the issue:142050d#diff-3cac9d9bfe73e0619e6407f21f6fe652da0719d0ec9074ff813ad3e416d0eb1aR945 It makes sense that this would only hit us in the /src/ directory |
### What * Fix `next/dynamic` with babel config and `src/` directory * Separate the existing `next/dynamic` dev tests, make it easier to cover more cases, add `.babelrc` + `src/` folder coverage case ### Why * The new transform is using `src/` or root dir as the base directory `next/dynamic` for generating relative module path as unique key for `next/dynamic` modules. The babel one was always using the root dir (`cwd`), which is incorrect. It should use the `src/` dir. In the future we could make the different solution to generate the unique id simpler, instead of using relative paths Closes NEXT-3254 Closes NEXT-3251 Fixes #64741
Thank you! |
It's fixed in v14.3.0-canary.31 |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
### What * Fix `next/dynamic` with babel config and `src/` directory * Separate the existing `next/dynamic` dev tests, make it easier to cover more cases, add `.babelrc` + `src/` folder coverage case ### Why * The new transform is using `src/` or root dir as the base directory `next/dynamic` for generating relative module path as unique key for `next/dynamic` modules. The babel one was always using the root dir (`cwd`), which is incorrect. It should use the `src/` dir. In the future we could make the different solution to generate the unique id simpler, instead of using relative paths Closes NEXT-3254 Closes NEXT-3251 Fixes #64741
Link to the code that reproduces this issue
https://github.com/LukasBombach/next-dynamic-src-folder-babel-bug
To Reproduce
yarn install
yarn dev
http://localhost:3000
next/hydration
Current vs. Expected behavior
In the example, I use
next/dynamic
to load and render a plain react component that always returns the same JSXsrc/pages/index.tsx
src/components/DynamicTest.tsx
I would expect no errors here, but this will result in a hydration mismatch:
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103 Available memory (MB): 16384 Available CPU cores: 8 Binaries: Node: 20.9.0 npm: 10.1.0 Yarn: 1.22.19 pnpm: 8.9.0 Relevant Packages: next: 14.2.2 // Latest available version is detected (14.2.2). eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.4.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Lazy Loading
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), Other (Deployed)
Additional context
The hydration mismatch only occurs under these conditions
babel
is usedsrc
folder is usedWhen you either remove the
.babelrc
from the example or move thepages
andcomponents
from thesrc
folder to the root dir, everything works alrightThe bug was introduced with next
14.2.0
We did reproduce it with
14.2.0
,14.2.1
and14.2.2
.Next
14.1.3
works fineNEXT-3251
The text was updated successfully, but these errors were encountered: