I’ve been using the next custom build.sh script
#!/bin/sh
CANISTER_NAME=$1
ENTRY_POINT=$2
mkdir -p .dfx/local/canisters/${CANISTER_NAME}
$(vessel bin)/moc ${ENTRY_POINT} -o .dfx/local/canisters/${CANISTER_NAME}/${CANISTER_NAME}.wasm \
-c --debug --idl --stable-types --public-metadata candid:service --actor-idl .dfx/local/canisters/idl/ \
--actor-alias ${CANISTER_NAME} $(dfx canister id ${CANISTER_NAME}) $(vessel sources)
ic-wasm .dfx/local/canisters/${CANISTER_NAME}/${CANISTER_NAME}.wasm -o .dfx/local/canisters/${CANISTER_NAME}/${CANISTER_NAME}.wasm shrink
gzip -f -9 .dfx/local/canisters/${CANISTER_NAME}/${CANISTER_NAME}.wasm
And dfx.json config
{
"canisters": {
"test": {
"build": "build.sh test test.mo",
"candid": ".dfx/local/canisters/test/test.did",
"type": "custom",
"wasm": ".dfx/local/canisters/test/test.wasm.gz"
}
}
}
It works fine with dfx 13.1 and lower but dfx 14 fails with an error
Failed during wasm installation call: The replica returned a replica error: Replica Error: reject code CanisterError, reject message Wasm module of canister bkyz2-fmaaa-aaaaa-qaaaq-cai is not valid: Failed to decode wasm module: unsupported canister module format, error code None
This custom build step serves 2 main purposes: gzip the WASM and install custom Motoko compiler.
The first one is no longer necessary with dfx 14 but, as far as I know, custom build is still the only option to install a different Motoko compiler.
Would appreciate any insight on how I can fix the error.