Skip to content

scripts: add wasm_exec.js generator#201

Merged
syumai merged 3 commits into
mainfrom
add-wasm-exec-generator
May 4, 2026
Merged

scripts: add wasm_exec.js generator#201
syumai merged 3 commits into
mainfrom
add-wasm-exec-generator

Conversation

@syumai

@syumai syumai commented May 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds scripts/gen-wasm-exec, a TypeScript + jscodeshift tool that fetches upstream wasm_exec.js from golang/go / tinygo-org/tinygo and reapplies the Workers-specific patches.
  • Adds make gen-wasm-exec (with optional GO_VERSION / TINYGO_VERSION overrides) to regenerate cmd/workers-assets-gen/assets/wasm_exec_*.js.
  • Aligns TinyGo's globalProxy to use Reflect.get(target, prop, target), matching Go.

syumai and others added 3 commits May 4, 2026 17:46
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>
@syumai syumai marked this pull request as ready for review May 4, 2026 09:00
@syumai syumai merged commit 8f37020 into main May 4, 2026
2 checks passed
@syumai syumai deleted the add-wasm-exec-generator branch May 4, 2026 09:00
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.

1 participant