scripts: add wasm_exec.js generator#201
Merged
Merged
Conversation
Adds scripts/gen-wasm-exec, a TypeScript + jscodeshift tool that fetches upstream wasm_exec.js from golang/go and tinygo-org/tinygo at the configured tags and reapplies the Workers-specific patches (context arg on Go.run, globalProxy, TinyGo Node.js-only blocks commented out). Run `make gen-wasm-exec` (with optional GO_VERSION / TINYGO_VERSION overrides) to regenerate cmd/workers-assets-gen/assets/wasm_exec_*.js. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the common AST patching steps out of transform-go.ts and transform-tinygo.ts into a shared transformWasmExec() helper, parametrized by globalName, expected standalone-global count, and the globalProxy decl. TinyGo keeps its Node.js-block commenting pre-step locally and delegates the rest. Output for Go 1.26.2 / TinyGo 0.41.1 is byte-identical to before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Use Reflect.get(target, prop, target) in the TinyGo globalProxy decl, matching the Go side. Now that both flavors share the same proxy body (only the global name differs), the literal moves into transform-wasm-exec behind a buildGlobalProxyDecl(globalName) helper, so the two wrappers no longer carry their own copies. Regenerated wasm_exec_tinygo.js reflects the one-line behavior change. Co-Authored-By: Claude Opus 4.7 (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
scripts/gen-wasm-exec, a TypeScript + jscodeshift tool that fetches upstreamwasm_exec.jsfromgolang/go/tinygo-org/tinygoand reapplies the Workers-specific patches.make gen-wasm-exec(with optionalGO_VERSION/TINYGO_VERSIONoverrides) to regeneratecmd/workers-assets-gen/assets/wasm_exec_*.js.globalProxyto useReflect.get(target, prop, target), matching Go.