go-html/cmd/wasm/register.go
Snider 2d16ce9d69
All checks were successful
Security Scan / security (push) Successful in 7s
Test / test (push) Successful in 1m34s
fix(conventions): alias stdlib io, add interface checks, use go-log
- Alias stdlib `io` as `goio` in cmd/codegen/main.go to follow project conventions
- Add compile-time Node interface checks for all node types in node.go
  and Layout in layout.go
- Replace fmt.Fprintf stderr logging with go-log in cmd/codegen/main.go
- Replace fmt.Println with go-log in cmd/wasm/register.go

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-15 16:40:39 +00:00

27 lines
744 B
Go

//go:build !js
package main
import (
"encoding/json"
"fmt"
"forge.lthn.ai/core/go-html/codegen"
log "forge.lthn.ai/core/go-log"
)
// buildComponentJS takes a JSON slot map and returns the WC bundle JS string.
// This is the pure-Go part testable without WASM.
// Excluded from WASM builds — encoding/json and text/template are too heavy.
// Use cmd/codegen/ CLI instead for build-time generation.
func buildComponentJS(slotsJSON string) (string, error) {
var slots map[string]string
if err := json.Unmarshal([]byte(slotsJSON), &slots); err != nil {
return "", fmt.Errorf("registerComponents: %w", err)
}
return codegen.GenerateBundle(slots)
}
func main() {
log.Info("go-html WASM module — build with GOOS=js GOARCH=wasm")
}