Kai, I believe you are confusing classes with modules. A module can have many exports. For example, you could export 5 different classes from a single module. If you only import one of those classes, tree shaking ensures you don't include the other 4 unused Classes.
I think what you might be referring to is that tree shaking can't eliminate methods on a class that are potentially not called by a user. However that by no means makes tree shaking not valuable even when using libraries that export classes. Finally, in my personal experience the amount of performance improvements you can make from dead code elimination are far from negligible. Of course it depends on many factors, but it is an incredibly useful feature. On Tue, Dec 12, 2017, 9:54 PM kai zhu <[email protected]> wrote: > we're talking about the same thing. class-based libraries like backbone.js > for example cannot be tree-shaken. i've done manual tree-shaking for the > entire frontend-stack for swagger-ui, by writing tests and doing > deadcode-elimination from code-coverage. the takeaway from that was most > of its libraries could not be tree-shaken, until the underlying class > methods and constructors were manually refactored into separable > static-functions. > > On Dec 13, 2017 12:08 PM, "Darien Valentine" <[email protected]> > wrote: > >> > tree-shaking is incompatible with class-inheritance and >> meta-programming in javascript. it has negligible effect in practice, >> unless the majority of your code uses static-functions instead of classes. >> >> It’s just a form of dead code elimination that takes advantage of the >> fact that imports/export statements are static. More often useful for >> library code than local app code (since if you had unused stuff there, >> you’d likely just delete it). I’m pretty perplexed by the suggestion that >> it has any sort of relationship with classes or inheritance. Are we talking >> about different things? >> >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> >> _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

