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

[VO-1282] chore: Migrate to Rsbuild #3296

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Jan 15, 2025

Performances comparison on my computer:

yarn build

Webpack Rsbuild
Run 1 68,33s 9,00s
Run 2 52,40s 9,59s
Run 3 54,12s 10,72s
Run 4 59,22s 12,40s
Run 5 53,44s 12,44s
Average 57,50s 10,83s

yarn watch

Webpack Rsbuild
Initial build 20,30s 6,64s
Rebuild 1 2,64s 1,42s
Rebuild 2 3,56s 0,73s
Rebuild 3 2,91s 0,72s
Rebuild 4 2,57s 0,77s
Average (initial build removed from average) 2,92s 0,91s

Related PRs:

### 🔧 Tech

* Migrate to Rsbuild

Copy link

bundlemon bot commented Jan 15, 2025

BundleMon

Files added (19)
Status Path Size Limits
public/static/js/(chunkId).(hash).js
+1.3MB -
static/js/(chunkId).(hash).js
+1.19MB -
static/js/cozy.(hash).js
+793.04KB -
public/static/js/cozy.(hash).js
+659.93KB -
(hash).js
+337.62KB -
public/(hash).js
+337.62KB -
services/qualificationMigration.js
+271.87KB -
services/dacc.js
+254.82KB -
static/js/main.(hash).js
+120.44KB -
public/static/js/public.(hash).js
+97.85KB -
public/static/js/lib-react.(hash).js
+39.37KB -
static/js/lib-react.(hash).js
+39.37KB -
static/css/cozy.(hash).css
+32.78KB -
public/static/css/cozy.(hash).css
+32.57KB -
public/static/js/lib-router.(hash).js
+22.05KB -
static/js/lib-router.(hash).js
+22.05KB -
static/css/main.(hash).css
+16.76KB -
public/static/css/public.(hash).css
+6.27KB -
assets/manifest.json
+185B -
Files removed (16)
Status Path Size Limits
vendors/drive.(hash).js
-2.32MB -
public/drive.(hash).js
-2.09MB -
public/pdf.worker.entry.(hash).worker.js
-345.35KB -
services/qualificationMigration/drive.js
-283.72KB -
services/dacc/drive.js
-263.3KB -
app/drive.(hash).js
-159.6KB -
public/cozy-client-js.js
-159.28KB -
intents/drive.(hash).js
-85.93KB -
public/drive.(hash).min.css
-39.53KB -
onlyOffice/slide.pptx
-24.83KB -
app-drive.(hash).min.css
-10.16KB -
intents-drive.(hash).min.css
-8.43KB -
onlyOffice/text.docx
-5.85KB -
onlyOffice/spreadsheet.xlsx
-5.02KB -
intents/index.html
-509B -
manifest.json
-185B -
Files updated (1)
Status Path Size Limits
index.html
658B (+60B +10.03%) -
Unchanged files (1)
Status Path Size Limits
manifest.webapp
1.92KB -

Total files change -263.42KB -4.46%

Groups added (3)
Status Path Size Limits
**/*.js
+5.42MB -
**/*.{png,svg,ico}
+2.17MB -
**/*.css
+88.38KB -
Groups removed (7)
Status Path Size Limits
public/**
-2.63MB -
vendors/**
-2.32MB -
services/**
-547.03KB -
app/**
-159.6KB -
intents/**
-86.43KB -
onlyOffice/**
-35.7KB -
img/**
-5.85KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@Ldoppea Ldoppea force-pushed the feat/migrate-to-rsbuild branch 2 times, most recently from 98c82cd to 7201534 Compare January 15, 2025 16:52
@zatteo
Copy link
Contributor

zatteo commented Jan 15, 2025

This commit title seems incomplete feat: Migrate index.ejs from

import { getRsbuildConfig } from 'rsbuild-config-cozy-app'

const config = getRsbuildConfig({
title: 'Cozy Photos',
Copy link
Contributor

@zatteo zatteo Jan 15, 2025

Choose a reason for hiding this comment

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

Cozy Drive

@@ -84,7 +84,6 @@
"classnames": "2.3.1",
"cozy-bar": "^16.0.1",
"cozy-client": "^52.1.0",
"cozy-client-js": "0.20.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not enough for the cozy-client-js removal. They are cozy.client global variable uses in the repo.

@zatteo
Copy link
Contributor

zatteo commented Jan 15, 2025

Great job! 🎉 Can't wait to build faster than light ✨

@zatteo zatteo force-pushed the feat/migrate-to-rsbuild branch from 7201534 to cb626f2 Compare January 27, 2025 10:59
With the Rsbuild migration, the transpiled code now use `let` and
`const` features contrary to the previous Webpack configuration that
converted them to `var`

This highlight some bug that we previously missed where some variables
were used before being declared. This did not produce any throw when
using `var` due to hoisting, but this may produce bug as the accessed
variable may be undefined
With the Rsbuild migration, the transpiled code now use `let` and
`const` features contrary to the previous Webpack configuration that
converted them to `var`

This highlight some bug that we previously missed where some variables
were used before being declared. This did not produce any throw when
using `var` due to hoisting, but this may produce bug as the accessed
variable may be undefined
In cozy-script we used to enforce the development mode when doing a
`yarn watch`

The development mode changes the build behavior by removing some steps
like minification which results to a faster build

A side effect is that the code generated from the `watch` command is a
bit different than the one generated from `build` command. This may
produce some differences on the app's behavior, but this is rare enough
(happened 1 or 2 times in the past years) so we consider the speed gain
to still be valuable. Also we know that we should run a `build` locally
as ultimate check before pushing new code to the git repo

So we want to enable this mode in the new Rsbuild configuration

Here are the timings for initial build and then 4 differents edits in
the code that trigger a re-build

yarn watch
```
    11,70s (initial build)
    9,87s
    9,89s
    10,10s
    10,80s
```

yarn watch --mode development
```
    6,64s (initial build)
    1,42s
    0,73s
    0,72s
    0,77s
```

Related code:
https://github.com/cozy/create-cozy-app/blob/master/packages/cozy-scripts/scripts/watch.js#L13
`rsbuild-config-cozy-app` has been upgraded to `0.2.0` in order to
retrieve the configuration needed to run `rsbuild dev` with our
cozy-stack based architecture and then benefits from HMR feature

Related PR: cozy/cozy-libs#2700
Since previous commit we can run `rsbuild dev` to enable HMR feature

We now have 3 different scripts:
- `yarn build`: build the app for production
- `yarn watch`: like for the `build` script but with some optimizations
  in order to build faster and to trigger rebuild automatically when
  the code changes
- `yarn dev`: build the app with HMR enabled. This should be the
  fastest way to debug the app, but the HMR feature may prevent the app
  to work in some environments (i.e. flagship app)
`cozy-dataproxy-lib` has been upgraded to `2.3.1` in order to retrieve
a fix on package.json configuration that did not export the dataproxy's
`stylesheet.css`

Related PR: cozy/cozy-libs#2699
By migrating from webpack to rsbuild we lost this resolution override
that is needed by react-pdf for generating PDFs previews using
WebWorkers

More details:
https://github.com/cozy/cozy-libs/blob/a00baa1723bd7d37591fe95dcc1921d4e2c24f87/packages/cozy-viewer/src/Readme.md?plain=1#L299-L335
@zatteo zatteo force-pushed the feat/migrate-to-rsbuild branch from cb626f2 to 2f7e44e Compare January 27, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants