Skip to content

Docusaurus 3.8 #4607

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

Merged
merged 22 commits into from
May 27, 2025
Merged

Docusaurus 3.8 #4607

merged 22 commits into from
May 27, 2025

Conversation

slorber
Copy link
Contributor

@slorber slorber commented May 14, 2025

This PR upgrades the React Native website to Docusaurus 3.8:
https://docusaurus.io/blog/releases/3.8


Visual regression tests

I'm running visual regression tests from this PR: slorber/rnw-visual-tests#10

All the reported differences have been handled with little custom CSS changes.

Benchmarks

This release continues to improve build times significantly.

Bundling

Default:

  • Cold build: 37s
  • Warm rebuild: 17s

With the expensive optimization disabled:

  • Cold build: 19s
  • Warm rebuild: 3s

SSG

Before: 13s
After: 6s

Docusaurus Faster Impact

Here's the global updated impact of Docusaurus Faster on total build times, with all the flags on/off for the React Native website (including ~2k pages)

Setup Cold Build Warm Rebuild
❌ Docusaurus Slower (webpack) 120s (baseline) 33s (3.6 × faster)
✅ Docusaurus Faster (Rspack) 31s (3.8 × faster) 17s (7 × faster)

Copy link

netlify bot commented May 14, 2025

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit af4fe5f
🔍 Latest deploy log https://app.netlify.com/projects/react-native/deploys/6835910bab793e0008932c68
😎 Deploy Preview https://deploy-preview-4607--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Simek
Copy link
Collaborator

Simek commented May 19, 2025

Thanks @slorber! Looks like the bump induced some lint errors? I don't see them when running the check locally, on main.

@slorber
Copy link
Contributor Author

slorber commented May 20, 2025

Yes it looks related to the React types upgrade, I'm not sure your snack examples are compatible with React 19 types so we may need to upgrade to React 19 in a separate PR. Will figure it out later
CleanShot 2025-05-20 at 16 28 11

@slorber slorber marked this pull request as draft May 20, 2025 14:29
@slorber slorber changed the title Docusaurus 3.8 + React 19.1 Docusaurus 3.8 May 23, 2025
@slorber slorber marked this pull request as ready for review May 26, 2025 16:42
Copy link
Contributor Author

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to review, see my additional inline comments.

I'll release Docusaurus v3.8 tomorrow and then update the PR.

I fixed all the visual diffs that my tooling reported here: https://app.argos-ci.com/slorber/rnw-visual-tests

Normally this should look exactly as before

@@ -43,7 +43,6 @@
--ifm-table-border-color: var(--ifm-toc-border-color);
--ifm-table-cell-padding: 10px;
--ifm-table-stripe-background: rgba(0, 0, 0, 0.02);
--docusaurus-blog-social-icon-size: 16px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not used, and after introducing cascade layers, it became used and produced a visual diff that my tool caught.

The effective icon size on the RN website in prod is 17px, not 16px.

Comment on lines +163 to +177
function disableExpensiveBundlerOptimizationPlugin() {
return {
name: 'disable-expensive-bundler-optimizations',
configureWebpack(_config, isServer) {
// This optimization is expensive and only reduces by 3% the JS assets size
// Let's skip it for local and deploy preview builds
// See also https://github.com/facebook/docusaurus/discussions/11199
return {
optimization: {
concatenateModules: isProductionDeployment ? !isServer : false,
},
};
},
};
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional but this can significantly reduce build time for local production builds and deploy previews.

See also facebook/docusaurus#11199

See benchmarks with/without this optimization in the PR description.

Comment on lines +276 to +278
> :last-child {
margin-bottom: 0;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your site's custom CSS now overrides what comes from Infima and Docusaurus.

This broke our CSS rule that prevents an useless extra margin at the end of blockquote by default.

CleanShot 2025-05-26 at 18 29 55

I'm moving this rule here so that you can keep the same behavior:

Comment on lines +225 to 233
/*
Layer needed to override utility rules using !important in the Infima layer
See also https://css-tricks.com/css-cascade-layers/#aa-important-layers
*/
@layer docusaurus.infima.importantOverrides {
main[class^="docMainContainer"] > .container {
padding-top: 2rem !important;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our Infima utility types such as margin--xl use !important

Once layered, these rules can't be overridden by unlayered CSS, and you have to add your override directly to the Infima layer with !important to be able to override it.

All this is explained here: https://css-tricks.com/css-cascade-layers/#aa-important-layers.

This may seem annoying, but I think it makes sense. Utility classes serve to drive the styling from the markup. If you write margin--xl in the HTML, it's a bit weird if the final margin is not "xl" but another value due to an unexpected override. You can see this as a way to be explicit and say "hey, I know what I'm doing, and really want to override even if this is dangerous and can lead to unexpected behavior.

The proper way would be to swizzle the component and remove margin--xl for example, but I understand how it might feel more practical to just use CSS 🤪

PS: the name "importantOverrides doesn't matter much, what matters is that it's a "sub-layer" of Infima.

@Simek
Copy link
Collaborator

Simek commented May 26, 2025

@slorber Thanks for putting all of the work into migrating the website, and explaining all of the changes needed! 🙏

Tested the website locally, and on the PR preview, it looks and performs great!

@slorber
Copy link
Contributor Author

slorber commented May 27, 2025

Awesome!

v3.8 is out now, PR updated and ready to merge :)

@Simek Simek merged commit 1895ec8 into facebook:main May 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants