From 456adce73bcbedfadb384893d06af93c3684660c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Feb 2026 00:15:08 +0000 Subject: [PATCH] build: add Makefile with WASM build target and size check Co-Authored-By: Claude Opus 4.6 --- .gitignore | 1 + Makefile | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..849ddff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d5d26c6 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: wasm test clean + +WASM_OUT := dist/go-html.wasm + +test: + go test ./... + +wasm: $(WASM_OUT) + +$(WASM_OUT): + @mkdir -p dist + GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o $(WASM_OUT) ./cmd/wasm/ + @ls -lh $(WASM_OUT) + @SIZE=$$(stat -c%s "$(WASM_OUT)" 2>/dev/null || stat -f%z "$(WASM_OUT)"); \ + if [ "$$SIZE" -gt 2097152 ]; then \ + echo "WARNING: WASM binary exceeds 2MB target ($${SIZE} bytes)"; \ + else \ + echo "OK: WASM binary within 2MB target ($${SIZE} bytes)"; \ + fi + +clean: + rm -rf dist/