Dfx.json build scripts

It would be really nice to be able to write my own scripts that are executed as part of the dfx build or dfx deploy commands. For example, I have just run into the issue where my Rust binary is too large for dfx to accept it. The solution for now has been to use ic-cdk-optimizer, but running that tool requires me to setup my own process to run the optimizer after the original wasm binary has been created. I could use the “build” field of the dfx.json, but that would require me to setup a cargo flow that I would prefer to avoid.

So for now I’m going to invite myself and others who use Sudograph, when their binaries get too large (will easily happen as GraphQL schemas increase in size), to create npm scripts to deploy instead of using dfx deploy.

I also think post-build and pre-build scripts would be great, I’ve written previously about this here: Configure pre-build and post-build npm scripts

1 Like

Hey @lastmjs,

I ran into that limitation with your sudograph canister in my project. The wasm is 2.5MB, and I’m not able to deploy it. But if i use ic-cdk-optimizer I can get it down to 1.4MB. But I’m not able to deploy that with dfx install. What process do you use to deploy the wasm created with ic-cdk-optimizer?

I’ll add to this some QoL improvements by enabling more verbosity in the error messages. There are some instances with paths where the error messages are pretty opaque, and you have to do a lot of guesswork to find the source of the error.

The post-build step failed for canister <> with an embedded error: No such file or directory (os error 2)

Without knowing which file is missing, that error message is pretty unhelpful :slight_smile:

Nevermind, I found the solution Default generated rust project errors

In general it would be nice to be able to create canisters where the binary is bigger than 2MB. Are there any plans in the future to enable this?

3 Likes

Has the dfx deploy process been upgraded to allow build scripts yet?