Skip to content

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Jan 14, 2025

By default Hot Module Rreplacement is configured to work with a localhost dev server

This server is responsible to serve the app and enable HMR

This wouldn't work with our apps because they are meant to be served by a local cozy-stack as a dev environment and so the cozy-app would try to connect to the HMR websocket using the cozy-stack's URL

Also the Rsbuild dev server is configured to serve built files from memory, so the /build folder would be empty and the cozy-stack wouldn't see any app

To fix this we can use both dev.writeToDisk and dev.client configurations

Then in order to benefit from this, the cozy-app should be run using rsbuild dev instead of rsbuild build --watch

More info:

In our projects, we found that using
`rsbuild build --watch --mode development` instead of just
`rsbuild build --watch` would speed up the re-build process

But when doing so, the bundler enables the
[fastRefresh](https://rsbuild.dev/plugins/list/plugin-react#fastrefresh)
mode from plugin-react

This mode does not work on `build` mode and trying to run the cozy-apps
would produce a blank screen with some `$RefreshSig$ is not defined`

This is because fastRefresh is meant to be run with `rsbuild dev`
command

So we want to disable this mode for all commands but `rsbuild dev`
Copy link
Member

@zatteo zatteo left a comment

Choose a reason for hiding this comment

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

🎉

By default Hot Module Rreplacement is configured to work with a
localhost dev server

This server is responsible to serve the app and enable HMR

This wouldn't work with our apps because they are meant to be served by
a local cozy-stack as a dev environment and so the cozy-app would try
to connect to the HMR websocket using the cozy-stack's URL

Also the Rsbuild dev server is configured to serve built files from
memory, so the `/build` folder would be empty and the cozy-stack
wouldn't see any app

To fix this we can use both `dev.writeToDisk` and `dev.client`
configurations

Then in order to benefit from this, the cozy-app should be run using
`rsbuild dev` instead of `rsbuild build --watch`

More info:
- web-infra-dev/rsbuild#4366
- https://rsbuild.dev/config/dev/write-to-disk#writing-to-disk
- https://rsbuild.dev/config/dev/client
@Ldoppea Ldoppea merged commit 160705b into master Jan 15, 2025
2 checks passed
@Ldoppea Ldoppea deleted the feat/rsbuild-hmr branch January 15, 2025 08:52
Ldoppea added a commit to cozy/cozy-settings that referenced this pull request Jan 15, 2025
`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
Ldoppea added a commit to cozy/cozy-photos that referenced this pull request Jan 15, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 15, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 15, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 15, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 15, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 15, 2025
`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
zatteo pushed a commit to cozy/cozy-drive that referenced this pull request Jan 27, 2025
`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
zatteo pushed a commit to cozy/cozy-drive that referenced this pull request Jan 27, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 28, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 28, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 28, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 29, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Jan 30, 2025
`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
Ldoppea added a commit to cozy/cozy-drive that referenced this pull request Feb 6, 2025
`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
zatteo pushed a commit to cozy/cozy-drive that referenced this pull request Feb 7, 2025
`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
zatteo pushed a commit to cozy/cozy-drive that referenced this pull request Feb 11, 2025
`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
zatteo pushed a commit to cozy/cozy-photos that referenced this pull request Mar 11, 2025
`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
zatteo pushed a commit to cozy/cozy-settings that referenced this pull request Mar 18, 2025
`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
JF-Cozy pushed a commit to cozy/cozy-settings that referenced this pull request Mar 18, 2025
`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
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