Angular main.js large file size with ES modules

498
2
Jump to solution
05-03-2023 11:48 AM
ShaneBuscher
Occasional Contributor

I'm working on an Angular 14 application which was using AMD modules via the CDN. I recently changed the app to use ES modules instead. The app works properly but I noticed a significant change in the size of main.js from 773 KB (AMD) to 3.9 MB (ES):

ShaneBuscher_0-1683137733473.pngShaneBuscher_1-1683137814101.png

I didn't make any other changes. Wondering why the size of main.js increased after converting to ES modules and how to slim it back down?

@AndyGup ?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
AndyGup
Esri Regular Contributor

Hi @ShaneBuscher  the size increase is because AMD modules are only being loaded at runtime, and they are not included in the app bundles. The ES modules (@arcgis/core) are being included and bundled along with the app. Here's a bit more info on bundle size: https://github.com/Esri/jsapi-resources/tree/main/esm-samples#bundle-size-and-performance. The app will only use the modules that it needs at runtime.

View solution in original post

0 Kudos
2 Replies
AndyGup
Esri Regular Contributor

Hi @ShaneBuscher  the size increase is because AMD modules are only being loaded at runtime, and they are not included in the app bundles. The ES modules (@arcgis/core) are being included and bundled along with the app. Here's a bit more info on bundle size: https://github.com/Esri/jsapi-resources/tree/main/esm-samples#bundle-size-and-performance. The app will only use the modules that it needs at runtime.

0 Kudos
ShaneBuscher
Occasional Contributor

Makes perfect sense. Thanks!

0 Kudos