[WIP]: Use Rspack instead of Webpack
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 startworks for the Docusaurus website ๐ -
yarn buildworks 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
โก๏ธ 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 |
[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...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
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 |
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 |
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 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.
New and removed dependencies detected. Learn more about Socket for GitHub โ๏ธ
๐ฎ 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]
Rspack support is now good enough to merge ๐
Note that the Rspack bundles are still a bit larger than Webpack:
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 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 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 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 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 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')
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
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!