JIT compiler error for lazy loaded module

72 views
Skip to first unread message

Akhil Dhanuka

unread,
May 29, 2017, 8:15:47 AM5/29/17
to Angular and AngularJS discussion

Hi All,

I am trying to get both AOT and JIT to work simultaneously on a Angular 4 project. AOT works fine with lazy loaded module but while loading using JIT compiler I am getting the following error - 

component name (lazy loaded)  is not part of any ngmodule. Do I have to do something special for JIT mode?

I have ejected webpack config from angular-cli to improve certain configurations on webpack. 

My loaders look like - 

                    "test": /\.ts$/,

                    "loaders": ["@ngtools/webpack", "angular-router-loader?aot=false&genDir=compiled&loader=system"]


As you can see I used angular-router-loader but with or without is not helping to solve the issue. lazy modules chunks are created and while loading I can see the chunk file was called over http successfully but then I get jitcompiler errors on the component not available.

Thanks,
Akhil

Sander Elias

unread,
May 29, 2017, 8:26:13 AM5/29/17
to Angular and AngularJS discussion
Hi Akhil,

While  I know for sure this can be made to work, don't do it.
The JIT is going to disappear in the future. So basing your solution on the JIT is a short term solution.
You don't need the JIT to be able to lazy-load modules. And soon we will have a way to create the stuff that needs even more dynamic things.

Regards
Sander 

Akhil Dhanuka

unread,
May 29, 2017, 8:12:38 PM5/29/17
to Angular and AngularJS discussion
Hi Sander,

Thanks for the quick response. I think it is very valuable for short term as these are the issues we are currently facing with AOT solution...

- AOT does not work with file changes during development properly and the build time is very long for each file change.
- we have 70+ locales integrated with Angular 4 app and AOT pre-builts the app for each locales and it takes in excess of 20 minutes which is very slow for both development and release process.

My plans for short term - 

Use JIT for development purposes.
AOT for production builds
refactor codebase to allow dynamic loading of locales..

Let me know if this is not the right path?

Thanks,
Akhil

Sander Elias

unread,
May 30, 2017, 1:16:18 AM5/30/17
to Angular and AngularJS discussion
Hi Akhil,

Thanks for the quick response. I think it is very valuable for short term as these are the issues we are currently facing with AOT solution...
As long as you realise the JIT is not a solution, there is nothing wrong with using it temporarily. Here is a git issue that goes into details. Please note that this is not officially supported!
 
- AOT does not work with file changes during development properly and the build time is very long for each file change.
While I'm aware of this, I also know that this is under active development. Soon(ish) the build time will be much better.
 
- we have 70+ locales integrated with Angular 4 app and AOT pre-builts the app for each locales and it takes in excess of 20 minutes which is very slow for both development and release process.
70+ locales, that sounds like a big challenge. Do you really need all of those in development? With a project this size, I'm pretty sure you have (or should have) a staging environment. Staging should test all languages, so you don't have to do this during development all the time. 20 minutes sounds horrible!
 
My plans for short term - 

Use JIT for development purposes.
AOT for production builds
Yep, no problem. 
 
refactor codebase to allow dynamic loading of locales..
 Euhm. I know the core team is also working on this. I don't have any time-frames or details, but perhaps this doesn't need to be on your plate only. Let me check some things.

Regards,
Sander

Akhil Dhanuka

unread,
May 30, 2017, 2:15:51 AM5/30/17
to ang...@googlegroups.com
Thanks Sander for all the information. 

As long as you realise the JIT is not a solution, there is nothing wrong with using it temporarily. Here is a git issue that goes into details. Please note that this is not officially supported!

Short term we will continue to use JIT and switch to AOT during development when things gets resolved.

- AOT does not work with file changes during development properly and the build time is very long for each file change.
While I'm aware of this, I also know that this is under active development. Soon(ish) the build time will be much better.

Short term this will be served with JIT. Same as above.

- we have 70+ locales integrated with Angular 4 app and AOT pre-builts the app for each locales and it takes in excess of 20 minutes which is very slow for both development and release process.
70+ locales, that sounds like a big challenge. Do you really need all of those in development? With a project this size, I'm pretty sure you have (or should have) a staging environment. Staging should test all languages, so you don't have to do this during development all the time. 20 minutes sounds horrible!
 

We have staging and we ONLY build one LTR and one RTL language but since AOT is slow and doesn’t have a Live-reload we are switching to JIT mode for short term.

All of the above items are co-related and we will wait until the core team gives us AOT with faster build times along with dynamic locale functionality.

Until then JIT is the way to go for us. Thanks for all the help to resolve all the issues we are facing.

Thanks,
Akhil

--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/DVfFvDUPSUk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Sander Elias

unread,
May 30, 2017, 3:24:21 AM5/30/17
to Angular and AngularJS discussion
Hi Akhil,

refactor codebase to allow dynamic loading of locales..
 Euhm. I know the core team is also working on this. I don't have any time-frames or details, but perhaps this doesn't need to be on your plate only. Let me check some things.
I just talked with the core maintainer of I18n about this. There is work being done so that it will become possible to lazy load translations as they are needed. Plan for now(disclaimer, plans can change!) is to decouple the i18n files from the build. 
it won't be before V5, or perhaps even later. (to put it in context, V5 will be this year, v6 6 months after that)

I tried to DM you on hangouts because I was curious. You don't seem to be a Hangouts user ;)

Regards
Sander

Akhil Dhanuka

unread,
May 30, 2017, 3:39:03 AM5/30/17
to ang...@googlegroups.com
Thanks Sander. I am now available in Hangout. We can have a quick chat?

Thanks,
Akhil
Reply all
Reply to author
Forward
0 new messages