fix: copy raw binary to dist/index.wasm during standalone builds, not base64#7237
Draft
alfonso-noriega wants to merge 1 commit intomainfrom
Draft
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
6f0ccbe to
4a8884f
Compare
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.

WHY are these changes introduced?
Community regression (CLI 3.93.0): after
shopify app build,dist/index.wasmcontains base64-encoded text instead of raw binary, causing vitest to fail immediately when loading the wasm.How the bug was introduced — the full chain
There are two independent concerns that
outputPathhas been confusingly conflating:build.pathin TOML, e.g.target/wasm32-wasi/release/my_func.wasm)dist/index.wasm— a hard server-side contract)1. Commit
4446834(bad refactor): changedgetOutputRelativePathto returnbuild.path ?? dist/index.wasm. This causedextension.outputPathat construction time to point at the compiler output path, which meant the wasm ended up under the wrong key in the deploy bundle — breaking all Function deploys.2. PR #7085 (fix, Mar 24): restored
getOutputRelativePathto always returndist/index.wasm. This fixed deploys. However, it also meansextension.outputPathstarts as<project>/dist/index.wasmagain. InsidebuildFunctionExtension:When called from
shopify app build(i.e.ext.build()directly),bundlePathis the project's owndist/index.wasm, so base64 is written straight into the developer's project.3. PR #7161 (partial fix, Apr 2): added a
dirnamecheck to skip bundling whenbuild.pathis in the same directory asdist/(e.g.dist/custom.wasm). This helps only that narrow case. Typical Rust functions havebuild.path = "target/wasm32-wasi/release/func.wasm"— a completely different directory — so the base64 encoding still runs.4. Community report (Apr 7): users on CLI 3.93.0 see vitest fail because
dist/index.wasmhas base64 text, not raw WASM bytes.Why the same code works correctly for
shopify app deployWhen called from
buildForBundle(the deploy path),buildForBundlepre-setsextension.outputPathto the temp bundle directory before callingbuild():So inside
buildFunctionExtension,bundlePath=<bundleDir>/dist/index.wasm(outside the project), and the base64 encoding goes into the bundle directory — exactly right for the zip upload. The project'sdist/index.wasmis never touched.The problem is that
shopify app buildskipsbuildForBundleand callsext.build()directly, sobundlePathis the project's owndist/index.wasm.WHAT is this pull request doing?
Adds a check in
buildFunctionExtensionto distinguish between the two call sites using a simple, unambiguous condition:bundlePathshopify app build(standalone)<project>/dist/index.wasmshopify app deploy/buildForBundle<bundleDir>/<id>/dist/index.wasmbuild.path = dist/custom.wasm(same dir, standalone)<project>/dist/index.wasmdist/custom.wasm→dist/index.wasm✓build.path = dist/custom.wasm(same dir, bundle)<bundleDir>/<id>/dist/index.wasmHow to test your changes?
build.pathpointing to the Cargo output:shopify app build— verifydist/index.wasmis raw binary (e.g. starts with\0asmmagic bytes), not base64 text.shopify app deploy— verify the function deploys successfully (wasm uploaded underdist/index.wasm).shopify app dev— verify dev draft updates work correctly.Measuring impact
Checklist