fix: Add WASM build tags to native-only files#282
Closed
josh-padnick wants to merge 1 commit intomainfrom
Closed
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Yes, we intentionally slimmed down the imports in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While creating #281, Claude Code hit build failures because it was compiling boilerplate using
go build ./.... CI didn't catch this because the Makefile'sbuild-wasmtarget only compiles./cmd/wasm/, which has its ownmain.gothat avoids importing the package that caused the build failures (the POSIX-onlysyscall.Termiosdependency insurvey/v2/terminal).Maybe we'll only ever use the
Makefileand 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
//go:build !(js && wasm)build tags to files in the native CLI call chain that transitively importsurvey/v2, which uses POSIX-only syscalls unavailable in thejs/wasmtargetGOOS=js GOARCH=wasm go build ./...failing due toundefined: syscall.Termioserrors fromsurvey/v2/terminalDetails
The WASM entry point (
cmd/wasm/main.go) never imports theconfig,templates, orclipackages — it bypasses the interactive prompt path entirely. However,go build ./...compiles every package in the module regardless, andconfig/get_variables.gounconditionally importssurvey/v2which depends on POSIX syscalls.Files tagged with
//go:build !(js && wasm):main.go— native CLI entry pointcli/boilerplate_cli.go— CLI app setup (importstemplates)templates/template_processor.go— template orchestration (importsconfig)config/get_variables.go— interactive variable prompting (importssurvey/v2)config/get_variables_test.go— tests for the aboveTest plan
go build ./...— native build still worksgo test ./config/... ./templates/... ./cli/...— affected package tests passGOOS=js GOARCH=wasm go build ./...— full module WASM build now succeedsGOOS=js GOARCH=wasm go build ./cmd/wasm/— WASM entry point still builds