0

I need to put a website in production soon and am looking into the AOT to improve performance (my app needs about 3-4 secs to load on Chrome, 8-10 secs on Firefox, which is just not possible for production).

I followed the guide on https://angular.io/docs/ts/latest/cookbook/aot-compiler.html but am stuck with the compiling part...

If I type : node_modules/.bin/ngc -p tsconfig-aot.json I will get a nice "Compilation failed" with a list of around 100 hundred errors, like this one :

Error at /myapp/aot/app/contact/admin/contact-list.component.ngfactory.ts:64:7: Supplied parameters do not match any signature of call target.

I am not able to solve all of them, as some are coming from Angular directly (I guess), for example :

Error at /myapp/node_modules/@angular/core/src/di/reflective_provider.d.ts:88:165: Cannot find name 'Map'.

Is the compilation failed related to all these errors and if I solve them the compilation will pass ? If yes, is it normal that even Angular causes errors such as the one I provided ?

Thanks !

Note : I am using Angular 2.1.1.

kinkaz
  • 53
  • 8

2 Answers2

1

For those who are interested :

The compiler will fail if you have Typescript errors (even if you forgot to type a variable, for example public myVar; will throw an error, public myVar: any; will pass).

The angular errors shouldn't be appearing and it has been solved for me by adding this dependency in my package.json :

"@types/core-js": "^0.9.34"

kinkaz
  • 53
  • 8
1

I was in the same boat as kinkaz. What worked for me was deleting the following from the tsconfig-aot.json file that the angular.io website suggested in the AoT tutorial...

just delete,

"typeRoots": [ "../../node_modules/@types/" ]

from tsconfig-aot.json

ng24u
  • 11
  • 1