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

ng serve, high file sizes and long loading time.

Open bwqr opened this issue 8 years ago • 7 comments

Versions

Angular CLI: 1.6.3
Node: 6.11.4
OS: win32 x64 / Windows 10
Angular: 5.1.2

Repro steps

This is my project link

Observed behavior

Before the version 1.5.0, ng serve command's output files' sizes are not so large. I'm talking about 6-7 mb. After upgrading to Angular 5 and angular-cli 1.6.3, my vendor file's size gets like 19 mb which takes chrome javascript runtime like 10 seconds after each code change - you have to wait chrome to get page loaded. Moreover, chrome uses RAM so much - 400 mb.

I have tried downgrading angular-cli step by step. First tested the 1.5.5 which gives same result. When trying 1.4.9, same project's vendor file size gets 6 mb.

You can check dependencies from project link. But I think it has nothing to do with dependencies.

bwqr avatar Dec 29 '17 15:12 bwqr

The increase in the vendor file size on ng serve happens because on CLI 1.5+ we use a different sort of sourcemaps.

Before we had them in a separate file (vendor.bundle.js + vendor.bundle.js.map) but now we have them in the same file (just vendor.bundle.js) which makes rebuilds faster.

I wasn't really expecting it to take much longer to load on the browser though.

Is the browser load after rebuild is finished faster if you run ng serve --no-sourcemaps?

filipesilva avatar Dec 29 '17 17:12 filipesilva

I have seen the same. My results with @angular/cli": "1.6.3"

Date: 2017-12-29T19:41:21.487Z
Hash: 844ff85f69257af1fcfe
Time: 625ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry]
chunk {main} main.bundle.js (main) 3.18 MB [initial]
chunk {polyfills} polyfills.bundle.js (polyfills) 1.7 MB [initial]
chunk {styles} styles.bundle.js (styles) 790 kB [initial]
chunk {vendor} vendor.bundle.js (vendor) 23.2 MB [initial]

versus "@angular/cli": "1.4.3"

Date: 2017-12-29T19:36:16.692Z
Hash: 8950b431dcd5ce28a735
Time: 27377ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 1.19 MB {vendor} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 607 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 282 kB {inline} [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 8.69 MB [initial] [rendered]

Perhaps the confusion is this line: vendor.bundle.js, vendor.bundle.js.map (vendor) 8.69 MB. Was this file size listed the combine file size or just the file size of vender.bundle.js?

Of course the build time is much faster which is great.

jokecamp avatar Dec 29 '17 19:12 jokecamp

@filipesilva I am appreciated with your fast response and you have solved the problem.

After running your command, now file size decreased to normal level, 7 mb. Now every thing works as expected.

Thank you!

@jokecamp, yes the problem is the map file. I didn't notice that.

bwqr avatar Dec 29 '17 19:12 bwqr

@jokecamp the old stats only listed the size of the .js file. I agree that is confusing though...

@Blowedminds please be aware that --no-sourcemaps does disable sourcemaps... so if you need to debug you're going to want to turn it back on. Do you notice a difference in load time though?

filipesilva avatar Dec 29 '17 20:12 filipesilva

@filipesilva Difference in loading time between w/o sourcemap is 2-3 seconds. I think 3 seconds does not matter, however chrome ram usage is so high. I'm running multiple angular apps and other applications. I can reach so easily to my memory limits - 8 gb. Is there any way to debug like in 1.4.*?

bwqr avatar Dec 30 '17 06:12 bwqr

I'm seeing a browser crash in Edge because of this file size. With sourcemaps on size is 31.1MB which leads to a crash in Edge. Without source maps size is 11.9MB and site loads perfectly. Any solution to this problem? If we would need to debug Edge in the future this will be a problem..

Joja avatar Feb 02 '18 12:02 Joja

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.