-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
30 lines (25 loc) · 962 Bytes
/
Makefile
File metadata and controls
30 lines (25 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.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/