Add automatic rebuild and browser reload functionality for development. When Go source files change, the WASM binary is automatically rebuilt and connected browsers reload to show the updated application.
Changes
Watcher (watcher.go): File system watcher using polling to detect changes in Go source files
Builder (builder.go): Executes WASM compilation when files change
LiveReload (livereload.go): WebSocket server for browser-to-server communication
Inject (inject.go): Injects reload script into HTML responses
DevServer (devserver.go): Combines all components into an easy-to-use development server
## Summary
Add automatic rebuild and browser reload functionality for development. When Go source files change, the WASM binary is automatically rebuilt and connected browsers reload to show the updated application.
## Changes
- **Watcher** (`watcher.go`): File system watcher using polling to detect changes in Go source files
- **Builder** (`builder.go`): Executes WASM compilation when files change
- **LiveReload** (`livereload.go`): WebSocket server for browser-to-server communication
- **Inject** (`inject.go`): Injects reload script into HTML responses
- **DevServer** (`devserver.go`): Combines all components into an easy-to-use development server
- Updated `README.md` with hot reload documentation
## Usage
```go
dev := host.NewDevServer("public", "index.html", ".", "public/app.wasm")
dev.ListenAndServe(":8080")
```
Closes #9
Implement automatic rebuild and browser reload during development:
- File watcher monitors .go files for changes with configurable extensions
- Builder compiles Go source to WASM on file changes
- LiveReload WebSocket server notifies connected browsers to reload
- DevServer combines all components for easy development setup
- HTML injection adds reload script automatically
Usage:
dev := host.NewDevServer("public", "index.html", ".", "public/app.wasm")
dev.ListenAndServe(":8080")
Closes#9
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Custom minimal WebSocket implementation (no external deps)
Good test coverage (392 lines of tests)
Comprehensive README documentation
Issue: Unused Code
host/devserver.go lines 461-473 - The responseWriter struct is defined but never used:
// ResponseWriter wraps http.ResponseWriter to capture the responsetyperesponseWriterstruct{http.ResponseWriterbuf*bytes.BufferstatusCodeint}func(rw*responseWriter)WriteHeader(codeint){rw.statusCode=code}func(rw*responseWriter)Write(b[]byte)(int,error){returnrw.buf.Write(b)}
Please remove this unused code before merging.
Minor Notes
Error handling in readLoop silently ignores errors (acceptable for reload-only use)
WebSocket is intentionally minimal - appropriate for this use case
## Code Review
### Summary
Excellent feature addition implementing automatic rebuild and browser reload for development. Well-architected with clean component separation.
### Highlights
- Clean separation: Watcher, Builder, LiveReload, Inject, DevServer
- Good API design with functional options pattern
- Proper concurrency handling (mutexes, WaitGroups)
- Custom minimal WebSocket implementation (no external deps)
- Good test coverage (392 lines of tests)
- Comprehensive README documentation
### Issue: Unused Code
**host/devserver.go lines 461-473** - The `responseWriter` struct is defined but never used:
```go
// ResponseWriter wraps http.ResponseWriter to capture the response
type responseWriter struct {
http.ResponseWriter
buf *bytes.Buffer
statusCode int
}
func (rw *responseWriter) WriteHeader(code int) {
rw.statusCode = code
}
func (rw *responseWriter) Write(b []byte) (int, error) {
return rw.buf.Write(b)
}
```
Please remove this unused code before merging.
### Minor Notes
- Error handling in readLoop silently ignores errors (acceptable for reload-only use)
- WebSocket is intentionally minimal - appropriate for this use case
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Add automatic rebuild and browser reload functionality for development. When Go source files change, the WASM binary is automatically rebuilt and connected browsers reload to show the updated application.
Changes
watcher.go): File system watcher using polling to detect changes in Go source filesbuilder.go): Executes WASM compilation when files changelivereload.go): WebSocket server for browser-to-server communicationinject.go): Injects reload script into HTML responsesdevserver.go): Combines all components into an easy-to-use development serverREADME.mdwith hot reload documentationUsage
Closes #9
Implement automatic rebuild and browser reload during development: - File watcher monitors .go files for changes with configurable extensions - Builder compiles Go source to WASM on file changes - LiveReload WebSocket server notifies connected browsers to reload - DevServer combines all components for easy development setup - HTML injection adds reload script automatically Usage: dev := host.NewDevServer("public", "index.html", ".", "public/app.wasm") dev.ListenAndServe(":8080") Closes #9 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>Code Review
Summary
Excellent feature addition implementing automatic rebuild and browser reload for development. Well-architected with clean component separation.
Highlights
Issue: Unused Code
host/devserver.go lines 461-473 - The
responseWriterstruct is defined but never used:Please remove this unused code before merging.
Minor Notes
Code Review - Approved
Excellent hot reload feature with clean architecture and good test coverage.
Highlights
Previous Feedback
Unused
responseWriterstruct removed.LGTM - merging.