-
Notifications
You must be signed in to change notification settings - Fork 12k
how to lazy load a module from a package ? #2601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a very relevant question. I don't think we support it in the CLI atm. |
+1 for lazy loading from a package |
+1 here too, would love to be able to do this. working on a huge project with potentially dozens (hundreds?) of modules that may or may not ever be loaded, the decision is made at runtime. having them packaged as npm dependencies helps with the development process. |
+1 for lazy loading from a package too |
+1 for lazy loading from a package |
+1 |
I'm not sure if its supposed to do it this way, but in my testing i'm setup with a nested lazy loading setup that has app -> admin -> content as the module tree, including a 3rd party module into the content module, this bundles the 3rd party module with my content module, so this could be a work around for this approach. |
@Destreyf that sounds great. Could you be more specific on how you actually did it? For example provide a plunkr? That would be awesome. |
+1 |
@Destreyf Yep, I did this in the same way, but what's about singleton services for a module ? As I understand when we provide a feature module from package the angular creates new instances of module. Am I right ? |
@vdzundza When you use a feature module, it does create a new instance of singleton services (Or any Injectable service) based on my understanding whenever a lazy loaded module is created in order to prevent possible issues, however I've not run into any problems so maybe my understanding is outdated. |
+1 |
I have the same need, i.e., lazy load a feature module that I have published to npm as a package. Is this still not supported? |
this below works for me, but i don't know why it works. copy *.module.ts to your dist(ngc compile outDir) directory.
i m using |
@L2M can you be more explicit about your example? how you set this -> loadChildren: '../../../node_modules/your_package_name/...' |
@spagenny , in my project.
'topibd/sys-conf' is my npm package name. |
I tried using direct references to modules in |
Do you think |
@erkanarslan That might just do the business 👍 |
Although does the Angular CLI not package all the vendor (npm modules) into a single bundle? |
@erkanarslan I did use this approach of importing external lazy loaded modules from NPM package into local module in my app, and load that local module lazily using load Children. This works perfect for me. import { NgModule } from '@angular/core'; @ NgModule({
|
Is this still an open issue? I need to lazy-load my feature module in order to allow it's own translation configuration using angular-l10n. Without, it is not possible according the documentation and that's also what I'm seeing in practice. I'm wrapping it now but I wonder .. is this still required? |
@tiwarirahul thank you so much. This works fine for me (you can also define your routes in the npm lib package) :) |
+1 for this. |
@filipesilva: the suggested workaround from @tiwarirahul seems to be valid/valid solution. Do you think we could add a PR for that (see below)? Proposal:
structure something like this:
generated code in src/app/module/library/my-lib.module.ts
|
Bumped into that issue today. Using new angular cli 6.0, trying to build a library. Not sure it's helpful or not but the library uses the router. How I build the whole Angular project:
So basically the main project is the demo and also where I make sure with E2E tests that the lib is working well by using some service and component from the lib, testing the edge cases. Now, I'm done building it and wanted to build it for prod. Now, vicious circle for that use case:
Only remaining solution is to lazy load then. But when I lazy load I end up with an other error: So right now completely stuck there. Also, it might be related to this issue: #10750 |
Issue is probably related to #6373 as well. |
is there any update for this issue? I don't want to have a wrapper module which imports requires module from is it resolved in other referenced links? Will any one provide any update on this issue? |
@micronyks, I researched the topic quite a lot (dozen of similar issues out there - unresolved) and it seems like this issue just receives no love :( Currently, the only way around this is really wrapping a module, but this is of course extremely bad. |
First of all thanks for the update @klemenoslaj . Even I feel like that I am stuck after developing so many libraries and I don't want to go with a wrapper module approach. |
+1 |
Any Update? |
Hi, Me too got stuck with same issue, any update on this? Thanks, |
Duplicate of #6373 |
Any updates on this issue? |
this work for me, you can try it #6373 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
we have some modules published as package, and in this project we need to lazy load the module
if the module in the target project, it's ok , like :
export const routes: Routes = [
{ path: '', redirectTo: 'test01', pathMatch: 'full'},
{ path: 'test01', loadChildren: 'app/testing01/test01.module' },
]
but, how can i load modules from package , like this:
{ path: 'test01', loadChildren: '@xxx/testing01/test01.module' },
i am using
"angular-cli": "1.0.0-beta.15",
@angular 2.0.0
thank you and being in touch
The text was updated successfully, but these errors were encountered: