angular-umd-dynamic-example icon indicating copy to clipboard operation
angular-umd-dynamic-example copied to clipboard

AoT compilation for modules?

Open fr0 opened this issue 7 years ago • 7 comments

First, thank you for posting this repo - it is very helpful.

Do you know if it is possible to use this technique (or another similar technique) with modules that are compiled with AoT instead of lazy loading?

Thanks!

fr0 avatar Aug 15 '18 21:08 fr0

Hey!

Nice to hear! To be honest, the initial trigger for this project was to investigate the possibilities of loading 'modules' (in this case primarily UMD) using lazy loading (and unknown at compile time).

I'll write it down and take a look at it later!

lmeijdam avatar Aug 16 '18 06:08 lmeijdam

I think AOT is not working but README states the opposite. Try:

  1. ng build --prod --aot
  2. http-server ./dist/angular-dynamic-demo What you get is module not found error in console. I tried to rebuild all modules with AOT(build --prod moduleX) and repace them in assets but this thoes not help. Any ideas how all this can work in AOT mode? The point is to stay optimized and NOT send the compiler to the browser. @lmeijdam ^

kkartunov avatar Aug 30 '18 07:08 kkartunov

@kkartunov I See, strange! It's not that I haven't test this out before 'claiming' it was working with AoT. I've actually a couple of versions of this project and I see that none of them is building AoT any more. It did before.

lmeijdam avatar Aug 31 '18 07:08 lmeijdam

I;ve actually tested this a few months ago with ng build --prod and ng build --prod --build-optimizer=false, both were working. I'll check it out, when I got the time.

You're also free to fork it and try some stuff out;)

lmeijdam avatar Aug 31 '18 07:08 lmeijdam

I think issue is with build-optimizer, This will work like AOT without optimized build. ng build --prod --aot --build-optimizer=false

yogen-darji-hs avatar Sep 18 '18 10:09 yogen-darji-hs

Hi @lmeijdam, thanks for your great job !

I'm currently working on Angular 7.

AS you said, all was fine with JIT compilation, but with AOT, I had to use "--build-optimizer=false". But in your polyfills there is:

// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. import 'core-js/es7/reflect';

In my case, I need this in my polyfills: import 'core-js/es6/reflect'; import 'core-js/es7/reflect';

If not, i'm getting this error: error

Because I'm working with third party library, I'm interrested by using build-optimizer. It is reducing my app size a lot. Do we have an idea of ​​where the problem comes from ? Does someone have an idea how to use build-optimizer ?

LeoLetourneur avatar Jan 31 '19 12:01 LeoLetourneur

Did you manage to get this working?

lcbotha avatar Feb 26 '19 07:02 lcbotha