Skip to content

Comments

fix: Add WASM build tags to native-only files#282

Closed
josh-padnick wants to merge 1 commit intomainfrom
fix-wasm-build
Closed

fix: Add WASM build tags to native-only files#282
josh-padnick wants to merge 1 commit intomainfrom
fix-wasm-build

Conversation

@josh-padnick
Copy link
Contributor

While creating #281, Claude Code hit build failures because it was compiling boilerplate using go build ./.... CI didn't catch this because the Makefile's build-wasm target only compiles ./cmd/wasm/, which has its own main.go that avoids importing the package that caused the build failures (the POSIX-only syscall.Termios dependency in survey/v2/terminal).

Maybe we'll only ever use the Makefile and don't care about this fix? But if so, I'm including it here, kindly generated by Claude Code. Feel free to close if not relevant.

Summary

  • Add //go:build !(js && wasm) build tags to files in the native CLI call chain that transitively import survey/v2, which uses POSIX-only syscalls unavailable in the js/wasm target
  • Fixes GOOS=js GOARCH=wasm go build ./... failing due to undefined: syscall.Termios errors from survey/v2/terminal

Details

The WASM entry point (cmd/wasm/main.go) never imports the config, templates, or cli packages — it bypasses the interactive prompt path entirely. However, go build ./... compiles every package in the module regardless, and config/get_variables.go unconditionally imports survey/v2 which depends on POSIX syscalls.

Files tagged with //go:build !(js && wasm):

  • main.go — native CLI entry point
  • cli/boilerplate_cli.go — CLI app setup (imports templates)
  • templates/template_processor.go — template orchestration (imports config)
  • config/get_variables.go — interactive variable prompting (imports survey/v2)
  • config/get_variables_test.go — tests for the above

Test plan

  • go build ./... — native build still works
  • go test ./config/... ./templates/... ./cli/... — affected package tests pass
  • GOOS=js GOARCH=wasm go build ./... — full module WASM build now succeeds
  • GOOS=js GOARCH=wasm go build ./cmd/wasm/ — WASM entry point still builds

The `config/get_variables.go` file imports `survey/v2` which uses
POSIX-only syscalls (syscall.Termios) that are unavailable in the
js/wasm target. This causes `GOOS=js GOARCH=wasm go build ./...` to
fail, even though the WASM entry point (cmd/wasm/) never imports
these packages.

Add `//go:build !(js && wasm)` to the files in the native CLI call
chain (main.go -> cli -> templates/template_processor -> config/
get_variables) so they are excluded from WASM compilation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
boilerplate Ready Ready Preview, Comment Feb 24, 2026 1:12am

Request Review

@yhakbar
Copy link
Contributor

yhakbar commented Feb 24, 2026

Yes, we intentionally slimmed down the imports in cmd/wasm/main.go so that we wouldn't have to include build flags everywhere. It also helps us ensure that usage of Boilerplate as a library is slim, as we should prefer to simplify the import graph for all consumers of packages in Boilerplate, rather than using build flags everywhere.

@yhakbar yhakbar closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants