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

Hot-reload #10

Closed
PaulBlanche opened this issue Apr 27, 2022 · 2 comments
Closed

Hot-reload #10

PaulBlanche opened this issue Apr 27, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@PaulBlanche
Copy link
Owner

In dev mode, use SSE to trigger refresh on rebuild. Not HMR, but this should allow rapid developpment cycle.

@PaulBlanche PaulBlanche added the enhancement New feature or request label Apr 27, 2022
@PaulBlanche
Copy link
Owner Author

In order to implement this without over-engineering, we need denoland/deno#8327.

Currently, with a server started, we can listen to changes on a filesystem and trigger a rebuild. This rebuild is done with the cached modules loaded by Deno. This means that we will react to a change to a module, but a refresh will produce the old page (because the module cache was populated with the old module).

As a workaround we could run frugal in a worker and the server in the main thread. Instead of invoking frugal methods, the server would exchange messages with a worker. When a filesystem event is triggered, we destroy and recreate the worker. But i think it's not a good idea :

  • This might be difficult (or impossible) since we might need to pass function between the main thread an the worker.
  • destroying/recreating the worker might be expensive.

@PaulBlanche PaulBlanche added the blocked Something out ouf control blocks the issue label May 10, 2022
@PaulBlanche
Copy link
Owner Author

Solution implemented in #18.

Starting frugal in dev mode starts a livereload server and generates a module that will be run as a subprocess in watch mode (meaning the module cache is reloaded on each filesystem change event). Parent and subprocess exchange messages through stdin/stdout. The subprocess sends a message each time it reloads (due to filesystem change event), and the livereload server can dispatch a SSE.

The livereload client is "side loaded" if frugal is started in dev mode, and triggers a page reload.

@PaulBlanche PaulBlanche removed the blocked Something out ouf control blocks the issue label Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant