ok-computer
ok-computer copied to clipboard
Improve tree-shaking
Both rollup and webpack fail to efficiently tree-shake the codebase which, although very small, would be still be nice given it is side effect free.
I think it's related to curried functions being executed on import but also specifically seems to be related to newing up errors in and
, or
etc.
https://github.com/richardscarrott/ok-computer/pull/21
https://dev.to/livechat/tree-shaking-for-javascript-library-authors-4lb0
It seems introspectValidator
is problematic because it does in fact have a side-effect (throws), however it's only relevant if the return value is used so prob a legit case for PURE annotation, however it's all so brittle I think it'd be better to have a test which bundles w/ rollup and asserts the output.
Also, might want to try: https://github.com/Andarist/babel-plugin-annotate-pure-calls