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

Allow to import pipe selectively #215

Closed
unsafecode opened this issue Dec 3, 2018 · 6 comments
Closed

Allow to import pipe selectively #215

unsafecode opened this issue Dec 3, 2018 · 6 comments

Comments

@unsafecode
Copy link

Description of the Issue and Steps to Reproduce:

Looks like the current implementation always imports all the pipe, making the final bundle excessively large:

image

It would be better to be able to import pipes in a more selective way, in order not to increase the final app size including unused code.

Environment:

Please answer the following questions:

  • Angular version? 7.1.0
  • TypeScript version? 3.1.6
  • ng-xdate-fns version? 2.0.3
@joanllenas
Copy link
Owner

Hi @unsafecode , thanks for reporting.
I'll take a look ASAP.

Cheers!

@joanllenas
Copy link
Owner

Hi @unsafecode
I upgraded to Angular 7 hoping that tree shaking would have been improved somehow but I'm having the same issues.

Not sure if there's something I can do until date-fns v2 is released.
Take a look at this: https://github.com/date-fns/date-fns/blob/master/docs/esm.md

Suggestions / PRs are welcomed!

@gmanoj26
Copy link

@joanllenas : As date-fns v2 is released. do we have any update on this open issue.

@joanllenas
Copy link
Owner

Hi @gmanoj26 ,
I took a look a while ago and didn't find a solution to the problem. V2 by itself didn't solve the issue.
Maybe, for this to work we need something like what this article suggests; one pipe per module; but I think it's not a good idea given the number of pipes this library contains.

I'm open to discussing possible solutions if someone has the time to investigate.

@joanllenas
Copy link
Owner

I added a section about tree shaking in the docs.
I hope this helps: https://github.com/joanllenas/ngx-date-fns#tree-shaking-date-fns

@KingDarBoja
Copy link
Contributor

In order to make each pipe tree-shakable, those must be provided as secondary entry points (as stated by the article, 1 pipe per entry point / module). It can be easily done using ng-samurai schematics.

Willing to look into this as I am using this library but not being tree-shakable atm.

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