AOT & Roll-Up: Only bundles main.js and nothing else AOT & Roll-Up: Only bundles main.js and nothing else typescript typescript

AOT & Roll-Up: Only bundles main.js and nothing else


In your [visual studio project]/scripts/aot folder, there should be a main.ts file, visual studio will compile it to main.js using tsconfig.json but not tsconfig-aot.json, check your main.js file, if it looks like

"use strict"; var platform_browser_1 = require("@angular/platform-browser"); var app_module_ngfactory_1 = require("./app.module.ngfactory"); platform_browser_1.platformBrowser().bootstrapModuleFactory(app_module_ngfactory_1.AppModuleNgFactory);

you need to update in your tsconfig.json:

    {     "module": "commonjs",    }

to

   {     "module": "es2015",   }


I also was following the official angular2 AOT guilde myself and due to lack of a simple working example I have created this github repository. I hope it helps you.

If you are a windows user, you should definitely be able to get it working in git-bash terminal (tested by me).


For AOT to work, you'll need to ensure that you're generating es6 module loading syntax:

Rollup can only Tree Shake ES2015 modules which have import and export statements.

tsconfig.json:

{    "compilerOptions" {        "module": "es6",         ...     }}