Summary
Add --live-reload flag that auto-refreshes the browser when files change, leveraging existing WebSocket notifications.
Implementation
Minimal addition (~20 lines):
- Add
--live-reload flag to CLI
- When enabled, auto-enable notifications WebSocket
- Inject small client script into HTML responses:
<script>(function(){
var ws = new WebSocket((location.protocol==='https:'?'wss:':'ws:') + '//' + location.host + '/notifications/');
ws.onmessage = function() { location.reload() };
ws.onclose = function() { setTimeout(function(){ location.reload() }, 1000) };
})();</script>
Usage
Browser auto-refreshes when any file is created/updated/deleted via PUT/DELETE.
Use Case
Primary consumer is servejss (npx serve alternative) which will pass this flag for local development.
Complexity
- ~15 lines for script injection helper
- ~5 lines for flag/config wiring
- Leverages existing notifications infrastructure
Related: JavaScriptSolidServer/jsserve#1
Summary
Add
--live-reloadflag that auto-refreshes the browser when files change, leveraging existing WebSocket notifications.Implementation
Minimal addition (~20 lines):
--live-reloadflag to CLIUsage
Browser auto-refreshes when any file is created/updated/deleted via PUT/DELETE.
Use Case
Primary consumer is
servejss(npx serve alternative) which will pass this flag for local development.Complexity
Related: JavaScriptSolidServer/jsserve#1