go-html/cmd/wasm/register.go
Snider 29bd63d751
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
fix: add stub main() for non-WASM builds in cmd/wasm
The WASM main.go is gated behind //go:build js && wasm, leaving
register.go (//go:build !js) as the only file on native builds —
but it had no main(). Adds a stub that prints a usage hint.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-23 06:31:14 +00:00

26 lines
714 B
Go

//go:build !js
package main
import (
"encoding/json"
"fmt"
"forge.lthn.ai/core/go-html/codegen"
)
// 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() {
fmt.Println("go-html WASM module — build with GOOS=js GOARCH=wasm")
}