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-1227] chore: Migrate to Rsbuild #55

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

Conversation

cballevre
Copy link
Contributor

### 🔧 Tech

* Migrate to Rsbuild

Related PRs:

@cballevre cballevre requested a review from zatteo as a code owner November 28, 2024 17:46
@cballevre cballevre force-pushed the feat/migrate-to-rsbuild branch from 552a4a3 to a2d7795 Compare November 29, 2024 14:11
@cballevre cballevre changed the title chore: Migrate to Rsbuild [VO-1227] chore: Migrate to Rsbuild Nov 29, 2024
@cballevre cballevre force-pushed the feat/migrate-to-rsbuild branch from a2d7795 to 98ac75f Compare November 29, 2024 15:08
@cballevre cballevre assigned cballevre and Ldoppea and unassigned cballevre Nov 29, 2024
@cballevre cballevre removed the request for review from Ldoppea November 29, 2024 15:09
Copy link

bundlemon bot commented Nov 29, 2024

BundleMon

Files added (17)
Status Path Size Limits
static/js/(chunkId).(hash).js
+616.81KB -
public/static/js/(chunkId).(hash).js
+586.7KB -
static/js/cozy.(hash).js
+414.53KB -
public/static/js/cozy.(hash).js
+382.49KB -
services/onPhotoUpload.js
+251.85KB -
services/onPhotoTrashed.js
+246.54KB -
static/js/main.(hash).js
+74.07KB -
public/static/css/cozy.(hash).css
+40.37KB -
static/css/main.(hash).css
+39.84KB -
public/static/js/lib-react.(hash).js
+39.37KB -
static/js/lib-react.(hash).js
+39.37KB -
public/static/js/public.(hash).js
+32.96KB -
static/css/cozy.(hash).css
+31.92KB -
public/static/css/public.(hash).css
+17.49KB -
static/js/lib-router.(hash).js
+16.82KB -
public/static/js/lib-router.(hash).js
+16.38KB -
assets/manifest.json
+185B -
Files removed (9)
Status Path Size Limits
vendors/photos.(hash).js
-1.22MB -
public/photos.(hash).js
-1.2MB -
services/onPhotoUpload/photos.js
-266.49KB -
services/onPhotoTrashed/photos.js
-256.88KB -
public/cozy-client-js.js
-159.28KB -
app/photos.(hash).js
-57.12KB -
public/photos.(hash).min.css
-46.47KB -
app-photos.(hash).min.css
-19.75KB -
manifest.json
-185B -
Files updated (2)
Status Path Size Limits
index.html
598B (+80B +15.44%) -
manifest.webapp
1.14KB (+20B +1.74%) -

Total files change -444.43KB -13.49%

Groups added (3)
Status Path Size Limits
**/*.js
+2.65MB -
**/*.css
+129.62KB -
**/*.{png,svg,ico}
+28.92KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@zatteo
Copy link
Contributor

zatteo commented Dec 3, 2024

@cballevre very nice work

@Ldoppea
Copy link
Member

Ldoppea commented Dec 10, 2024

This commit message says the opposite of what is done. Is the error on the message? or on what have been done?
image

@cballevre
Copy link
Contributor Author

This a mistake on the message 🙁

@Ldoppea Ldoppea force-pushed the feat/migrate-to-rsbuild branch from 98ac75f to ca82d75 Compare January 7, 2025 09:20
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
```
    7,57s (initial build)
    5,79s
    5,83s
    6,68s
    7,15s
```

yarn watch --mode development
```
    7,00s (initial build)
    0,69s
    0,45s
    0,92s
    0,46s
```

Related code:
https://github.com/cozy/create-cozy-app/blob/master/packages/cozy-scripts/scripts/watch.js#L13
@Ldoppea Ldoppea force-pushed the feat/migrate-to-rsbuild branch from ca82d75 to 588ab49 Compare January 7, 2025 09:41
@Ldoppea Ldoppea force-pushed the feat/migrate-to-rsbuild branch from 44e02d4 to 8f998c6 Compare January 7, 2025 11:29
`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
Copy link
Member

Ldoppea commented Jan 29, 2025

Non-regression tests have been done:

  • basic app usage
  • upload photo
  • download photo

Performances comparison on my computer:

yarn build

Webpack Rsbuild
Run 1 33,91s 7,28s
Run 2 31,61s 6,83s
Run 3 30,06s 7,49s
Run 4 33,09s 6,39s
Run 5 37,45s 7,12s
Average 33,22s 7,02s

yarn watch

Webpack Rsbuild
Initial build 17,50s 7,00s
Rebuild 1 2,45s 0,69s
Rebuild 2 2,65s 0,45s
Rebuild 3 2,33s 0,92s
Rebuild 4 2,26s 0,46s
Average (initial build removed from average) 2,42s 0,63s

`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)
<div role="application" data-cozy="{{.CozyData}}"></div>
<% htmlPlugin.files.js.forEach(function(file) { %>
<script defer src="<%- file %>"></script>
<% }); %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Any idea why there is no here ?

@zatteo zatteo requested a review from Ldoppea February 11, 2025 13:17
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