WebAssembly for Functions
You can write your functions in any language that can compile to WebAssembly (Wasm), such as Rust, Zig, or TinyGo. This guide describes how to generate Wasm that conforms to Shopify Functions standards.
Requirements
Anchor link to section titled "Requirements"Functions that are compiled to Wasm need to meet the following requirements:
Conform with the command module structure referenced in the unstable WASI application ABI specification.
For each target implemented by the extension, the module must export a function of type
(func)
, which takes no arguments, and has no return values.- Function modules are multi-call executables that have exports mapped to Shopify extension targets in the function extension configuration.
Write output as a JSON encoded byte stream to a standard output file descriptor:
STDOUT (fd=1)
Read input as a JSON encoded byte stream from a standard input file descriptor:
STDIN (fd=0)
Write debug logs as a newline delimited
utf-8
file to a standard error file descriptor:STDERR (fd=2)
Module example
Anchor link to section titled "Module example"The following sample in WebAssembly text format (WAT) shows the expected signature for module exports, and its associated extension configuration: