Custom WASM Builds
By default, cre workflow deploy and cre workflow simulate compile your Go or TypeScript source to a WASM binary automatically — no build configuration required. This works for most workflows.
cre workflow custom-build is an opt-in feature for advanced users who need to own the build step. Once converted, the CLI delegates compilation to a Makefile in your workflow directory instead of compiling your source itself.
When to use custom WASM builds
Generally, you should consider using custom WASM builds only when you have a specific reason to take control of the compilation step. Custom workflows are particularly useful for teams that need to use a custom compiler version or toolchain that differs from the CRE default compiler.
Common reasons to use custom WASM builds:
- Custom compiler flags or build tags: Add optimization flags, conditional compilation tags, or other build-time settings not exposed by the CLI's built-in compiler
- CI/CD pipelines: Build the WASM artifact once in your pipeline and promote it across environments without recompiling
- Pre-build validation: Add linting, type checking, formatting, or security scanning steps before compilation
- Non-standard toolchains: Use a custom compiler version or toolchain that differs from the CLI default
- Language and SDK extensions: Integrate code from other languages or custom SDKs into your build pipeline
Convert a workflow to custom build
Run the following command from your project root:
cre workflow custom-build ./my-workflow
You will be prompted to confirm before any changes are made. To skip the prompt, use --force.
The following changes are made to your workflow:
- Updates
workflow-pathto./wasm/workflow.wasmin yourworkflow.yamlfor all targets - Creates a
Makefilein your workflow directory with abuildtarget - Creates a
wasm/output directory
Build and simulate
After conversion, install dependencies (TypeScript only), then build and simulate:
# TypeScript only
bun install
make build
cre workflow simulate ./my-workflow --target staging-settings
The CLI picks up the compiled binary at wasm/workflow.wasm automatically.
Try it yourself
Walk through the full custom build flow end to end using a hello-world project.
1. Convert your workflow to a custom build: Run the following command from your project root:
cre workflow custom-build ./my-workflow
2. Open the generated Makefile: In the my-workflow directory, you'll see a new Makefile with a build target.
| 1 | .PHONY: build |
| 2 | |
| 3 | build: |
| 4 | bun cre-compile main.ts wasm/workflow.wasm |
| 5 | |
Install dependencies and run the initial build:
# TypeScript only
bun install
make build
cre workflow simulate ./my-workflow --target staging-settings
For a hello-world workflow you'll see output like "Hello world!".
3. Add a custom step to your Makefile (highlighted line shows what to add):
| 1 | .PHONY: build |
| 2 | |
| 3 | build: |
| 4 | echo "Running my custom build step..." |
| 5 | bun cre-compile main.ts wasm/workflow.wasm |
| 6 | |
4. Rebuild and simulate again: Run the following commands from your project root:
make build
cre workflow simulate ./my-workflow --target staging-settings
When make build runs you'll see Running my custom build step... printed before compilation.
Swap the echo for any real step: type checking, linting, code generation, or a custom compiler invocation.
Build once without converting your workflow
If you only need to compile once and reuse the binary, for example to run many simulations against the same build, you don't have to convert your workflow. Build the binary with cre workflow build, then pass it with --wasm:
cre workflow build ./my-workflow
cre workflow simulate ./my-workflow --wasm ./binary.wasm --target staging-settings
This leaves your workflow.yaml unchanged, so you can still let the CLI compile your source at any time. The --wasm flag is available on cre workflow simulate, cre workflow hash, and cre workflow deploy. For details on how simulate resolves the path, see Simulating with a pre-built binary.
Choose custom-build when you need to change how the binary is compiled. Choose build with --wasm when you only need to compile once.
Generated Makefile
The generated Makefile is ready to use. The only requirement is that make build produces wasm/workflow.wasm.
Go:
.PHONY: build
build:
GOOS=wasip1 GOARCH=wasm CGO_ENABLED=0 go build -o wasm/workflow.wasm -trimpath -ldflags="-buildid= -w -s" .
TypeScript:
.PHONY: build
build:
bun cre-compile main.ts wasm/workflow.wasm
Customizing the Makefile
Edit the generated Makefile to add any steps your build requires.
Example: Go with build tags:
.PHONY: build
build:
GOOS=wasip1 GOARCH=wasm CGO_ENABLED=0 go build -tags mytag -o wasm/workflow.wasm -trimpath -ldflags="-buildid= -w -s" .
Example: TypeScript with type checking, linting, and formatting:
.PHONY: build format lint typecheck
format:
bun run format
lint: format
bun run lint
typecheck: lint
bun run typecheck
build: typecheck
bun cre-compile main.ts wasm/workflow.wasm
Learn more
cre workflow custom-buildreference: Command flags and usage- Simulating Workflows: Testing your workflow locally
- Deploying Workflows: Deploying to the Workflow Registry