Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Provide an es import compatible build #1044

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

Closed
ianks opened this issue Jan 19, 2017 · 4 comments
Closed

Provide an es import compatible build #1044

ianks opened this issue Jan 19, 2017 · 4 comments

Comments

@ianks
Copy link

ianks commented Jan 19, 2017

Looking at my build, currently Immutable takes up 139.14 KB. I only use a few things from Immutable, so it would be nice to only pay for what I use.

Proposed solution

Provide an es6 build which compiles everything down except for modules, much like react-router, reselect, redux, etc. This way, the user can rely on their module bundler to perform tree shaking to only include what is neccesary.

Would this be possible to implement?

@simonkberg
Copy link

Worth noting is that Immutable greatly benefits from gzipping, so the actual size comes down to 15.21 kb (with level 9 compression).
That said I definitely think it would make sense to provide a build preserving ES modules for tree-shaking purposes (and/or the top-level API as individual CJS modules we could import selectively).

@leebyron
Copy link
Collaborator

Yeah this would be great to have, but it's not easy to implement incrementally - some breaking changes would be necessary.

Specifically right now all types have a toList() and toMap() etc methods which convert between various collection types. That ties all of the library together and tree shaking typically isn't smart enough to trim prototype methods as well. A breaking major version change would be necessary to remove these methods to enable tree shaking.

However I don't actually think you would shave much from the ~15kb build already. That's roughly split into thirds: Map, List, and everything else.

@leebyron
Copy link
Collaborator

leebyron commented Mar 8, 2017

Merging into #317

@moravcik
Copy link

I have just one note regarding toList() and toMap() methods on all types.

Maybe RxJS operators are similar case: import 'rxjs/add/operator/switchMap' adds switchMap operator to Observable interface in ES import/export friendly way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants