Skip to content

feat(motoko): migrate templates to @dfinity/motoko@v5.0.0 mops-build recipe#28

Open
marc0olo wants to merge 2 commits into
mainfrom
feat/motoko-v5-mops-canisters
Open

feat(motoko): migrate templates to @dfinity/motoko@v5.0.0 mops-build recipe#28
marc0olo wants to merge 2 commits into
mainfrom
feat/motoko-v5-mops-canisters

Conversation

@marc0olo

@marc0olo marc0olo commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

Prepares the three Motoko templates for the upcoming @dfinity/motoko@v5.0.0 release, which delegates compilation to mops build and requires canister definitions to live in mops.toml.

  • motoko/ — adds [canisters] in mops.toml; removes main/candid from icp.yaml (no recipe configuration: block needed)
  • hello-world/motoko-backend/ — adds [canisters.backend] in mops.toml; removes main/candid from canister.yaml
  • bitcoin-starter/motoko-backend/ — same as hello-world; preserves existing [dependencies] section
  • Bumps moc toolchain to 1.8.2 across all three templates

Closes #27

Migration guide (before/after)

Before (icp.yaml / canister.yaml) After (mops.toml)
main: src/main.mo [canisters.backend] main = "src/main.mo"
candid: backend.did [canisters.backend] candid = "backend.did"
args: --incremental-gc [canisters.backend] args = ["--incremental-gc"]

The canister name in icp.yaml is used automatically — no name: param needed in the recipe configuration.

🤖 Generated with Claude Code

marc0olo and others added 2 commits May 26, 2026 14:10
…recipe

Move canister definitions (main, candid) from icp.yaml/canister.yaml into
mops.toml [canisters] sections and replace main/candid recipe params with
a single `name` param, as required by the new mops build-based recipe.
Bumps moc toolchain to 1.8.2 across all three Motoko templates.

Closes #27

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
With _.canister.name now injected automatically by icp-cli (see
dfinity/icp-cli#567), the `name` configuration param is no longer
needed in recipe configs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marc0olo added a commit to dfinity/icp-cli-recipes that referenced this pull request Jun 9, 2026
## Summary

- Replaces direct `moc` invocation with `mops build`, aligning the
Motoko recipe with how the Rust recipe delegates to `cargo build`
- Toolchain, dependencies, compiler flags, candid, and per-canister args
all move to `mops.toml` — the recipe retains only icp-specific concerns
(output path, `moc:version`/`template:type` metadata, shrink, compress)
- Removes `main`, `candid`, and `args` recipe params — no replacement
needed, the canister name is injected automatically via
`{{_.canister.name}}`

## Breaking change

| Removed from `icp.yaml` | Moves to `mops.toml` |

|--------------------------|---------------------------------------------------|
| `main: src/main.mo` | `[canisters.backend] main = "src/main.mo"` |
| `candid: backend.did` | `[canisters.backend] candid = "backend.did"` |
| `args: --default-persistent-actors` | `[canisters.backend] args =
["--default-persistent-actors"]` |

New `icp.yaml` — no `configuration:` block needed:
```yaml
canisters:
  - name: backend
    recipe:
      type: "@dfinity/motoko@<version>"
```

New `mops.toml` — canister name must match `icp.yaml`:
```toml
[toolchain]
moc = "1.9.0"

[canisters.backend]
main = "src/main.mo"
candid = "backend.did"
```

## Test plan

- [ ] Build a canister using `mops build` with a matching `[canisters]`
entry in `mops.toml`
- [ ] Confirm `moc:version` and `template:type` metadata are present in
the output WASM
- [ ] Confirm `[moc] args` from `mops.toml` are respected (e.g.
`--default-persistent-actors`)
- [ ] Confirm `shrink` and `compress` options still work
- [ ] Confirm a clear error is shown when the `[canisters]` entry is
missing

> **Note:** `icp-cli-templates` needs a follow-up update to add
`[canisters]` to all Motoko `mops.toml` files. Tracked in
dfinity/icp-cli-templates#27 / dfinity/icp-cli-templates#28.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo marked this pull request as ready for review June 9, 2026 16:56
@marc0olo marc0olo requested a review from a team as a code owner June 9, 2026 16:56
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.

Update Motoko templates for new mops build-based recipe

1 participant