-
Notifications
You must be signed in to change notification settings - Fork 153
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
Big impact on compilation time and the chunk size with the pro packages #34
Comments
Are you using the latest Angular CLI and FA packages? Do you use AoT or JiT compilation? There is an increase in the build time when using imports from main, but 10 minutes sounds like too much, normally I would expect 1-2 minutes. Also bundle size should only increase ~40K, when importing only 1 icon. Can you create a reproduction repository, where we can reproduce "Importing only one icon from the pro packages, results in a 1MB plus in the bundles"? Ideally it should be a new Angular CLI application with minimal code needed to reproduce the problem. In general I've also spotted the problem before. For now I stick with deep imports of every icon in my projects, e.g. IIRC the root cause is that UglifyJS has to tree shaken 99% of the file with icon definitions and it takes a lot of time. There are some changes, which can potentially improve the situation:
|
@devoto13 Thank's for your answer, I updated with a reproduction repo. |
I can also confirm that deep imports of every icon solved the problem, time is now 20 times shorter. |
I have this same issue, but I use the The problem I'm facing however is that when I perform a deep import like this:
It works just fine in develop, but when doing a prod build (using
|
@robbaman the Can you switch to the |
I'll take a look when I'm back at work. Note though that it actually does work when using this import statement:
Thanks for the update though, I'll check back in once I've had an opportunity to try your suggestion. Probably won't be before Sunday evening though. |
I've updated my project using the steps specified in the Using deep links ea:
instead of
Does seem to fix the package size issue and make the build time acceptable, but obviously this isn't exactly a pretty solution :) |
same here MurhafSousli/ngx-sharebuttons#280 Isn't it applicable to export the icons the same way rxjs 6 does with the operators? |
@robbaman Yes, I've been working on that "92% issue", as has @devoto13. For now, a workaround is to swap out UglifyJS for Babel Minify. See my reproduction and discussion of this over in the uglifyjs-webpack-plugin repo. |
@robmadole You mentioned switching to the According to the documents at https://fontawesome.com/how-to-use/use-with-node-js the correct npm package to use is the I ask because I noticed a new version being out (5.0.13), which I seem to be unable to use in my project because I have to use the Any clarification on this point would be great. |
@robbaman To view the equivalent documentation for the preview release, add "preview" to the url like this: The reason you'll see more recent releases on the 5.0 branch is because we continue to issue maintenance releases. |
@robbaman Is there something (like a new icon?) in the 5.0.13 release of |
@mlwilkerson Thanks for clearing that up. There wasn't anything in particular that I'm missing, I was just using This led me to investigate and get lost in the package-forest... |
Ah, the package-forest, which grows ever more deep...and dark. |
We totally should get an icon for that! But for now I'll stop spamming this useful topic with my ignorant questions... |
@robbaman we aren't updating the |
For others who hit the |
Looks like Webpack will be released this week with |
I've found a fix for me. Before I imported the icons in the component, this took 30 minutes to build with
Now instead it takes 12s. It's still twice as long as it took before. But it's good enough. my
|
Angular CLI 7.0.0-beta.2 (make sure you also update Please give it a try and let me know if it works for you as well. |
Ah excellent. Good to know @devoto13 |
@devoto13 Thank you. I had to update other packages as well to get it to work. I updated @angular/* to 7.0.0-beta.7, @angular-devkit/build-angular to 0.9.0-beta.2, and typescript to 3.0.1. |
Yeah, deep importing fixed this issue for me. |
Angular CLI 7+ uses terser as a minifier and therefore includes the fix for the slow compilation. Please open a new issue with the reproduction if you still experience slow builds using Angular CLI 7+. If you're stuck with an older version you can use deep imports approach as a workaround. |
Unfortunately deep importing still has a significant effect on the decrease of the resulting chunk size (~200kB for @fortawesome/free-solid-svg-icons after gzipped). |
@kimamula How do you measure this? Is it |
@devoto13 Thanks for the response. I think I can provide a simple repro when I have time. |
@kimamula I see. Repro would be super useful! Thanks! |
@devoto13 I am sorry that I found that this was totally my fault. |
@kimamula Happy to hear that you solved it! And thanks for letting us know what problem was. |
I reduced @FortAwesome bundle size in angular project from 1.1mb to 139.27kb by changing imports of 5 icons from |
Importing only one icon from the pro packages, results in a 1MB plus in the bundles and 10 minutes additional compiling time.
Here is a minimal code to reproduce the issue :
`import { NgModule } from '@angular/core';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { library } from '@fortawesome/fontawesome-svg-core';
import { faCircleNotch } from '@fortawesome/pro-regular-svg-icons';
library.add(faCircleNotch);
@NgModule({
imports: [FontAwesomeModule]
})
export class IconModule {}
`
Import this module in the
app.module.ts
.I have the same behavior with smaller impact with the free packages, probably because it has less icons.
Here is a reproduction repo :
https://github.com/ibenjelloun/angular-fortawesome-issue34-reprodution
after the clone just update the .yarnrc with the fontawesome registry or replace pro by free in the icon.module.ts.
run
yarn
+yarn bundle-report
The text was updated successfully, but these errors were encountered: