Description
When building optimized WASM files, we rely on a good DCE algorithm for the target language. When JavaScript is the target, I've been able to tree-shake at least down to the class level; however, it seems that tree-shaking doesn't work lower than that. This means that all of the functions on ICU4XFixedDecimal, for example, are still present in the bundle and therefore linked into WASM.
Good discussion on this: rollup/rollup#349
It does seem that the Closure Compiler can support this, but when I tried it didn't seem to work for me. Probably spending more time on this could make it work.
A few paths forward:
- Continue investigations into a method that tree-shakes class functions using Closure Compiler.
- Investigate and/or implement alternatives, perhaps relying on TypeScript.
- Change Diplomat codegen so that each function is standalone, rather than in a class.
P.S. In terms of bundlers, I had the best luck with rollup
for handling async dependencies. Using webpack
resulted in a lot of unused classes being included because it doesn't seem to DCE along async dependencies.
Discuss with:
Optional:
- Someone who knows a lot about JS/TS and build systems