go-html/Makefile
Snider e532c219b9
All checks were successful
Security Scan / security (pull_request) Successful in 7s
Test / test (pull_request) Successful in 38s
fix(dx): update CLAUDE.md size gate, sync Makefile limit, add coverage tests
- CLAUDE.md: correct WASM raw size gate from 3 MB to 3.5 MB (matches size_test.go)
- CLAUDE.md: document error handling (log.E) and file I/O (coreio.Local) conventions
- Makefile: sync WASM_RAW_LIMIT to 3670016 (3.5 MB) to match size_test.go
- Tests: add coverage for NewContextWithService, Attr through wrapper nodes,
  Unless(true), and Text.Render with i18n service — core package 95.8% → 99.4%

No fmt.Errorf or os.ReadFile/os.WriteFile violations found.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 08:21:15 +00:00

30 lines
962 B
Makefile

.PHONY: wasm test clean
WASM_OUT := dist/go-html.wasm
# Raw size limit: 3.5MB (Go 1.26 WASM runtime growth)
WASM_RAW_LIMIT := 3670016
# Gzip transfer size limit: 1MB (what users actually download)
WASM_GZ_LIMIT := 1048576
test:
go test ./...
wasm: $(WASM_OUT)
$(WASM_OUT): $(shell find . -name '*.go' -not -path './dist/*')
@mkdir -p dist
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o $(WASM_OUT) ./cmd/wasm/
@RAW=$$(stat -c%s "$(WASM_OUT)" 2>/dev/null || stat -f%z "$(WASM_OUT)"); \
GZ=$$(gzip -c "$(WASM_OUT)" | wc -c); \
echo "WASM size: $${RAW} bytes raw, $${GZ} bytes gzip"; \
if [ "$$GZ" -gt $(WASM_GZ_LIMIT) ]; then \
echo "FAIL: gzip transfer size exceeds 1MB limit ($${GZ} bytes)"; \
exit 1; \
elif [ "$$RAW" -gt $(WASM_RAW_LIMIT) ]; then \
echo "WARNING: raw binary exceeds 3.5MB ($${RAW} bytes) — check imports"; \
else \
echo "OK: gzip $${GZ} bytes (limit 1MB), raw $${RAW} bytes (limit 3.5MB)"; \
fi
clean:
rm -rf dist/