Skip to content
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

[WIP]: Use Rspack instead of Webpack #10402

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft

[WIP]: Use Rspack instead of Webpack #10402

wants to merge 36 commits into from

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Aug 14, 2024

Disclaimer

For now, this is only a POC to see how complicated it would be to switch bundlers or provide an alternative bundler as an experimental flag. We also hope to measure possible performance improvements.

We don't have a real plan yet.

Motivation

Rspack is mostly retro-compatible with Webpack and the most suitable choice for Docusaurus in the short term (see also #4765 (comment))

This should improve bundling performance, the main bottleneck for many sites.

State

The current state of this PR:

  • yarn start works for the Docusaurus website 🎉
  • yarn build works for the Docusaurus website 🎉

But we are not done, there are many details to handle before it becomes usable. For example, restoring the ChunkAssetPlugin)

Note: the Rspack team is willing to help us and most of the initial POC code is inspired by @hardfist patch on our init template here: hardfist/docusaurus-rspack#1

Performance

Approximate build time measurements taken on a local MacBook pro M3 on 14 August :

For yarn build:website:fast:

  • Rspack: 36s (bundling 26s, SSG 5s)
  • Webpack: 57s (bundling 47s, SSG 6s)

For yarn build:website --locale en:

  • Rspack: 66s (bundling 43s, SSG 17s)
  • Webpack: 98 (bundling 72s, SSG 20s)

Note: these measures involve running yarn clear:website first. Rspack does not support (yet) persistent caching like Webpack.

Note: these results are not final, and ballpark estimates. They may change in the future.

Surprisingly, it seems to improve the SSG performance too. We'll have to figure out why, maybe the server output is more optimized.

Test Plan

CI

Test links

https://deploy-preview-10402--docusaurus-2.netlify.app/

Related issues/PRs

#4765

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 14, 2024
Copy link

github-actions bot commented Aug 14, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 85 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 60 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 74 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 67 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🔴 48 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 63 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟠 86 Report

Copy link

netlify bot commented Aug 14, 2024

[V2]

Name Link
🔨 Latest commit 0739fce
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/66e47561f48f9d0008af03d6
😎 Deploy Preview https://deploy-preview-10402--docusaurus-2.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 site configuration.

Copy link

github-actions bot commented Aug 14, 2024

Size Change: -133 kB (-1.15%)

Total Size: 11.4 MB

Filename Size Change
website/build/assets/css/styles.********.css 122 kB +8.95 kB (+7.91%) 🔍
website/build/assets/js/main.********.js 704 kB +37.9 kB (+5.69%) 🔍
website/build/assets/js/runtime~main.********.js 24.8 kB -10.2 kB (-29.18%) 🎉
website/build/blog/2017/12/14/introducing-docusaurus.html 74.1 kB -657 B (-0.88%)
website/build/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus.html 46.5 kB -811 B (-1.71%)
website/build/blog/2022/09/01/docusaurus-2.1.html 50.3 kB -574 B (-1.13%)
website/build/blog/preparing-your-site-for-docusaurus-v3.html 130 kB -8.26 kB (-5.98%)
website/build/blog/releases/2.4.html 64.3 kB -993 B (-1.52%)
website/build/blog/releases/3.0.html 102 kB -9.77 kB (-8.77%)
website/build/blog/upgrading-frontend-dependencies-with-confidence-using-visual-regression-testing.html 128 kB -250 B (-0.2%)
website/build/docs.html 49.3 kB -60 B (-0.12%)
website/build/docs/advanced/routing.html 68.8 kB -5.06 kB (-6.85%)
website/build/docs/advanced/ssg.html 79.6 kB -1.91 kB (-2.35%)
website/build/docs/api/docusaurus-config.html 202 kB -456 B (-0.23%)
website/build/docs/api/misc/@docusaurus/eslint-plugin.html 45.9 kB -2.44 kB (-5.06%)
website/build/docs/api/misc/create-docusaurus.html 34.3 kB -531 B (-1.52%)
website/build/docs/api/plugins/@docusaurus/plugin-client-redirects.html 62 kB -535 B (-0.86%)
website/build/docs/api/plugins/@docusaurus/plugin-content-blog.html 197 kB -939 B (-0.47%)
website/build/docs/api/plugins/@docusaurus/plugin-content-docs.html 201 kB -943 B (-0.47%)
website/build/docs/api/plugins/@docusaurus/plugin-content-pages.html 77.2 kB -844 B (-1.08%)
website/build/docs/api/plugins/@docusaurus/plugin-debug.html 50 kB -548 B (-1.08%)
website/build/docs/api/plugins/@docusaurus/plugin-google-analytics.html 50.9 kB -548 B (-1.06%)
website/build/docs/api/plugins/@docusaurus/plugin-google-gtag.html 50.5 kB -552 B (-1.08%)
website/build/docs/api/plugins/@docusaurus/plugin-google-tag-manager.html 49.2 kB -548 B (-1.1%)
website/build/docs/api/plugins/@docusaurus/plugin-ideal-image.html 50.6 kB -544 B (-1.06%)
website/build/docs/api/plugins/@docusaurus/plugin-pwa.html 109 kB -12.8 kB (-10.54%) 👏
website/build/docs/api/plugins/@docusaurus/plugin-sitemap.html 67.9 kB -542 B (-0.79%)
website/build/docs/api/plugins/@docusaurus/plugin-vercel-analytics.html 41.7 kB -536 B (-1.27%)
website/build/docs/api/themes/@docusaurus/theme-classic.html 45.8 kB -544 B (-1.17%)
website/build/docs/api/themes/@docusaurus/theme-live-codeblock.html 38.1 kB -544 B (-1.41%)
website/build/docs/api/themes/@docusaurus/theme-mermaid.html 37 kB -544 B (-1.45%)
website/build/docs/api/themes/@docusaurus/theme-search-algolia.html 34.2 kB -548 B (-1.58%)
website/build/docs/api/themes/configuration.html 256 kB -289 B (-0.11%)
website/build/docs/blog.html 219 kB -182 B (-0.08%)
website/build/docs/browser-support.html 48.4 kB -2.6 kB (-5.1%)
website/build/docs/cli.html 56.6 kB -7.15 kB (-11.21%) 👏
website/build/docs/create-doc.html 64.9 kB -406 B (-0.62%)
website/build/docs/creating-pages.html 59 kB -67 B (-0.11%)
website/build/docs/deployment.html 207 kB -4.85 kB (-2.29%)
website/build/docs/docs-multi-instance.html 77.5 kB -1.26 kB (-1.6%)
website/build/docs/i18n/crowdin.html 147 kB -3.61 kB (-2.4%)
website/build/docs/i18n/git.html 77.8 kB -4.88 kB (-5.9%)
website/build/docs/i18n/introduction.html 48 kB -2.74 kB (-5.4%)
website/build/docs/i18n/tutorial.html 160 kB -11.2 kB (-6.52%)
website/build/docs/installation.html 69.6 kB -3.38 kB (-4.64%)
website/build/docs/markdown-features/code-blocks.html 240 kB -4.77 kB (-1.95%)
website/build/docs/markdown-features/diagrams.html 55.5 kB -534 B (-0.95%)
website/build/docs/markdown-features/math-equations.html 92.1 kB -3.32 kB (-3.48%)
website/build/docs/markdown-features/plugins.html 100 kB -540 B (-0.53%)
website/build/docs/markdown-features/react.html 135 kB -8.2 kB (-5.71%)
website/build/docs/migration.html 41.3 kB -1.76 kB (-4.09%)
website/build/docs/migration/v2/automated.html 40.8 kB -1.85 kB (-4.33%)
website/build/docs/migration/v2/manual.html 196 kB -10.9 kB (-5.28%)
website/build/docs/migration/v2/versioned-sites.html 63.9 kB -3.3 kB (-4.9%)
website/build/docs/migration/v3.html 200 kB -17.8 kB (-8.16%)
website/build/docs/search.html 119 kB -1.89 kB (-1.57%)
website/build/docs/sidebar/autogenerated.html 153 kB -3.45 kB (-2.21%)
website/build/docs/styling-layout.html 139 kB -2.3 kB (-1.63%)
website/build/docs/swizzling.html 116 kB -4.68 kB (-3.89%)
website/build/docs/typescript-support.html 63.4 kB -1.99 kB (-3.04%)
website/build/docs/using-plugins.html 114 kB -1.08 kB (-0.94%)
website/build/docs/versioning.html 82.1 kB -5 kB (-5.74%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/codeTranslations.json 2 B 0 B
website/.docusaurus/docusaurus.config.mjs 27.9 kB 0 B
website/.docusaurus/globalData.json 30.2 kB 0 B
website/.docusaurus/i18n.json 930 B 0 B
website/.docusaurus/registry.js 155 kB 0 B
website/.docusaurus/routes.js 74.3 kB 0 B
website/.docusaurus/routesChunkNames.json 81.7 kB 0 B
website/.docusaurus/site-metadata.json 2.17 kB 0 B
website/build/blog.html 61.4 kB 0 B
website/build/blog/2018/09/11/Towards-Docusaurus-2.html 51.7 kB +12 B (+0.02%)
website/build/blog/2018/12/14/Happy-First-Birthday-Slash.html 30.4 kB -1 B (0%)
website/build/blog/2019/12/30/docusaurus-2019-recap.html 39.6 kB -1 B (0%)
website/build/blog/2020/01/07/tribute-to-endi.html 34 kB -1 B (0%)
website/build/blog/2021/01/19/docusaurus-2020-recap.html 48.9 kB -1 B (0%)
website/build/blog/2021/03/09/releasing-docusaurus-i18n.html 45.1 kB -1 B (0%)
website/build/blog/2021/05/12/announcing-docusaurus-two-beta.html 47.5 kB -1 B (0%)
website/build/blog/2021/11/21/algolia-docsearch-migration.html 53 kB +12 B (+0.02%)
website/build/blog/2022/01/24/docusaurus-2021-recap.html 44.5 kB -1 B (0%)
website/build/blog/2022/08/01/announcing-docusaurus-2.0.html 139 kB -1 B (0%)
website/build/blog/archive.html 24.7 kB 0 B
website/build/blog/authors.html 46.5 kB 0 B
website/build/blog/authors/j-marcey.html 65 kB 0 B
website/build/blog/authors/josh-cena.html 43 kB 0 B
website/build/blog/authors/lex-111.html 50.2 kB 0 B
website/build/blog/authors/slorber.html 61.5 kB 0 B
website/build/blog/authors/slorber/authors/2.html 65.4 kB 0 B
website/build/blog/authors/slorber/authors/3.html 77.7 kB 0 B
website/build/blog/authors/slorber/authors/4.html 44.7 kB 0 B
website/build/blog/authors/yangshun.html 57.8 kB 0 B
website/build/blog/authors/zpao.html 43.5 kB 0 B
website/build/blog/page/2.html 66 kB 0 B
website/build/blog/page/3.html 71.7 kB 0 B
website/build/blog/page/4.html 64.2 kB 0 B
website/build/blog/page/5.html 41.9 kB 0 B
website/build/blog/releases/2.2.html 49.6 kB 0 B
website/build/blog/releases/2.3.html 60.8 kB 0 B
website/build/blog/releases/3.1.html 52 kB +1 B (0%)
website/build/blog/releases/3.2.html 48.8 kB 0 B
website/build/blog/releases/3.3.html 55.5 kB 0 B
website/build/blog/releases/3.4.html 55.8 kB +7 B (+0.01%)
website/build/blog/releases/3.5.html 58.1 kB +1 B (0%)
website/build/blog/tags.html 28.6 kB 0 B
website/build/docs/advanced.html 31.1 kB 0 B
website/build/docs/advanced/architecture.html 30.7 kB +4 B (+0.01%)
website/build/docs/advanced/client.html 76 kB 0 B
website/build/docs/advanced/plugins.html 58.6 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-html-links.html 38.1 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text.html 37 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading.html 38.3 kB +4 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages.html 41.9 kB 0 B
website/build/docs/api/misc/@docusaurus/logger.html 39.8 kB 0 B
website/build/docs/api/plugin-methods.html 67.4 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/extend-infrastructure.html 63 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/i18n-lifecycles.html 60.7 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/lifecycle-apis.html 170 kB 0 B
website/build/docs/api/plugin-methods/static-methods.html 46.5 kB +4 B (+0.01%)
website/build/docs/api/plugins.html 31.7 kB 0 B
website/build/docs/api/themes.html 30.4 kB 0 B
website/build/docs/category/getting-started.html 28.3 kB 0 B
website/build/docs/category/guides.html 36.4 kB 0 B
website/build/docs/configuration.html 98.5 kB +4 B (0%)
website/build/docs/docs-introduction.html 53.6 kB 0 B
website/build/docs/docusaurus-core.html 245 kB 0 B
website/build/docs/guides/whats-next.html 32.8 kB 0 B
website/build/docs/introduction/index.html 280 B 0 B
website/build/docs/markdown-features.html 83.2 kB +1 B (0%)
website/build/docs/markdown-features/admonitions.html 119 kB +4 B (0%)
website/build/docs/markdown-features/assets.html 93.5 kB +2 B (0%)
website/build/docs/markdown-features/head-metadata.html 52.8 kB 0 B
website/build/docs/markdown-features/links.html 43.1 kB 0 B
website/build/docs/markdown-features/tabs.html 148 kB 0 B
website/build/docs/markdown-features/toc.html 88.8 kB +4 B (0%)
website/build/docs/migration/v2.html 41.3 kB 0 B
website/build/docs/migration/v2/translated-sites.html 52.8 kB 0 B
website/build/docs/playground.html 32.5 kB 0 B
website/build/docs/resources/index.html 325 B 0 B
website/build/docs/seo.html 93 kB +13 B (+0.01%)
website/build/docs/sidebar.html 136 kB +4 B (0%)
website/build/docs/sidebar/items.html 188 kB 0 B
website/build/docs/sidebar/multiple-sidebars.html 67.1 kB +4 B (+0.01%)
website/build/docs/static-assets.html 56.3 kB +4 B (+0.01%)
website/build/docs/support/index.html 319 B 0 B
website/build/docs/team/index.html 310 B 0 B
website/build/index.html 37.8 kB 0 B

compressed-size-action

@slorber slorber added the Argos Add this label to run UI visual regression tests. See argos.yml GH action. label Aug 15, 2024
Copy link

argos-ci bot commented Aug 15, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 156 removed Sep 15, 2024, 2:19 PM

@tmpaul
Copy link

tmpaul commented Aug 30, 2024

Are you considering runtime sizes as well before proceeding with this migration ? It seems that the bundler community is solely focused on who's faster (farmfe/rspack/turbopack etc), while almost no attention is being paid to the actual runtime javascript sizes whatsoever. Even rspack's documentation is very vague on what it does exactly to reduce the code size compared to webpack 5. I'm posting the measured network size (Chrome devtools Network tab) for the preview link vs the main branch. I do realize that this PR is behind the main branch, so the numbers might vary when the PR is updated. But here is what I see:

Rspack PoC (netlify URL)

JS: 9 requests, 1.0 MB compressed, 2.7 MB uncompressed
CSS: 2 requests, 26.8 KB compressed, 135 KB uncompressed
Total: 1050 Kb compressed, 2900 KB uncompressed

Webpack 5 (docusarus.io)

JS: 10 requests, 981 KB compressed, 2.0 MB uncompressed
CSS: 2 requests, 30.3 KB compressed, 136 KB uncompressed
Total: 1011.3 KB compressed, 2184 KB uncompressed

If we assume that the "base" is the same, there is a ~716 KB (minified) diff between webpack and rspack. Feel free to adjust the numbers after a rebase, but this is definitely concerning.

I appreciate the build time perf boost. It is quite important. But we must not forget that there is a lot more to performance than pure blind speed. I cannot see any concrete numbers or benchmarks around "runtime" sizes either. Most comparisons are based on webpack-bundle-analyzer, which is incorrect since the splitChunks configuration can affect which chunks are loaded on a route, and not all chunks in the analyzer are loaded for a given route. Build time static size analysis is not the right metric imo. Curious to hear your thoughts

@slorber
Copy link
Collaborator Author

slorber commented Aug 31, 2024

@tmpaul yes we obviously consider this, we even have a bot to warn us:
#10402 (comment)

And bundler authors as well
https://rspack.dev/blog/announcing-1-0#smaller-bundle-size

This is why this PR is a draft POC, it's not ready to merge. We are already aware of that code splitting problem.

Most likely we'll provide an experimental feature flag to turn Rspack on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Argos Add this label to run UI visual regression tests. See argos.yml GH action. CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants