angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

It takes forever in "92% chunk asset optimization" can it be cached or disabled?

Open marcalj opened this issue 9 years ago • 84 comments

Bug Report or Feature Request (mark with an x)

- [x] feature request

Versions.

@angular/cli: 1.0.0-rc.2 node: 6.9.2 os: darwin x64 @angular/common: 2.4.10 @angular/compiler: 2.4.10 @angular/core: 2.4.10 @angular/forms: 2.4.10 @angular/http: 2.4.10 @angular/platform-browser: 2.4.10 @angular/platform-browser-dynamic: 2.4.10 @angular/router: 3.4.10 @angular/cli: 1.0.0-rc.2 @angular/compiler-cli: 2.4.10

Desired functionality.

assets optimization it rarely changes when you only do coding, and specially for my project it takes 2-5 minutes each time. So it's killing my productivity. With "--verbose" it doesn't show me any specific files which I could remove temporally to speed up the process of compiling...

Hash: 51ba5014dae3bd179ab9                                                                 
Time: 395021ms
chunk    {0} main.bundle.js, main.bundle.js.map (main) 10.8 MB {4} [initial] [rendered]
chunk    {1} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 278 kB {5} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 751 kB {5} [initial] [rendered]
chunk    {3} scripts.bundle.js, scripts.bundle.js.map (scripts) 362 kB {5} [initial] [rendered]
chunk    {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.44 MB [initial] [rendered]
chunk    {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

Thanks.

marcalj avatar Mar 31 '17 09:03 marcalj

My AOT build takes 362 seconds on Google's Compute engine, 1 CPU, 6.5 Gig Ram. Adding more cpus hasn't really made any difference.

On my personal computer, it takes about 210 seconds to build the app, which is strange, because it's a 5-year old i7-3660 (OC'd to 4.2ghz, but still).

Honestly, this makes deployment frustrating, especially when you get a Javascript Heap Error and you've been waiting 6 minutes just to discover that.

As an aside, I think ng build's with aot should set the node memory for you, or you really ought to add this to your default package.json just to make things easier for people:

"build-prod": "node --max-old-space-size=8192 node_modules/@angular/cli/bin/ng build --prod --aot",

egervari avatar Dec 05 '17 14:12 egervari

92% chunk asset optimization

image

I'm already ordering some! 😂

paulmelero avatar Feb 06 '18 11:02 paulmelero

Running into the same issue here, it stops in 94%. Can we customize the shirt @gangsthub? :smile:

allanesquina avatar Feb 15 '18 19:02 allanesquina

You should stop complaining, update your Angular CLI, fix your AOT build warnings and use AOT also for debugging, since it now supports debugging:

ng serve --aot

And try to keep up with the Angular CLI releases, things are getting better day by day.

P.S. Thanks to everyone working on this!

EDIT: With AOT the initial build is slow, subsequent builds are a lot faster.

SchnWalter avatar Feb 16 '18 12:02 SchnWalter

I use Angular 6 with an extremely large enterprise project.

ng build --aot --prod

Time: 780178ms

Way too long

bluefire2121 avatar May 09 '18 19:05 bluefire2121

@bluefire2121 --aot makes it a little slower but it's totally worth it for the end user, IMO. Do you have a lot of assets? (just curious to know were the bottleneck is)

ng serve --aot is great advise by @SchnWalter

paulmelero avatar May 10 '18 08:05 paulmelero

@gangsthub I have 6.06MB of assets. I had initially created an API CDN to connect to my assets, but I had to scrap that plan due to CORS restrictions on our intranet. The assets have to exist on the same server domain. .gitignore and .tfignore both include node_modules so I'm unsure what could be causing the issue. We have lots of components, services, classes, and templates, but the initial compile shouldn't be that long.

bluefire2121 avatar May 11 '18 17:05 bluefire2121

I wonder if this "92% chunk asset optimization" problem is related to this performance regression on uglify-es (now terser). I was also seeing "92%" for a long time as a result of that issue.

mlwilkerson avatar Jun 07 '18 22:06 mlwilkerson

For me manually patch the "node_modules\uglify-es\lib\compress.js" like @mlwilkerson said for the issue https://github.com/fabiosantoscode/terser/issues/50 works : 26sec to build --prod --aot

cub avatar Jun 08 '18 08:06 cub

You can use this flag while compiling: ng serve --source-map=false

It take 10sec to compile now while previously it was taking 32sec. source-map is just used for debugging. So if not using debugger you can disable and compile.

anothershubham avatar Jun 22 '18 10:06 anothershubham

@spmsupun that hint was super good: But I'd recommend to use: --build-optimizer=true along with --vendor-chunk=true. I also added the --extract-css=true

ng build --aot --extract-css=true --build-optimizer=true --vendor-chunk=true --prod

The main chunck goes (with only --aot --prod) from 2.37MB to 734kB 😊

Also, timing, wich is what we were discussing decreases a little bit: from 120s to 70s.

paulmelero avatar Jul 05 '18 14:07 paulmelero

this is the ram problem, you need to increse your ram or free ram.

mrhrao avatar Jul 11 '18 09:07 mrhrao

@mrhrao It is not a "ram problem" for me.

I'm trying to build and serve for debugging purposes. I'd like to AOT as well, but can live without it.

I'm using a configuration in my angular.json to set environment variables for my test machine:

configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true
        },
        "dev": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.dev.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": true,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true
        }
      }
    },

It takes forever (minutes) to compile. My command line is: node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve ui -c dev --aot

I have current versions of all angular packages (as of 2018-07-12) "@angular/cli": "^6.0.8"

I have 562 files in my src folder.

Any ideas?

kdubious avatar Jul 12 '18 20:07 kdubious

@filipesilva Can we re-open this issue? Or direct me to a good one that's open?

kdubious avatar Jul 13 '18 13:07 kdubious

I get stuck at 92% chunk asset optimization UglifyJSPlugin seemingly forever (I left it overnight and it never passed).

This seems to only be an issue when using WSL (Windows Subsystem for Linux) as I'm able to build it appropriately in Docker containers or even using git-bash.

Empereol avatar Jul 19 '18 15:07 Empereol

I am also experiencing this with a new Angular 6 project. It ONLY takes forever when I build for prod with --prod. When I don't do a prod build, it goes super fast and smooth. Anybody ever figure this out?

hlohrenz avatar Jul 21 '18 20:07 hlohrenz

Also got this problem. It takes 25 minutes to build project. Was 2-3 minutes before.

BigSakoLol avatar Jul 21 '18 20:07 BigSakoLol

Same issue when deploying Angular 6 application to Heroku using ng build --prod Getting stuck at 92% chunk asset optimization UglifyJSPlugin for at least 5 min

ochadenat avatar Jul 28 '18 21:07 ochadenat

same issue with webpack production

nimatrazmjo avatar Jul 31 '18 05:07 nimatrazmjo

This is becoming quite the running gag. Stuck on 92% chunk asset optimization UglifyJSPlugin on gitlab while it's quite acceptable when building locally, even with the --prod flag.

rwlnd avatar Jul 31 '18 09:07 rwlnd