ionic-team / ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
128 stars 85 forks source link

Lazy loading from common folder #983

Open stephaneHillerCGI opened 5 years ago

stephaneHillerCGI commented 5 years ago

I'm submitting a ... (check one with "x") [x ] bug report [ ] feature request

Current behavior:

I have a repo with three folder : 2 ionic apps and a common module. The goal of this common module is to provide common information for the two ionic projects (the module contains providers, component, models, pages, ...).

But when you try to lazy load a page from the module, it doesn't work ("core.js:1350 ERROR Error: Uncaught (in promise): invalid link: MyPage").

ps: my current ionic version is 4.11, but it's an Ionic v3 application.

Expected behavior:

The expected behaviour would be a working lazy loading.

Steps to reproduce:

https://github.com/stephaneHillerCGI/ionicCommonModule

Clone github repo and run npm install on each of the three folder. After that you can run ionic serve from both folder ionicProjectA and ionicProjectB.

The two pages that will be displayed will be the same (a button "My component" and a button "Launch"). Press "Launch" to navigate to another page. In project A it doesn't work (because of live reload) and in project B, it works (no live reload). To switch from live reload to no live reload, just comment/uncomment the lines in (my-page.module.ts, my-page.ts and my-module.module.ts).

Related code:

The code of the application can be clone from : https://github.com/stephaneHillerCGI/ionicCommonModule

Other information:

Is it possible that Ionic doesn't "see" the IonicPage() annotation because this annotation isn't in the src folder ? If true, is it possible to extends the watcher to another folder so Ionic can recognize the annotation ?

   ionic (Ionic CLI)  : 4.11.0 (C:\Users\stephane.hiller\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.0

System:

   NodeJS : v8.9.4 (C:\Program Files\nodejs\node.exe)
   npm    : 5.6.0
   OS     : Windows 7
longgt commented 5 years ago

The default setup of Ionic Appscript is it will look into src folder. So if Lazy Loading page is out of here, it can't be parsed and inject into module loader properly.

If you need support this feature, feel free to file issue to Ionic app scripts.

https://github.com/ionic-team/ionic-app-scripts

stephaneHillerCGI commented 5 years ago

@longgt Thanks for your answer. I've open an issue in the Ionic app scripts github. Here is the link if anyone is interessed by the response : https://github.com/ionic-team/ionic-app-scripts/issues/1520