go-html/Makefile
Claude 9bc1fa7c69
fix: escape variant names, single-pass StripTags, WASM security contract
- Escape variant name in Responsive.Render HTML attribute (XSS fix)
- Rewrite StripTags to single-pass O(n) space collapsing
- Document Raw() security contract in WASM entry point
- Add TestAttr_NonElement coverage
- Fix Makefile WASM target to rebuild on source changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 00:21:24 +00:00

30 lines
959 B
Makefile

.PHONY: wasm test clean
WASM_OUT := dist/go-html.wasm
# Raw size limit: 3MB (Go WASM has ~2MB runtime floor)
WASM_RAW_LIMIT := 3145728
# 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 3MB ($${RAW} bytes) — check imports"; \
else \
echo "OK: gzip $${GZ} bytes (limit 1MB), raw $${RAW} bytes (limit 3MB)"; \
fi
clean:
rm -rf dist/