fix: switch JS/WASM bindings from TinyGo to standard Go#50
Merged
Conversation
TinyGo's WASM target has two blocking bugs that break the JS bindings: - reflect.AssignableTo panics with interfaces, breaking encoding/json used by both our code and the moby/buildkit parser (#4277) - regexp \s (Perl character classes) fails in newer TinyGo versions, also breaking the buildkit parser This commit: - Switches from TinyGo to standard Go (GOOS=js GOARCH=wasm), which has full reflect and regexp support - Replaces encoding/json usage in our code with a reflection-free []string JSON marshal/unmarshal (lib/json.go), avoiding HTML-escaping of <, >, & as a bonus - Simplifies the JS bindings by using syscall/js instead of manual memory management (malloc/free/pointer arithmetic) - Adds wasm-opt to the build pipeline to reduce binary size - Adds JS integration tests covering the issue #25 reproduction case Binary size increases from 2.0 MB to 6.9 MB (after wasm-opt), but the bindings now actually work for all Dockerfile forms. Fixes #25 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
|
Unfortunately, this blows up the binary size from 2->7 mb, but I can't control usage of JSON serialization in the buildkit parser. |
Runs Go tests and JS build+tests on pull requests and pushes to main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
GOOS=js GOARCH=wasm) to fix JS bindings that panic onreflect.AssignableToand\sregexp failures in the buildkit parserencoding/jsonin our formatting code with a reflection-free[]stringJSON marshal/unmarshal (lib/json.go)syscall/jsinstead of manual memory management (malloc/free/pointer arithmetic)wasm-optto the build pipeline (7.6 MB → 6.9 MB)Test plan
go test ./...— all Go tests passnode --test dist/format.test.js— all 6 JS tests pass, including:Fixes #25
🤖 Generated with Claude Code