Package splitting
dave opened this issue · 0 comments
dave commented
The jsgo compiler uses GopherJS to compile Go to Javascript. It splits the output by Go package, meaning each package is individually cached by the browser. This has benefits:
- Several projects that use the
fmtpackage will share the samefmt.jsscript. - Deploying a small change to a project will result in clients only re-downloading the javascript for packages with changes.
Unfortunately the Go compiler doesn't support the same package splitting, so this isn't possible in the WASM version.
This ticket is to track any possible work-arounds.
Two possibilities have been researched:
- Fork the Go compiler and modify it to emit the WASM binary for each package separately.
- Split the WASM binary after it's been created by the Go compiler.
I worked on forking the Go compiler for a couple of weeks, but as expected there were huge issues. I'm not planning to continue work on this. See here for progress.
@dennwc worked on the WASM binary splitter, but came across problems. However, this is the preferred option for anyone who wants to help. See here for progress.