Im looking for some help/tips for figuring out what takes up so much space in my Motoko WASM output. The main issue is that I am going over the 2MB cap and I have many MOPS packages referenced and can’t seem to figure out the specific dependencies/code that are the issue or can be slimmed down. Manual inspection has been no luck and inspecting the WASM hasn’t been fruitful, except for one thing that I will mention below
- I can cut my WASM size from 2.6 MB to 1.8 MB with ‘trimming’ the WASM of ‘local names’ and ‘function names’ using wasm-strip, which seem to be debugging artifacts, but they get generated when i use --release. Not sure if there is a setting to fix this or what I am doing wrong
- I have tried to use a script to iterate through all the modules to build a WASM for each and find the big ones, but the big ones are ususally just the main files and I can’t tell the size of each imported module because multiple modules might share the same code, so its hard to tell
- One issue i know of is the multi versioning of the same dependency from having to do version pinning to stop things from breaking, but that means if another library references a slightly different version, i essentially double to size. see Dependecy Hell. I have tried to fix this by getting all of my libraries on the same versioning scheme, but the issue is using other’s libraries along side it
- Are there any specifics that would be helpful to know? like limitations of tree shaking/optimizations or how to organize modules for leaner/a la carte?
- Are there any useful tools that exist in the Motoko compiler that could give me insight into some of this data?