-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Converting site from remark to mdx increases compile and build times up to 8x #17443
Comments
I am having the same problem as you. However, as I am working with a lot of files (thousands of them and some of them are thousands of lines long), it is a blocker for me (as I cannot afford to have 40min+ build times). It also seems to me, that the cache mechanism just does not work with so many files - as whatever I change, It always starts the build process and re-generation of cache again. Btw. I am also encountering the same Babel message (Error) and it drives me crazy - as I cannot get rid of it by any of these:
I also posted the problem to the similar issue in |
@johno Let me know if I can try and help implement the static flag for MDX elements you mentioned at Gatsby Days London. Also, how difficult do you think it would be to convert or extend |
@Mrazator can you include which plugins you're using?
This definitely sounds like a bug since we shouldn't need to rebuild the entire cache when a single file changes 🤔
This typically only occurs with plugins that add a large amount of DOM nodes to the document (which we've only seen from syntax highlighting plugins so far).
I'll set aside some time this week to write up an RFC so we can discuss implementation 👍
@janosh I'm not very familiar with I'll be digging into this issue over the next week and see what the bottlenecks are. MDX is doing a lot more so it will result in longer build times, but it shouldn't be this significant so we'll look into optimizations to get the times down. There hasn't been much work done in this area so there's prolly some low hanging fruit. |
I'm confused now. How is the compositional approach related to running on the client? I thought the benefit of composition would stem from not ending up with a large number of DOM nodes generated by some |
The compositional approach occurs via the MDXProvider so it is rendered on the server during build and on the client after rehydration. It becomes part of the site's bundle. This is why we require a "static" mechanism where we can "compile away" the client portion (which was what we discussed a bit in person last week). Not sure if that clarified things or not? |
It certainly helped. I guess I need to do a little more reading to understand how MDX really works... |
Thanks for quick response.
Here you go:
I tested it without using prismjs and emotions, and still have the same problem. Maybe the actual document is just too big (6K+ lines)? |
Hmmm, the compiled output of a 6k line document should be much less than 500KB if prismjs is turned off. Do you mind creating a minimal reproduction I could debug @Mrazator? |
I will try to do it asap :) |
JFYI @johno I partially "solved" the problem by splitting those big files into smaller ones. |
I just ported my entire personal site from Remark to MDX. Compile times went from 17 sec (Remark) to 135 sec (MDX) and build times increased from 32 sec to 193 sec (in each case as measured by an actual clock).
This is way more than I expected so I was wondering if perhaps I did something wrong in following the MDX guide and if there is potential for easy optimization.
Relevant information
Here's the commit that made the transition.
Environment
Perhaps related
I also started getting a bunch of messages during the build process:
The text was updated successfully, but these errors were encountered: