I have set up a seed project with Angular 2 (RC.1) and system JS. I wanted to create a static single bundle for production and bundle everything except for my own code for development. This was my normal flow in past, before using systemjs. After bundling with gulp-jspm/systemjs-builder the bundle file was bigger than 2 MB (source) or 1.2 MB (minified). As this looked too big I've double checked using plain jspm CLI, but the file size was the same.
Command used was for dev mode:
jspm bundle app/bootsrap - [path/to/app/**/*] mybundlename.js --inject
Or for production:
jspm bundle app/bootstrap mybundlename.js
Having a 1.2 MB file on production seems too big if I want e.g. to run my web app on mobile browsers with limited bandwidth. Specially since this was was a bundle with almost no code of mine (just a bootstrap file and a main app-component). My Angular 1.5 app bundles were usually around 700kB for pretty big enterprise applications.
By looking at bundle itself I realized there are 540 files bundled. I'm pretty sure I don't need most of them.
Full config.js can be found here: https://plnkr.co/edit/BhYy5Pu1QbmYJ7Ph5rBO.
So finally my questions:
- Should files be bundled when using systemJS in a project or should I just leave them unbundled and let systemJS take care of lazy loading?
- If bundling is recommended how can I create a bundle that has sensible size and includes only the files my app actually depends on?