Is there a way to include the JIT compiler with an AOT angular 6/7 build?

1k views Asked by At

I need to the ability to dynamically create modules and components ( with different templates) during runtime with a production build (aot enabled). I know this is possible with dev builds where the JIT compiler is used. But i don't want this for my production builds

Is there a way to lazy load the JIT compiler, so that it's only used for creating those dynamic modules and components, in a production build ?

1

There are 1 answers

1
Benjamin Schäublin On

yes it would be possible, but i would call it a hack. You would lose all the advantages of the aot build (like smaller build-output without the compiler, ahead of time generated templates and so on). So there is no reason, to still want to use aot.

If you really want to use dynamically created modules and component, you'll want to create a prod build without aot - but still with uglifying and the prod environments.

ng build --prod --aot=false (assuming you have angular-cli, referring to the docs)