Angular-cli: --prod is increasing the build size rather than reducing it, and it seems tree shaking is not happening

Created on 29 Nov 2016  路  4Comments  路  Source: angular/angular-cli

OS?

Windows 7

Versions.

angular-cli: 1.0.0-beta.21
node: 7.2.0
os: win32 x64

Repro steps.

ng new aottest
cd aottest
ng build -> dist folder is 4,79 MB
ng build --prod -> dist folder is 6,47 MB
ng build --aot -> dist folder is 2,80 MB
ng build --aot --prod -> dist folder is 3,66 MB

The log given by the failure.

using --prod also dumps a whole lot of yellow lines like these:

Condition left of || always false [C:/Workspace/aottest/~/zone.js/dist/zone.js:5 38,0] Condition left of || always false [C:/Workspace/aottest/~/zone.js/dist/zone.js:5 41,0] Side effects in initialization of unused variable Zone$1 [C:/Workspace/aottest/~ /zone.js/dist/zone.js:23,0]

Mention any other details that might be useful.

Just created this project to try to figure out why my actual project can't --aot, just happened to stumble on the fact that --prod was increasing the build rather than reducing it

Most helpful comment

--prod includes source maps. Something that the client wont download unless they're using dev tools in chrome etc. That's the reason the dist folder increases.

Check each js file instead to compare sizes. Or even better, the js.gz files as that's what the client will be downloading.

Current beta has a broken --no-sourcemap argument which already has been fixed and be included in the next release if you want to disable sourcemaps for prod.

Edit: About the yellow lines. That's tree shaking doing its thing. Removing dead code.

All 4 comments

--prod includes source maps. Something that the client wont download unless they're using dev tools in chrome etc. That's the reason the dist folder increases.

Check each js file instead to compare sizes. Or even better, the js.gz files as that's what the client will be downloading.

Current beta has a broken --no-sourcemap argument which already has been fixed and be included in the next release if you want to disable sourcemaps for prod.

Edit: About the yellow lines. That's tree shaking doing its thing. Removing dead code.

Makes sense, I guess this can be closed then. Do I have to do something like I would have to accept an answer in stackoverflow?

You can simply close the issue. :)

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brtnshrdr picture brtnshrdr  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

purushottamjha picture purushottamjha  路  3Comments