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-1228] chore: Migrate to Rsbuild #727

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

Conversation

cballevre
Copy link
Contributor

### 🔧 Tech

* Migrate to Rsbuild

Work remaining to be done:

  • Migrate cs test to jest to make yarn test
  • Migrate .bundlemonrc to the new build structure

cballevre and others added 14 commits January 7, 2025 10:34
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
```
    4,66s (initial build)
    4,84s
    4,12s
    4,63s
    5,08s
```

yarn watch --mode development
```
    3,09s (initial build)
    0,66s
    0,34s
    0,18s
    0,45s
```

Related code:
https://github.com/cozy/create-cozy-app/blob/master/packages/cozy-scripts/scripts/watch.js#L13
@Ldoppea Ldoppea force-pushed the chore/migrate-to-rsbuild branch from cdc84ec to 369f285 Compare January 7, 2025 10:07
Copy link

bundlemon bot commented Jan 7, 2025

BundleMon

Files added (7)
Status Path Size Limits
static/js/(chunkId).(hash).js
+593.66KB -
static/js/cozy.(hash).js
+427.86KB -
static/js/main.(hash).js
+151.64KB -
static/js/lib-react.(hash).js
+43.88KB -
static/css/main.(hash).css
+29.52KB -
static/css/cozy.(hash).css
+28.99KB -
static/js/lib-router.(hash).js
+4.71KB -
Files removed (16)
Status Path Size Limits
vendors/settings.(hash).js
-1.22MB -
app/settings.(hash).js
-93.8KB -
intents/settings.(hash).js
-44.71KB -
img/export-cozy-mail.(hash).svg
-27.39KB -
img/import-cozy.(hash).svg
-11.09KB -
app-settings.(hash).min.css
-9.9KB -
img/double_authent_prez_banner.(hash).svg
-4.36KB -
img/protect_data_point.(hash).svg
-4.1KB -
img/niv_secu_point.(hash).svg
-1.54KB -
intents-settings.(hash).min.css
-1.27KB -
img/icon-bills.(hash).svg
-703B -
img/icon-laptop.(hash).svg
-439B -
img/icon-arrow-left.(hash).svg
-414B -
img/icon-question-mark.(hash).svg
-386B -
img/icon-check.(hash).svg
-369B -
img/icon-phone.(hash).svg
-343B -

Total files change -167.88KB -11.59%

Groups added (1)
Status Path Size Limits
**/*.{png,svg,ico}
+58.02KB -
Groups removed (1)
Status Path Size Limits
img/.
-51.07KB -
Groups updated (2)
Status Path Size Limits
**/*.js
1.83MB (+483.27KB +34.87%) -
**/*.css
78.19KB (+36.46KB +87.36%) -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

`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)
`rsbuild-config-cozy-app` has been upgraded to `0.2.1` in order to
retrieve the configuration needed to run intents and public targets in
the `rsbuild dev` mode

Related PR: cozy/cozy-libs#2717
@Ldoppea Ldoppea force-pushed the chore/migrate-to-rsbuild branch from e68747b to 35d8d76 Compare January 29, 2025 10:15
@Ldoppea
Copy link
Member

Ldoppea commented Jan 29, 2025

Non-regression tests have been done:

  • basic app usage
  • send Support request
  • change theme
  • export data
  • ❌ use /services/claudy route and Intent
  • ❌ use /services/support route and Intent

Performances comparison on my computer:

yarn build

Webpack Rsbuild
Run 1 26,91s 7,86s
Run 2 31,77s 5,26s
Run 3 27,24s 5,81s
Run 4 26,89s 5,23s
Run 5 25,04s 5,44s
Average 27,57s 5,92s

yarn watch

Webpack Rsbuild
Initial build 14,32s 3,09s
Rebuild 1 2,16s 0,66s
Rebuild 2 1,68s 0,34s
Rebuild 3 1,31s 0,18s
Rebuild 4 1,40s 0,45s
Average (initial build removed from average) 1,64s 0,41s

`rsbuild-config-cozy-app` has been upgraded to `0.3.0` in order to
retrieve the configuration needed to import images and static assets

Related PR: [cozy/cozy-libs#2728](cozy/cozy-libs#2728)
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.

3 participants