"The code generator has deoptimised the styling of", with preset stating "compact: true"
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the
npm run clearoryarn clearcommand. - [X] I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).
Description
When building Docusaurus (2, rc1)...
The log gets spammed with:
The code generator has deoptimised the styling of errors for large files.
This is odd, as the default babel.config.js gets applied:
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
The preset code I found, indicates that Docusaurus enforces:
compact: true
Which should mean the above error should never appear, yet it does?
Reproducible demo
No response
Steps to reproduce
- Have big md files with lots of html code
- Build docusaurus
Expected behavior
Afaik it should not throw this warning and compact big files as well
Actual behavior
Throws above warning
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
- [X] I'd be willing to fix this bug myself.
This is working as expected—the code generator cannot possibly optimize huge files because it would require too much memory. Without a reproduction or the detailed error message I cannot tell you where the limit lies, but the limit is always there. There's nothing done specially by Docusaurus. We have huge files (the CHANGELOG.md) and the compiler is de-optimizing it as well. That's just part of the normal build toolchain.
Unless more information is provided about how that tangibly creates problems and more importantly how Docusaurus is actually involved in this process (remember we delegate a lot of the building process to external tools like Babel, Webpack, PostCSS, and Terser), I'm going to close this as wontfix.
(I see you are pointing to compact: true, but I'm pretty sure it's done by MDX, not Babel. Last time I investigated, MDX v1 has its own Babel tooling to transform the MD documents, and that one is tangential from our config.)
(I see you are pointing to
compact: true, but I'm pretty sure it's done by MDX, not Babel. Last time I investigated, MDX v1 has its own Babel tooling to transform the MD documents, and that one is tangential from our config.)
Thank you, that explains why it states to be a babel error, yet that error is not possible with the preset given on the main babel instance.. :)
MDX is doing a lot of Babel stuff under the hood. This is removed in MDX v2. We'll hopefully be migrating to MDX v2 in Docusaurus v3 (see #4029), at which time we can re-experiment with large files.