docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

[WIP]: Use Rspack instead of Webpack

Open slorber opened this issue 1 year ago โ€ข 5 comments

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 https://github.com/facebook/docusaurus/issues/4765#issuecomment-2066226942)

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: https://github.com/hardfist/docusaurus-rspack/pull/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

https://github.com/facebook/docusaurus/issues/4765

slorber avatar Aug 14 '24 11:08 slorber

โšก๏ธ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ ๐ŸŸ  73 ๐ŸŸข 98 ๐ŸŸข 96 ๐ŸŸข 100 Report
/docs/installation ๐ŸŸ  59 ๐ŸŸข 97 ๐ŸŸข 100 ๐ŸŸข 100 Report
/docs/category/getting-started ๐ŸŸ  74 ๐ŸŸข 100 ๐ŸŸข 100 ๐ŸŸ  86 Report
/blog ๐ŸŸ  63 ๐ŸŸข 96 ๐ŸŸข 100 ๐ŸŸ  86 Report
/blog/preparing-your-site-for-docusaurus-v3 ๐Ÿ”ด 48 ๐ŸŸข 92 ๐ŸŸข 100 ๐ŸŸข 100 Report
/blog/tags/release ๐ŸŸ  64 ๐ŸŸข 96 ๐ŸŸข 100 ๐ŸŸ  86 Report
/blog/tags ๐ŸŸ  74 ๐ŸŸข 100 ๐ŸŸข 100 ๐ŸŸ  86 Report

github-actions[bot] avatar Aug 14 '24 11:08 github-actions[bot]

[V2]

Name Link
Latest commit b02fb3ec59ee4b67fb5d10ba1d6a525a38dc24f3
Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6708db13c734350008fb3ec5
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.

netlify[bot] avatar Aug 14 '24 16:08 netlify[bot]

Size Change: +63.4 kB (+0.57%)

Total Size: 11.2 MB

Filename Size Change
website/build/assets/css/styles.********.css 120 kB +528 B (+0.44%)
website/build/assets/js/main.********.js 728 kB +61.8 kB (+9.28%) ๐Ÿ”
website/build/assets/js/runtime~main.********.js 35.8 kB +667 B (+1.9%)
โ„น๏ธ View Unchanged
Filename Size Change
website/.docusaurus/codeTranslations.json 2 B 0 B
website/.docusaurus/docusaurus.config.mjs 28 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 58.1 kB 0 B
website/build/blog/2017/12/14/introducing-docusaurus.html 72.2 kB 0 B
website/build/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus.html 45.1 kB +12 B (+0.03%)
website/build/blog/2018/09/11/Towards-Docusaurus-2.html 49.4 kB 0 B
website/build/blog/2018/12/14/Happy-First-Birthday-Slash.html 28.6 kB 0 B
website/build/blog/2019/12/30/docusaurus-2019-recap.html 37.5 kB -1 B (0%)
website/build/blog/2020/01/07/tribute-to-endi.html 32.1 kB 0 B
website/build/blog/2021/01/19/docusaurus-2020-recap.html 46.5 kB 0 B
website/build/blog/2021/03/09/releasing-docusaurus-i18n.html 42.9 kB -1 B (0%)
website/build/blog/2021/05/12/announcing-docusaurus-two-beta.html 45.2 kB 0 B
website/build/blog/2021/11/21/algolia-docsearch-migration.html 50.3 kB +12 B (+0.02%)
website/build/blog/2022/01/24/docusaurus-2021-recap.html 42.4 kB 0 B
website/build/blog/2022/08/01/announcing-docusaurus-2.0.html 134 kB 0 B
website/build/blog/2022/09/01/docusaurus-2.1.html 48.2 kB -1 B (0%)
website/build/blog/archive.html 23.1 kB 0 B
website/build/blog/authors.html 43.9 kB 0 B
website/build/blog/authors/j-marcey.html 61.9 kB 0 B
website/build/blog/authors/josh-cena.html 40.7 kB 0 B
website/build/blog/authors/lex-111.html 47.6 kB 0 B
website/build/blog/authors/slorber.html 58 kB 0 B
website/build/blog/authors/slorber/authors/2.html 61.8 kB 0 B
website/build/blog/authors/slorber/authors/3.html 73.6 kB 0 B
website/build/blog/authors/slorber/authors/4.html 42.1 kB 0 B
website/build/blog/authors/yangshun.html 54.8 kB 0 B
website/build/blog/authors/zpao.html 41.1 kB 0 B
website/build/blog/page/2.html 62.6 kB 0 B
website/build/blog/page/3.html 68.3 kB 0 B
website/build/blog/page/4.html 61.1 kB 0 B
website/build/blog/page/5.html 39.8 kB 0 B
website/build/blog/preparing-your-site-for-docusaurus-v3.html 132 kB +4 B (0%)
website/build/blog/releases/2.2.html 47.1 kB 0 B
website/build/blog/releases/2.3.html 57.9 kB 0 B
website/build/blog/releases/2.4.html 62.1 kB 0 B
website/build/blog/releases/3.0.html 107 kB +12 B (+0.01%)
website/build/blog/releases/3.1.html 49.5 kB +1 B (0%)
website/build/blog/releases/3.2.html 46.3 kB 0 B
website/build/blog/releases/3.3.html 52.9 kB 0 B
website/build/blog/releases/3.4.html 53.1 kB +7 B (+0.01%)
website/build/blog/releases/3.5.html 55.3 kB +1 B (0%)
website/build/blog/tags.html 26.7 kB 0 B
website/build/blog/upgrading-frontend-dependencies-with-confidence-using-visual-regression-testing.html 123 kB 0 B
website/build/docs.html 47 kB 0 B
website/build/docs/advanced.html 29.4 kB 0 B
website/build/docs/advanced/architecture.html 28.9 kB +4 B (+0.01%)
website/build/docs/advanced/client.html 72.7 kB 0 B
website/build/docs/advanced/plugins.html 56 kB 0 B
website/build/docs/advanced/routing.html 70.8 kB +8 B (+0.01%)
website/build/docs/advanced/ssg.html 77.8 kB 0 B
website/build/docs/api/docusaurus-config.html 194 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin.html 45.7 kB +4 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-html-links.html 36 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text.html 34.9 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading.html 36.2 kB +4 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages.html 39.8 kB 0 B
website/build/docs/api/misc/@docusaurus/logger.html 37.9 kB 0 B
website/build/docs/api/misc/create-docusaurus.html 33 kB 0 B
website/build/docs/api/plugin-methods.html 64.6 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/extend-infrastructure.html 60.2 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/i18n-lifecycles.html 58.1 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/lifecycle-apis.html 164 kB 0 B
website/build/docs/api/plugin-methods/static-methods.html 44.4 kB +4 B (+0.01%)
website/build/docs/api/plugins.html 29.9 kB 0 B
website/build/docs/api/plugins/@docusaurus/plugin-client-redirects.html 59.5 kB +13 B (+0.02%)
website/build/docs/api/plugins/@docusaurus/plugin-content-blog.html 189 kB 0 B
website/build/docs/api/plugins/@docusaurus/plugin-content-docs.html 194 kB +9 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-content-pages.html 74 kB 0 B
website/build/docs/api/plugins/@docusaurus/plugin-debug.html 48 kB 0 B
website/build/docs/api/plugins/@docusaurus/plugin-google-analytics.html 48.9 kB 0 B
website/build/docs/api/plugins/@docusaurus/plugin-google-gtag.html 48.5 kB -4 B (-0.01%)
website/build/docs/api/plugins/@docusaurus/plugin-google-tag-manager.html 47.3 kB 0 B
website/build/docs/api/plugins/@docusaurus/plugin-ideal-image.html 48.4 kB +4 B (+0.01%)
website/build/docs/api/plugins/@docusaurus/plugin-pwa.html 116 kB +4 B (0%)
website/build/docs/api/plugins/@docusaurus/plugin-sitemap.html 65.3 kB +6 B (+0.01%)
website/build/docs/api/plugins/@docusaurus/plugin-vercel-analytics.html 39.9 kB +12 B (+0.03%)
website/build/docs/api/themes.html 28.7 kB 0 B
website/build/docs/api/themes/@docusaurus/theme-classic.html 44 kB +4 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-live-codeblock.html 36.6 kB +4 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-mermaid.html 35.5 kB +4 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-search-algolia.html 32.8 kB 0 B
website/build/docs/api/themes/configuration.html 243 kB 0 B
website/build/docs/blog.html 211 kB +6 B (0%)
website/build/docs/browser-support.html 48.4 kB 0 B
website/build/docs/category/getting-started.html 26.6 kB 0 B
website/build/docs/category/guides.html 34.5 kB 0 B
website/build/docs/cli.html 59.9 kB +1 B (0%)
website/build/docs/configuration.html 98.7 kB +8 B (+0.01%)
website/build/docs/create-doc.html 62.3 kB +12 B (+0.02%)
website/build/docs/creating-pages.html 56.4 kB +1 B (0%)
website/build/docs/deployment.html 203 kB +8 B (0%)
website/build/docs/docs-introduction.html 50.9 kB 0 B
website/build/docs/docs-multi-instance.html 75 kB +4 B (+0.01%)
website/build/docs/docusaurus-core.html 236 kB 0 B
website/build/docs/guides/whats-next.html 30.9 kB 0 B
website/build/docs/i18n/crowdin.html 145 kB +12 B (+0.01%)
website/build/docs/i18n/git.html 78.8 kB +4 B (+0.01%)
website/build/docs/i18n/introduction.html 48.3 kB 0 B
website/build/docs/i18n/tutorial.html 164 kB +13 B (+0.01%)
website/build/docs/installation.html 70.7 kB +5 B (+0.01%)
website/build/docs/introduction/index.html 280 B 0 B
website/build/docs/markdown-features.html 79.9 kB +1 B (0%)
website/build/docs/markdown-features/admonitions.html 113 kB +4 B (0%)
website/build/docs/markdown-features/assets.html 89.2 kB +2 B (0%)
website/build/docs/markdown-features/code-blocks.html 235 kB +4 B (0%)
website/build/docs/markdown-features/diagrams.html 53.1 kB +14 B (+0.03%)
website/build/docs/markdown-features/head-metadata.html 50.1 kB 0 B
website/build/docs/markdown-features/links.html 40.8 kB 0 B
website/build/docs/markdown-features/math-equations.html 90.5 kB +11 B (+0.01%)
website/build/docs/markdown-features/plugins.html 96.6 kB +8 B (+0.01%)
website/build/docs/markdown-features/react.html 138 kB +5 B (0%)
website/build/docs/markdown-features/tabs.html 142 kB 0 B
website/build/docs/markdown-features/toc.html 84.8 kB +4 B (0%)
website/build/docs/migration.html 40.7 kB +4 B (+0.01%)
website/build/docs/migration/v2.html 39.1 kB 0 B
website/build/docs/migration/v2/automated.html 40.4 kB 0 B
website/build/docs/migration/v2/manual.html 198 kB 0 B
website/build/docs/migration/v2/translated-sites.html 50.3 kB 0 B
website/build/docs/migration/v2/versioned-sites.html 64.2 kB 0 B
website/build/docs/migration/v3.html 209 kB +1 B (0%)
website/build/docs/playground.html 30.7 kB 0 B
website/build/docs/resources/index.html 325 B 0 B
website/build/docs/search.html 116 kB +1 B (0%)
website/build/docs/seo.html 88.7 kB +13 B (+0.01%)
website/build/docs/sidebar.html 130 kB +4 B (0%)
website/build/docs/sidebar/autogenerated.html 150 kB +13 B (+0.01%)
website/build/docs/sidebar/items.html 180 kB 0 B
website/build/docs/sidebar/multiple-sidebars.html 63.7 kB +4 B (+0.01%)
website/build/docs/static-assets.html 53.4 kB +4 B (+0.01%)
website/build/docs/styling-layout.html 135 kB 0 B
website/build/docs/support/index.html 319 B 0 B
website/build/docs/swizzling.html 115 kB +14 B (+0.01%)
website/build/docs/team/index.html 310 B 0 B
website/build/docs/typescript-support.html 62.3 kB 0 B
website/build/docs/using-plugins.html 110 kB +13 B (+0.01%)
website/build/docs/versioning.html 83.1 kB +13 B (+0.02%)
website/build/index.html 35.8 kB 0 B

compressed-size-action

github-actions[bot] avatar Aug 14 '24 16:08 github-actions[bot]

The latest updates on your projects. Learn more about Argos notifications โ†—๏ธŽ

Build Status Details Updated (UTC)
default (Inspect) โš ๏ธ Changes detected (Review) 54 changed Dec 31, 2024, 11:13 PM

argos-ci[bot] avatar Aug 15 '24 15:08 argos-ci[bot]

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

tmpaul avatar Aug 30 '24 16:08 tmpaul

@tmpaul yes we obviously consider this, we even have a bot to warn us: https://github.com/facebook/docusaurus/pull/10402#issuecomment-2289272099

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.

slorber avatar Aug 31 '24 09:08 slorber

New and removed dependencies detected. Learn more about Socket for GitHub โ†—๏ธŽ

Package New capabilities Transitives Size Publisher
npm/[email protected] None 0 589 kB google-wombot
npm/[email protected] None 0 27.9 kB benjamn
npm/[email protected] None 0 135 kB benjamn
npm/[email protected] None 0 53.8 kB google-wombot
npm/[email protected] environment 0 15.1 kB rexxars
npm/[email protected] None 0 4.29 kB sindresorhus
npm/[email protected] None 0 65.7 kB jviereck
npm/[email protected] None 0 12.5 kB wooorm
npm/[email protected] None 0 31.4 kB stevenvachon
npm/[email protected] None 0 18.6 kB wooorm
npm/[email protected] None +2 185 kB rhysd
npm/[email protected] None 0 21.2 kB wooorm
npm/[email protected] None 0 21.4 kB wooorm
npm/[email protected] None 0 14.8 kB wooorm
npm/[email protected] None 0 19.5 kB wooorm
npm/[email protected] None 0 42.6 kB wooorm
npm/[email protected] None 0 19.6 kB wooorm
npm/[email protected] None 0 169 kB ariaminaei
npm/[email protected] unsafe 0 3.42 kB floatdrop
npm/[email protected] unsafe 0 11.3 kB felixge
npm/[email protected] None 0 8.56 kB 3rdeden
npm/[email protected] filesystem, unsafe 0 4.64 kB sindresorhus
npm/[email protected] environment 0 11.7 kB mjackson
npm/[email protected] None 0 5.55 kB sindresorhus
npm/[email protected] None 0 18.9 kB tim-kos
npm/[email protected] None 0 9.44 kB matteo.collina
npm/[email protected] filesystem +1 72.4 kB isaacs
npm/[email protected] None 0 26.9 kB shadiabuhilal
npm/[email protected] None 0 6.56 kB feross
npm/[email protected] None 0 31.7 kB feross
npm/[email protected] None 0 42.3 kB chalker
npm/[email protected] None 0 12.1 kB jonschlinkert
npm/[email protected] None 0 15.4 kB indutny
npm/[email protected] None 0 25.4 kB jfromaniello
npm/[email protected] None 0 5.17 kB sindresorhus
npm/[email protected] None 0 95.8 kB npm-cli-ops
npm/[email protected] filesystem, network 0 50.1 kB dougwilson
npm/[email protected] environment, filesystem 0 42.4 kB vercel-release-bot
npm/[email protected] filesystem, network +2 121 kB dougwilson
npm/[email protected] None 0 25.2 kB dougwilson
npm/[email protected] None +2 56.5 kB ljharb
npm/[email protected] None 0 4.03 kB wesleytodd
npm/[email protected] None 0 9.45 kB jonschlinkert
npm/[email protected] None 0 7.35 kB dashed
npm/[email protected] None 0 2.56 kB kevva
npm/[email protected] None 0 2.83 kB sindresorhus
npm/[email protected] None 0 45 kB ljharb
npm/[email protected] environment, filesystem 0 212 kB nfischer
npm/[email protected] None 0 23.2 kB ljharb
npm/[email protected] filesystem 0 20.7 kB lukeed
npm/[email protected] None 0 6.79 kB terkelg
npm/[email protected] None 0 4.74 kB sindresorhus
npm/[email protected] None 0 3.51 kB sindresorhus
npm/[email protected] None 0 10.4 kB blakeembrey
npm/[email protected] filesystem, network 0 82.8 kB brycekahle
npm/[email protected] filesystem 0 16.9 kB dutchenkooleg
npm/[email protected] None 0 140 kB 7rulnik
npm/[email protected] filesystem 0 85.2 kB linusu
npm/[email protected] None 0 805 kB tromey
npm/[email protected] None 0 7.75 kB wooorm
npm/[email protected] None 0 136 kB daviddias
npm/[email protected] network 0 57.7 kB indutny
npm/[email protected] None 0 34.8 kB alexei
npm/[email protected] None 0 12.1 kB dougwilson
npm/[email protected] None 0 26.2 kB pi0
npm/[email protected] None 0 14.4 kB matteo.collina
npm/[email protected] None 0 5.78 kB sindresorhus
npm/[email protected] None 0 23.8 kB wooorm
npm/[email protected] None 0 8.12 kB sindresorhus
npm/[email protected] None 0 4.03 kB sindresorhus
npm/[email protected] None 0 5.69 kB jonschlinkert
npm/[email protected] None 0 3.05 kB sindresorhus
npm/[email protected] None 0 41.3 kB remarkablemark
npm/[email protected] None 0 38.7 kB ludovicofischer
npm/[email protected] None 0 7.04 kB sindresorhus
npm/[email protected] None 0 9.18 kB ljharb
npm/[email protected] None 0 48.9 kB trysound
npm/[email protected] Transitive: environment +1 173 kB evilebottnawi
npm/[email protected] environment, eval 0 2.19 MB fabiosantoscode
npm/[email protected] None 0 11 kB substack
npm/[email protected] None 0 7.76 kB mafintosh
npm/[email protected] None 0 14.8 kB alexreardon
npm/[email protected] None 0 8.31 kB alexreardon
npm/[email protected] None 0 3.5 kB sindresorhus
npm/[email protected] None 0 22.9 kB jonschlinkert
npm/[email protected] None 0 4.68 kB dougwilson
npm/[email protected] filesystem 0 7.46 kB lukeed
npm/[email protected] None 0 7.49 kB wooorm
npm/[email protected] None 0 22.9 kB wooorm
npm/[email protected] None 0 84.9 kB typescript-bot
npm/[email protected] None 0 202 kB sindresorhus
npm/[email protected] None +1 36.8 kB dougwilson
npm/[email protected] None 0 8.84 kB feross
npm/[email protected] None 0 82.7 kB matteo.collina
npm/[email protected] None 0 5.01 kB google-wombot
npm/[email protected] None 0 3.25 kB mathias
npm/[email protected] None 0 5.05 kB google-wombot
npm/[email protected] None 0 25.7 kB google-wombot
npm/[email protected] None 0 5.98 kB google-wombot
npm/[email protected] None 0 2.79 kB sindresorhus
npm/[email protected] None 0 27.1 kB wooorm
npm/[email protected] None 0 11.9 kB wooorm
npm/[email protected] None 0 12.8 kB wooorm
npm/[email protected] None 0 11 kB wooorm
npm/[email protected] None 0 13.2 kB wooorm
npm/[email protected] None 0 32.9 kB wooorm
npm/[email protected] None 0 28.5 kB wooorm
npm/[email protected] None 0 4.67 kB ryanzim
npm/[email protected] environment, filesystem, shell 0 14.8 kB ai
npm/[email protected] environment 0 15.6 kB sindresorhus
npm/[email protected] None 0 470 kB garycourt
npm/[email protected] None 0 29.6 kB evilebottnawi
npm/[email protected] None 0 5.48 kB tootallnate
npm/[email protected] None 0 24.2 kB ariaminaei
npm/[email protected] None 0 64.3 kB piotrwitek
npm/[email protected] None 0 3.72 kB jaredhanson
npm/[email protected] None 0 116 kB ctavan
npm/[email protected] environment 0 7.91 kB mjackson
npm/[email protected] None 0 8.75 kB dougwilson
npm/[email protected] None 0 13.1 kB wooorm
npm/[email protected] None 0 22.3 kB wooorm
npm/[email protected] environment, filesystem 0 56.4 kB evilebottnawi
npm/[email protected] None 0 7.44 kB wooorm
npm/[email protected] environment, filesystem, network +2 1.78 MB valscion
npm/[email protected] filesystem +1 266 kB evilebottnawi
npm/[email protected] environment, eval, network Transitive: filesystem, shell +2 713 kB evilebottnawi
npm/[email protected] None 0 47.9 kB bebraw
npm/[email protected] None 0 91.3 kB sokra
npm/[email protected] environment, filesystem, network, unsafe +1 5.05 MB evilebottnawi
npm/[email protected] environment 0 134 kB pi0
npm/[email protected] None 0 55 kB jcoglan
npm/[email protected] environment 0 9.97 kB isaacs
npm/[email protected] None 0 3.33 kB sindresorhus
npm/[email protected] None 0 13.5 kB damonoehlman
npm/[email protected] None 0 11.8 kB sindresorhus
npm/[email protected] None 0 2.96 kB zkat
npm/[email protected] filesystem 0 12.8 kB isaacs
npm/[email protected] network 0 122 kB lpinca
npm/[email protected] None 0 14.8 kB isaacs
npm/[email protected] environment 0 448 kB eemeli
npm/[email protected] None 0 6.03 kB sindresorhus
npm/[email protected] None 0 13.8 kB wooorm

๐Ÿšฎ Removed packages: npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@algolia/[email protected], npm/@docsearch/[email protected], npm/@docsearch/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@docusaurus/[email protected], npm/@mdx-js/[email protected], npm/@pnpm/[email protected], npm/@pnpm/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full reportโ†—๏ธŽ

socket-security[bot] avatar Oct 11 '24 08:10 socket-security[bot]

Rspack support is now good enough to merge ๐ŸŽ‰

Note that the Rspack bundles are still a bit larger than Webpack:

CleanShot 2024-10-11 at 10 46 21

This is actively being worked on and will be fixed later as part of:

  • https://github.com/web-infra-dev/rspack/issues/5316
  • https://github.com/web-infra-dev/rspack/pull/7764

slorber avatar Oct 11 '24 08:10 slorber

@slorber How could I go about adjusting the rspack config when rspackBundler is enabled? We use the @stoplight/elements package for openapi docs, which required a custom webpack config plugin to use the NodePolyfillPlugin().

It appears I need to disable this custom webpack plugin to use rspackBundler. However, once I disable the webpack plugin, our openapi docs stop working with the error: process is not defined.

It looks like rspack has a similar config using the same polyfill, and I'm wondering how I can include this with the Docusaurus rspack config.

Here's a link to our repo where I currently have the custom webpack config. I would like to replace this plugin with a custom rspack plugin using the same polyfill.

JKarlavige avatar Jan 30 '25 15:01 JKarlavige

@JKarlavige the configureWebpack plugin lifecycle hook still applies to Rspack, since it's an almost drop-in replacement, that lifecycle can be used to configure both bundlers.

You didn't share why you need to disable your Webpack plugin. If you get an error with the custom plugin, please share the error message.

Most likely, this is because of webpack.DefinePlugin, as explained here: https://github.com/facebook/docusaurus/issues/10572

Your node polyfill is compatible with Rspack: https://github.com/Richienb/node-polyfill-webpack-plugin/releases/tag/v3.0.0

But your Docusaurus plugin is not. Here's likely the solution:

- const webpack = require('webpack');
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")

// Adds custom configurations to webpack
module.exports = function customWebpackConfigPlugin() {
  return {
    name: 'docusaurus-custom-webpack-config-plugin',
-   configureWebpack() {   
+   configureWebpack(config, isServer, {currentBundler}) {
      return {        
        resolve: {     
          fallback: {
            "fs": false,
            "path": require.resolve("path-browserify"),
            "http": require.resolve("stream-http"),
            "tty": require.resolve("tty-browserify"),
          }
        },
        plugins: [
-         new webpack.DefinePlugin({
+         new currentBundler.instance.DefinePlugin({
            'process.versions.node': JSON.stringify(
              process.versions.node || '0.0.0',
            ),
          }),
          new NodePolyfillPlugin({}),
        ],
        module: {
          rules: [
            { test: /\.py$/, loader: 'raw-loader' }
          ]
        }
      }
    }
  }
}

slorber avatar Jan 30 '25 16:01 slorber

@slorber I appreciate the help. Here is the error I receive when starting the dev server, and I receive the same error on builds. I tried replacing webpack with currentBundler based on your edits above but I still hit the same error. If I comment out the entire custom webpack plugin, the error goes away.

[webpack-dev-middleware] [Error:   ร— TypeError: Cannot read properties of undefined (reading 'set')
<e>   โ”‚     at Object.fn (/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/webpack/lib/ProvidePlugin.js:43:37)
<e>   โ”‚     at SyncHook.callAsyncStageRange (/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/@rspack/lite-tapable/dist/index.js:240:21)
<e>   โ”‚     at SyncHook.callStageRange (/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/@rspack/lite-tapable/dist/index.js:259:14)
<e>   โ”‚     at QueriedHook.call (/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/@rspack/lite-tapable/dist/index.js:218:26)
<e>   โ”‚     at /Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/@docusaurus/faster/node_modules/@rspack/core/dist/index.js:13987:28
<e>   โ”‚     at last.function (/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/@docusaurus/faster/node_modules/@rspack/core/dist/index.js:14696:25)
<e>   โ”‚ 
<e> ] {
<e>   code: 'GenericFailure'
<e> }

And here is the state of the custom webpack plugin after the edits:

const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")

// Adds custom configurations to webpack
module.exports = function customWebpackConfigPlugin() {
  return {
    name: "docusaurus-custom-webpack-config-plugin",
    configureWebpack(config, isServer, { currentBundler }) {
      return {
        resolve: {
          fallback: {
            fs: false,
            path: require.resolve("path-browserify"),
            http: require.resolve("stream-http"),
            tty: require.resolve("tty-browserify"),
          },
        },
        plugins: [
          new currentBundler.instance.DefinePlugin({
            "process.versions.node": JSON.stringify(
              process.versions.node || "0.0.0"
            ),
          }),
          new NodePolyfillPlugin({}),
        ],
        module: {
          rules: [{ test: /\.py$/, loader: "raw-loader" }],
        },
      };
    },
  };
}

JKarlavige avatar Jan 30 '25 17:01 JKarlavige

@JKarlavige cf the release notes I linked above: https://github.com/Richienb/node-polyfill-webpack-plugin/releases/tag/v3.0.0

This Webpack plugin is only compatible with Rspack starting v3+.

You didn't upgrade it, and you are still on v1 (incompatible).

Webpack plugins also need to be compatible with Rspack, following similar practices (avoiding static imports from the webpack npm packages).

See https://github.com/Richienb/node-polyfill-webpack-plugin/pull/48/files

slorber avatar Jan 30 '25 17:01 slorber

@slorber Good call, upgrading the polyfill package fixed that specific error.

However, I assume upgrading the node-polyfill-webpack-plugin introduced other breaking changes in our custom webpack config, as i'm receiving a new error below. This occurs even with rspackBundler disabled, and with our axios package updated to the latest version. Ughhh, frustrating. I think i've just been looking at this too long.

ERROR in ./node_modules/axios/lib/helpers/toFormData.js 128:73-79
Module not found: Error: Can't resolve '/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/buffer' in '/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/axios/lib/helpers'
Did you mean 'index.js'?
BREAKING CHANGE: The request '/Users/jasonkarlavige/Documents/Code/repos/docs.getdbt.com/website/node_modules/buffer' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
ERROR in ./node_modules/axios/lib/helpers/toFormData.js
Cannot read properties of undefined (reading 'module')

JKarlavige avatar Jan 30 '25 18:01 JKarlavige

I don't know what this problem is but that doesn't really seem related to Docusaurus.

Most likely you need to handle the potential breaking changes of the webpack plugin you upgrade. I'd recommend upgrading first in a separate PR. Maybe you just need to add extra polyfills to your config, I don't know

slorber avatar Jan 30 '25 19:01 slorber

Yeah for sure, it seems like a separate issue with our webpack config, which admittedly I am not the most familiar with. Doesn't appear to be specific to Docusaurus, and i'll keep digging into resolving the current error. Thanks again for your help!

JKarlavige avatar Jan 30 '25 20:01 JKarlavige