Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate tree-shaking compatibility #27

Open
kosich opened this issue Oct 16, 2020 · 2 comments
Open

Investigate tree-shaking compatibility #27

kosich opened this issue Oct 16, 2020 · 2 comments
Labels
help wanted Extra attention is needed RnD

Comments

@kosich
Copy link
Owner

kosich commented Oct 16, 2020

As reported by @loreanvictor in #1, tree shaking might not be compatible with exporting $ and _ that share context variable with the computed fn.

Needs investigation.

@kosich kosich added help wanted Extra attention is needed RnD labels Oct 16, 2020
@loreanvictor
Copy link

I had a quick look (I was on the train so couldn't do more atm). From a first glance on an actual project bundled with webpack (default config, no particular optimization), rxjs-autorun seems to add ~12KB to the bundle size (rxjs itself adds about the same, nothing in particular imported from it). Inspecting the bundle (manually, not with a tool) indicates that no unused code is imported from rxjs though, so I am not sure if this is directly related to tree-shaking or not.

For comparison, I used callbag-subject and callbag-expr, which together contributed ~1.5KB to the bundle. I will create an equivalent package for rxjs-autorun mirroring implementation of callbag-expr, investigate its contribution to bundle size, and see where are the deficits. Note that I am not sure by any means whether this bundle size increase is due to problematic tree-shaking or is it due to other factors.

@kosich
Copy link
Owner Author

kosich commented Oct 19, 2020

Thanks for looking into this! I haven't yet debugged tree-shaking and am not sure how to do it properly.

I suspect, that RxJS imports are already optimized since we directly import the operators/constructors that are well-separated. So the tree-shaking won't be that obvious here.

If you're right and we aren't side-effect free, then I'm lying in package.json — something to be properly set after the investigation (I accidentally copy-pasted that with project set-up 🙂). Also, maybe setting it to false would mark only this package out of tree-shaking and still let others to be stripped.

Should be relatively easy to check our tree-shaking: just import only the autorun, shake it, and see what code is left in the bundle (do we have _$, context and computed?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed RnD
Projects
None yet
Development

No branches or pull requests

2 participants