How can we get the wasm file of the module without deploying it?
For example, these modules are created/derived from the Root Canister/ Parent Canister, and these submodules have many initialization parameters, and they all make sense.
We cannot create the Canister of this module through dfx deploy, or we need to build a meaningless initialization parameter to create a meaningless Canister.
I think these are not necessary, we just want to package the module code and generate a wasm file for updating the online canister.
How to do it? Here we go!
First, we need to declare the submodule in the dfx.json
file (not for direct dfx deploy)
"spark_user": {
"main": "src/spark_backend/user.mo",
"type": "motoko"
}
Then, we start the local dfx
dfx start --background --clean
We need to execute the canister creation command to create a local canister for the submodule (just to have a canisterid, otherwise it cannot be built)
dfx canister create spark_user
After execution, we execute the build command to generate the wasm file
dfx build spark_user
Finally generate the wasm file path (workdir: project root directory)
./.dfx/local/canisters/module-name/spark_user.wasm