-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Fast refresh does not work correctly with MDX #13574
Comments
I can confirm this. I just verified with my project. The page doing full reload on content change in |
MDX is not the problem, I managed to get fast refresh working Fast refresh gets disabled when the page file exports non react stuff (constants, objects, ) that gets consumed in other react files, so make sure you don’t export variables from MDX Also make sure that your main App component is a named function (should not be If you want to try out fast refresh with MDX files try out Dokz |
@remorses Thanks. What you're saying makes sense. But in my case, I don't have any App component and my MDX file does not export variables. |
I can confirm this is happening with using the latest canary versions on multiple mdx based sites. |
MDX fast refresh does not work for 9.5.0 but works for 9.4.0 in some cases, i can’t find the reason though |
Correct, I was trying to do some debugging but came up with nothing. I thought at first perhaps it was from using additional rehype / remark plugins, but none of the base mdx examples work with fast refresh. @timneutkens @Timer, curious if this might be a priority anytime soon!? |
Next.js plugins like `@next/mdx` inject additional webpack loaders to compile files, but they omit the necessary loader for Fast Refresh to work. Instead of making these files deopt out of Fast Refresh, we can automatically detect and inject the loader in these cases. Fixes vercel#13574
Next.js plugins like `@next/mdx` inject additional webpack loaders to compile files, but they omit the necessary loader for Fast Refresh to work. Instead of making these files deopt out of Fast Refresh, we can automatically detect and inject the loader in these cases. Fixes vercel#13574
Next.js plugins like `@next/mdx` inject additional webpack loaders to compile files, but they omit the necessary loader for Fast Refresh to work. Instead of making these files deopt out of Fast Refresh, we can automatically detect and inject the loader in these cases. Fixes #13574
Fixed in |
I can confirm it works with the latest canary. Thanks for the effort!! |
Just wanted to add I ran into this and then realized I had |
@gaearon is there a way to name non react component exports in a way that does not bail out react refresh? Maybe the babel plugin could ignore exports prefixed with |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
Instead of just replacing the contents, fast refresh performs a full page reload if it is an
.mdx
file.To Reproduce
git clone https://github.com/michel-kraemer/test-nextjs-fast-reload-mdx.git
cd test-nextjs-fast-reload-mdx
npm i
npm run dev
Hello World!
pages/index.mdx
pages/test.jsx
Expected behavior
Instead of reloading the full page, only the contents should be updated.
Screenshots
–
System information
Additional context
.mdx
file imports/exports aLayout
or not.The text was updated successfully, but these errors were encountered: