I want to compile a main.go file down to javascript code and import it into the frontend. This works fine, but the resulting js file is massive. The main file I’m using depends on 10 files, which together collectively amount to around 10k lines of code. However, most of this code is not needed by the functions in my main.go file.
Does anyone know of any way to compile my file such that it only takes the bare minimum code needed from these other 10 files to compile correctly (so that the resulting generated js file becomes significantly smaller?)
Unfortunately the -m flag minifies the resulting javascript - it does not eliminate dead / unused code.
I was able to find an outstanding open issue in gopherjs here: https://github.com/gopherjs/gopherjs/issues/186 that addresses my question, but there there doesn’t seem to be a resolution yet. I’ll keep looking but it seems like I might need to roll my own modified compiler or something.