Open sffc opened 1 year ago
How about this:
If you want to tree-shake, just use the free functions
@mosuem found that Dart has better DCE than I was able to get in JS.
@mathiasbynens suggested looping in @domenic about how to enable more effective DCE by putting functions into individual modules.
Hmm I don't think I have any special expertise here... not sure why I was recommended :)
I'll put this on Backlog for now until we have a clear client we can work with to improve the DCE in JS/TS.
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: https://github.com/rollup/rollup/issues/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:
P.S. In terms of bundlers, I had the best luck with
rollup
for handling async dependencies. Usingwebpack
resulted in a lot of unused classes being included because it doesn't seem to DCE along async dependencies.Discuss with:
Optional: