Skip to content

App with lazily loaded module fails with tns preview --bundle #6545

Closed

Description

@isc30

Environment

√ Component nativescript has 5.0.0 version and is up to date.
√ Component tns-core-modules has 5.0.2 version and is up to date.
√ Component tns-android has 5.0.0 version and is up to date.
√ Component tns-ios has 5.0.0 version and is up to date.

Describe the bug
Current version of Template Drawer Navigation (Angular) doesn't work well when running tns preview --bundle.

Error: com.tns.NativeScriptException: Failed to find module: "~/app/home/home.module", relative to: /app/

To Reproduce
Start a new project from the template and run tns preview --bundle

Expected behavior
It should run properly. With tns preview it works well, so its related to webpack.

Activity

  1. Fatme commented on Nov 12, 2018

    @Fatme
    Contributor

    @isc30,

    Currently preview app has a limitation and does not support lazy loading with angular projects.

    The error you receive is due to the fact that home module is lazy loaded here https://github.com/NativeScript/template-drawer-navigation-ng/blob/master/src/app/home/home-routing.module.ts#L12. If you want to run preview --bundle command with drawer navigation template, you need to refactor all places where lazy loading is used.

    The another option is to create an application from tabs or hello world templates. These templates do not have lazy loading, so they will work automatically with tns preview --bundle command.

  2. isc30 commented on Nov 12, 2018

    @isc30
    Author

    Lazy loading also prevents HMR, right?
    Is it recommended to avoid lazy loading for now and take advantage of bundling and HMR? What's the best approach for the future?
    Thanks a lot @Fatme

  3. changed the title [-]Angular Drawer Template: webpack error: Failed to find module: "~/app/home/home.module", relative to: /app/[/-] [+]App with lazily loaded module fails with tns preview --bundle[/+] on Nov 13, 2018
  4. NickIliev commented on Nov 13, 2018

    @NickIliev
    Contributor
  5. lock commented on Nov 13, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  6. locked and limited conversation to collaborators on Nov 13, 2019
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions