Angular2 CLI: why bind the size of "-prod" less than "-prod -aot"?

I am using the latest angular-cli (beta-18) for the project. I know that cli is still in its very early stages, but I wonder why my last packet size is smaller than AoT.

When I run ng build --prod , it is 1.08 mb:

  Asset Size Chunks Chunk Names main.53d637ff9422b65418e6.bundle.js 1.08 MB 0, 2 [emitted] main styles.01cffb95000fdb84402c.bundle.js 8.9 kB 1, 2 [emitted] styles inline.js 1.45 kB 2 [emitted] inline main.53d637ff9422b65418e6.bundle.map 7.24 MB 0, 2 [emitted] main styles.01cffb95000fdb84402c.bundle.map 40.3 kB 1, 2 [emitted] styles inline.d41d8cd98f00b204e980.bundle.map 13.5 kB 2 [emitted] inline main.53d637ff9422b65418e6.bundle.js.gz 236 kB [emitted] index.html 907 bytes [emitted] assets/.npmignore 0 bytes [emitted] favicon.ico 5.43 kB [emitted] 

When I launched ng build --prod --aot , it is 1.26 mb.

  Asset Size Chunks Chunk Names styles.01cffb95000fdb84402c.bundle.map 40.3 kB 1, 2 [emitted] styles 0.688d48f52a362bd543fc.bundle.map 2.94 kB [emitted] styles.01cffb95000fdb84402c.bundle.js 8.9 kB 1, 2 [emitted] styles inline.js 1.45 kB 2 [emitted] inline main.6490041404a193461c3c.bundle.map 6.81 MB 0, 2 [emitted] main main.6490041404a193461c3c.bundle.js 1.26 MB 0, 2 [emitted] main inline.d41d8cd98f00b204e980.bundle.map 13.5 kB 2 [emitted] inline main.6490041404a193461c3c.bundle.js.gz 223 kB [emitted] index.html 907 bytes [emitted] assets/.npmignore 0 bytes [emitted] favicon.ico 5.43 kB [emitted] 

For tsconfig it looks like this:

 { "compilerOptions": { "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es6", "dom" ], "mapRoot": "./", "module": "es6", "moduleResolution": "node", "outDir": "../dist/out-tsc", "sourceMap": true, "target": "es5", "typeRoots": [ "../node_modules/@types" ] }, "exclude": [ "**/*.spec.ts" ] } 
+5
source share
2 answers

I answered a question on our GitHub , but here is my answer for reference:

If you use certain libraries that do not support AoT (and release UMD packages), this may happen. The reason is that we cannot optimize components that are pure JavaScript. Unfortunately, this is not something we can fix on our side.

These libraries must expose ES2015 modules with the removal of their decorators, and their components / modules are already compiled by AoT. We are working on recommendations for libraries to support compilation of JIT and AoT.

Also, sometimes with some templates, the AoT size may be larger than the JIT. The gzipped options should be the other way around, since most of the AoT content is the same statements that are repeated over and over.

Although the package is larger, the boot time should be significantly faster.

+5
source

The generated JavaScript template is much larger than the template itself. This is the file size compared to a situation of compromising runtime.

+1
source

Source: https://habr.com/ru/post/1258671/


All Articles