[DRAFT] feat! replace webpack by rsbuild for faster build#252
[DRAFT] feat! replace webpack by rsbuild for faster build#252
Conversation
|
Is there anything you found that doesn't work / isn't supported by rsbuild? If not, we should just replace it everywhere and not just for tutor-mfe. |
No, I haven't. That's because there's nothing magical with our MFEs: they are just frontend code, bundled as regular js/html/css/images etc. That being said, I haven't extensively tested the 10 officially maintained MFEs, so it's quite possible I missed some issues.
I'm not sure anymore about that. While I worked on this project, I discovered some places where the webpack abstraction leaked into the MFE codebase, and that really feels like an anti-pattern. Instead, I now think that we should remove all of the build code from all MFE. There shouldn't be any MFE-specific build step. There should be a simple, documented standard to build any MFE. And we should be able to run something like |
Note that the locked cache in `rsbuild build` prevents concurrent builds. This means that we no longer have to limit the parallelism of the Docker builder, as we used to: https://docs.tutor.edly.io/troubleshooting.html#high-resource-consumption-by-docker-on-tutor-images-build
This makes sense to me, and I think it may even have been the original idea behind |
|
I tested this out on an Arm64 machine (M1 Macbook) and it seems that the rsbuild step breaks on arm64 native images. Here's the traceback: I then tried it out by building it using the amd64 platform using the command: The results were impressive nonetheless even with amd64 emulation with the build layers taking 2-3x less time than when we were using webpack. |
|
Thanks for testing @Danyal-Faheem! Would you mind trying out debugging with |
|
@regisb, Running with both |
|
I tested this branch on Macbook M2 and got the same error as Danyal mentioned above #252 (comment). However, even when I specified the platform (amd/64) in build argument, the build process did not complete and gave the same error. npm connection errors were happening as well, which has been more prominent than other build issues for me (even though I am using max2cpu config). I am adding some stats below:
|
|
I was able to reproduce the issue by building on a remote arm64 server: The issue disappears when I disable the cache, which is tagged as "experimental". So what I did was to disable caching on arm64. I also filed the following upstream issue: web-infra-dev/rspack#10118 Thus, Apple users should now be able to test this PR again. 👀 @Danyal-Faheem @DawoudSheraz |
Caching should be disabled on this platform until the following issue is resolved: web-infra-dev/rspack#10118
|
@regisb I tested it with the updated commits and It's building on arm64 natively now! The results are also impressive: Running with a max-parallelism of 2 (I had to do this otherwise the Some stats: Build Time Comparison
I think this is really impressive but we will have to make changes to the |
|
@regisb , have rsbuild efforts ceased completely? I see openedx/frontend-app-learner-dashboard#598 looked like it was very close but was closed waiting for feedback. Is there anything someone could/should do to pick this back up again? |
|
@AntonOfTheWoods Unfortunately I no longer have time to focus on this project. The learner dashboard PR you pointed to was just the tip of the iceberg: it was a prerequisite to rsbuild compatibility, but not the actual switch. I failed to get buy-in from members of the frontend working group and grew discouraged about this effort. |
|
Thanks for the quick response @regisb ! From the look of that PR, the majority of the changes almost looked like "best practice" changes (basically mostly just adding an alias for module resolution, right?), and that may no longer be a requirement for migrating to rspack if Mr Gemini is to be believed. I guess the unstoppable juggernaut of The JS ecosystem really is a marvel of humanity - half want to stick to obsolete horrors like webpack (and create-react-app!) and npm, and the other half want to reimplement everything with zero retrocompatibility every 6 months... I might see if I can get a few of the MFEs to compile with zero (or almost) code changes - that might make it possible to get around having to get buy-in from the whole community and isolate the changes to a very small surface. Thanks for your work on this anyway! |


This is the result of a long investigation to accelerate the building of MFE apps in Open edX. Many of the intermediate results can be found in this issue: openedx/wg-frontend#184
The tl;dr is that building MFEs takes a very long time, and that's because of Webpack. In this PR, we replace Webpack by rsbuild, resulting in a considerable performance improvement.
This PR is dependent on the following upstream PRs:
Open questions
TODO
Things we need to address before (if?) we merge:
Benchmarks
Configuration
These benchmarks are performed on my personal computer: a Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz with 4 processors and 20 GB RAM. My custom Docker builder runs with
max-parallelism = 4, as per these instructions:All plugins are disabled, except for "mfe" and "forum", and there is no bind-mount:
The "mfe" image is built from scratch on the "main" branch; then, we re-build the image by clearing the cache for the "*-prod" build steps, which are the ones that run
npm run build:The changes in this PR are tested by checking out this branch:
Then run the commands above.
We list the benchmarks by date, because we expect these figures to change as we iterate on this PR.
Reference times
Reference 1: total build time
On the main branch, the total elapsed ("real") time of that last step is 468 s (7 min 48 s). This will serve as a point of reference for all benchmarks.
Reference 2: no parallelism build of the learning MFE
Another interesting point of reference is the time that is needed to build the learning MFE, without parallelism -- that is, without concurrent builds of other MFEs. This is a figure that can be obtained by running:
And then checking the time to build the MFE in the Docker logs:
Here, the reference time is 119.5s.
Single-thread build of the learning app
2025/04/10 Locked cache
We added the following locked cache in the build step:
This causes all builds to run sequentially, and not in parallel. The good thing with this change is that it allows us to no longer customise our Docker builder with
max-parallelism=x. The only downside is that there might be a drop in performance; but in practice, we don't really observe a noticeable one.2025/04/09 Initial results
All MFEs build under 23s, despite the fact that there are 4 builds in parallel: