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

Introduce RSC "live reload." #10932

Merged
merged 14 commits into from
Jul 25, 2024
Merged

Introduce RSC "live reload." #10932

merged 14 commits into from
Jul 25, 2024

Conversation

peterp
Copy link
Contributor

@peterp peterp commented Jul 10, 2024

This PR introduces a development server with "live reload" functionality to the RSC parts of Redwood. Live reload enables developers to see changes immediately after saving a file, without needing to perform any additional actions.

The primary goal of this PR is to enhance the development experience. While live reload is a basic implementation of the "do something, see something" paradigm, it offers significant improvements to developer efficiency with minimal effort.

Here's a loom: https://www.loom.com/share/51463c3f6f1b40c5b8ee79d599f673d7?from_recorder=1&focus_title=1

How does it work?
We use chokidar to monitor the user's workspace for file changes. When a file change is detected, the following steps are executed:

  1. The existing process is terminated.
  2. The old code is deleted.
  3. The code is rebuilt.
  4. The development server is restarted.
  5. An event is sent to the frontend to reload the page.
  6. The frontend receives the event and refreshes the page.

This process allows developers to see the impact of their changes immediately without needing to manually rebuild and restart the web server.

Next steps: I plan to focus on speed improvements and then implement Hot Module Replacement (HMR).


Test it yourself:

cd ~/examples/
cp -R ~/gh/redwoodjs/redwood/__fixtures__/test-project-rsc-kitchen-sink .
cd test-project-rsc-kitchen-sink
yarn install
yarn rwfw project:sync
yarn rw-dev-rsc

@@ -48,6 +48,7 @@
},
"bin": {
"rw-dev-fe": "./dist/devFeServer.js",
"rw-dev-rsc": "./dist/devRscServer.js",
Copy link
Contributor Author

@peterp peterp Jul 10, 2024

Choose a reason for hiding this comment

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

This is a command that will be executed by the Redwood CLI.

@peterp peterp marked this pull request as ready for review July 25, 2024 12:24
'access-control-allow-origin': '*',
})
})
.listen(8913)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if hard coding this port is the correct approach, but could be OK for right now?

Copy link
Member

@Tobbe Tobbe Jul 25, 2024

Choose a reason for hiding this comment

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

Yeah, good enough for now! 🙂

@Tobbe Tobbe added the release:feature This PR introduces a new feature label Jul 25, 2024
@Tobbe Tobbe added this to the RSC milestone Jul 25, 2024
@Tobbe Tobbe enabled auto-merge (squash) July 25, 2024 17:18
@Tobbe Tobbe merged commit 7209bcb into main Jul 25, 2024
46 checks passed
@Tobbe Tobbe deleted the pp-rsc-live-reload branch July 25, 2024 20:19
@Josh-Walker-GM Josh-Walker-GM modified the milestones: RSC, v8.0.0 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature This PR introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants