Skip to content
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

Add example for pre ivy #28

Open
siddharthpal opened this issue Oct 10, 2019 · 4 comments
Open

Add example for pre ivy #28

siddharthpal opened this issue Oct 10, 2019 · 4 comments

Comments

@siddharthpal
Copy link
Contributor

siddharthpal commented Oct 10, 2019

Hi @mohammedzamakhan

Thanks for such a cool library. angular/core used in the demo app is for the Ivy engine. Can we add an example for pre-Ivy compiler which would work with Angular 7? If there isn't any repo I can create it and try ngx-loadable with Angular 7.

Please let me know if there is any change in using ngx-loadble for view engine?

@mohammedzamakhan
Copy link
Owner

Hey @siddharthpal,

You can use this library with Angular 7. Use the schamatics to generate the modules. Check the home page for the schematics

import { LoadableModule, matcher } from 'ngx-loadable';
...
LoadableModule.forFeature({
      moduleConfigs: [{
        name: 'lazy',
        loadChildren: () => import("./lazy/lazy.module").then(mod=> mod.LazyModule),
        matcher
      }]),

so if dynamic import doesn't work in your application, you can use magic string instead

import { LoadableModule, matcher } from 'ngx-loadable';
...
LoadableModule.forFeature({
      moduleConfigs: [{
        name: 'lazy',
        loadChildren: './lazy/lazy.module#LazyModule',
        matcher
      }]),
@mohammedzamakhan
Copy link
Owner

Please feel free to add this information in the FAQ section

@siddharthpal
Copy link
Contributor Author

Thanks, @mohammedzamakhan will try with magic strings and let you know.

@siddharthpal
Copy link
Contributor Author

Hi @mohammedzamakhan I tried the way you have mentioned above. I am facing one issue:
Whenever I am serving the application I see the application is not working with the below console error.

Screen Shot 2019-10-18 at 1 28 41 AM

And I see many warnings whenever I serve the app

Screen Shot 2019-10-18 at 1 25 07 AM

Sample application for repro.

Brief about the app

I am here using a Nrwl repo. I am lazily loading a module by setting the path in angular.json. When I build the app with aot I see a lazy load chunk is created.

In app.module I have added ngx-loadable and using it as below

import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";

import { AppComponent } from "./app.component";
import { ElementsProxyModule } from './elements-proxy/elements-proxy.module';
import { LoadableModule, matcher } from 'ngx-loadable';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, ElementsProxyModule, LoadableModule.forRoot({
			moduleConfigs: [{
        name: 'elements-proxy',
        loadChildren: './elements-proxy/elements-proxy.module#ElementsProxyModule',
        matcher
      }]
		})],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

Is there anything I am doing wrong or misconfiguring?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants