Skip to content

fix: respect function build.path during build and run#7161

Merged
isaacroldan merged 1 commit intomainfrom
04-02-fix-function-build-path-handling
Apr 2, 2026
Merged

fix: respect function build.path during build and run#7161
isaacroldan merged 1 commit intomainfrom
04-02-fix-function-build-path-handling

Conversation

@isaacroldan
Copy link
Copy Markdown
Contributor

@isaacroldan isaacroldan commented Apr 2, 2026

WHY are these changes introduced?

When a function extension defines a custom build.path (e.g. dist/custom.wasm) that stays in the same directory as the default output path (dist/index.wasm), the build process was unnecessarily rebundling (base64-encoding) the wasm file. Additionally, shopify app function run was not respecting the configured build.path, always using the default outputPath instead.

WHAT is this pull request doing?

extension.ts (build):

  • Adds a dirname check so that when build.path resolves to the same directory as the default output path, the redundant rebundle step is skipped.

runner.ts (run):

  • Adds a getFunctionPath() helper that resolves the function wasm path from build.path config when present, falling back to the default outputPath.
  • Uses this resolved path when invoking the function runner binary.

Tests:

  • Adds a test verifying no rebundling occurs when build.path stays in the default output directory.
  • Adds a test verifying the function runner uses build.path when configured.

How to test your changes?

  1. Create a function extension with a custom build.path in shopify.function.extension.toml:
    [build]
    command = "cargo wasi build --release"
    path = "dist/custom.wasm"
  2. Run shopify app build — verify no unnecessary base64 rebundling occurs.
  3. Run shopify app function run — verify it executes the correct wasm file.

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@isaacroldan isaacroldan marked this pull request as ready for review April 2, 2026 12:13
@isaacroldan isaacroldan requested a review from a team as a code owner April 2, 2026 12:13
Copilot AI review requested due to automatic review settings April 2, 2026 12:13
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

Avoid unnecessary rebundling when a function's custom build.path stays under the default dist directory, and make the function runner execute the configured build.path directly. Add regression tests for both behaviors.

Co-authored-by: Claude Code <claude-code@anthropic.com>
@isaacroldan isaacroldan force-pushed the 04-02-fix-function-build-path-handling branch from 7f3ec5b to cf64354 Compare April 2, 2026 12:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes function build/run behavior to correctly respect build.path and avoids unnecessary WASM rebundling when the custom path remains in the default output directory.

Changes:

  • Update shopify app function run to resolve the WASM file path from build.path when configured.
  • Skip the base64 rebundle step when build.path is in the same directory as the default output path.
  • Add tests covering both the rebundle-skip behavior and the runner’s build.path resolution.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/app/src/cli/services/function/runner.ts Resolve function WASM path from configuration.build.path (fallback to outputPath) before invoking the runner binary.
packages/app/src/cli/services/function/runner.test.ts Add coverage ensuring the runner uses the configured build.path.
packages/app/src/cli/services/build/extension.ts Avoid calling bundleFunctionExtension when custom build.path stays in the default output directory.
packages/app/src/cli/services/build/extension.test.ts Add coverage ensuring no rebundling occurs for same-directory build.path overrides.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@isaacroldan isaacroldan merged commit 1a0173f into main Apr 2, 2026
43 of 47 checks passed
@isaacroldan isaacroldan deleted the 04-02-fix-function-build-path-handling branch April 2, 2026 13:20
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.

3 participants