Skip to content

Lazy modules in shared project through page-router-outlet. #1635

Closed

Description

@artu-ole

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.0.1
  • NativeScript-Angular: 7.0.2
  • Angular: 7.0.4
  • reproduced on android.

Describe the bug
Lazy loaded module is not found with a relative or absolute path in a shared project.
That is not to say that lazy modules don't work at all, but they fail through page-router-outlet.
Routes are as follows:

const routes: Routes = [
    { path: "", redirectTo: "/login", pathMatch: "full" },
    {
        path: "login", component: LoginComponent
    },
    {
        path: "welcome", component: WelcomeComponent
    },
    {
        path: "tabs",
        loadChildren: "./app/tabs/tabs.module#TabsModule"
    },
];
JS: Error: Cannot find module './app/tabs/tabs.module'
JS:     at file:///data/data/org.nativescript.logintabsngshared/files/app/bundle.js:161:11 [angular]
JS:     at Object.onInvoke (file:///data/data/org.nativescript.logintabsngshared/files/app/vendor.js:46613:33) [angular]
JS:     at file:///data/data/org.nativescript.logintabsngshared/files/app/vendor.js:68322:34 [angular]
JS:     at Object.onInvokeTask (file:///data/data/org.nativescript.logintabsngshared/files/app/vendor.js:46604:33) [angular]

Funny enough, if loadChildren is changed to "~/app/tabs/tabs.module#TabsModule" while in live sync then module is resolved. However, module is not found with this link the very next time project is restarted in cli.

To Reproduce
Create new project with ng new --collection=@nativescript/schematics project-name --shared and replace app folder with app folder from https://github.com/ADjenkov/login-tabs-ng project.
Try running. Or use sample project which was created this way:

Sample project
https://github.com/artu-ole/login-tabs-ng-shared

Activity

  1. NickIliev commented on Dec 12, 2018

    @NickIliev

    @artu-ole Use the updated project that we migrated withint the NativeScript organization. It is the same project that @ADjenkov created but with some minor updates like the nsRouterLink navigation to the lazily loaded module and with the usage of tilde (~) instead of dot for the module path.

    Notice that some of the functionalities are not officially released so we are using the next of nativescript-angular

  2. artu-ole commented on Dec 12, 2018

    @artu-ole
    Author

    @NickIliev, Thank you for the response.
    I was able to fiddle laziness into existence some time ago in the fresh project with tilde and latest nativescript, this report and sample project only came to life because of different liveview vs fresh start behavior I've experienced at that time which can be replicated in the sample project.
    Ticket can be closed, however, as I have this working as expected now and sample project might be okay as well on latest versions, ain't nobody got time for that.

  3. artu-ole commented on Dec 12, 2018

    @artu-ole
    Author

    Quick question, outlet primary doesn't exist, is this a left over?

  4. ADjenkov commented on Dec 12, 2018

    @ADjenkov
    Contributor

    Hi @artu-ole ,
    Every unnamed <page-router-outlet> or <router-outlet> automatically gets default name set -"primary". In order to navigate back this specific unnamed <page-router-outlet> you have to specify his name which is "primary" by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions