Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Different relative paths for lazy route files #372

Closed

Description

@mxth

Expected

Nested routes resolve child modules correctly with or without --bundle.

Current

  • Without --bundle, the path is relative to ./app directory.
  • With --bundle, the path is relative to the current directory of the route file.

Reproduce

Activity

  1. self-assigned this
    on Dec 21, 2017
  2. mxth commented on Jan 11, 2018

    @mxth
    Author

    @vchimev do you have an estimation for the fix? Our app is going to production soon, and we need it to plan accordingly.

  3. NickIliev commented on Feb 13, 2018

    @NickIliev

    @mxth as a temporary solution you can manually change the paths before bundling with Webpack (as done here)

  4. SmailHammour commented on Mar 1, 2018

    @SmailHammour

    @NickIliev when can we expect a fix for this?

  5. NickIliev commented on Mar 2, 2018

    @NickIliev

    @Smiley01987 @mxth the issue can now be resolved by providing an app alias in tsconfig.json and using the alias to create the nested lazily loaded modules.
    For example (based on https://github.com/mxth/nativescript-nested-lazy)

    tsconfig.json (note the alias in paths "~/*": ["app/*"],)

    {
        "compilerOptions": {
            "module": "commonjs",
            "target": "es5",
            "experimentalDecorators": true,
            "emitDecoratorMetadata": true,
            "noEmitHelpers": true,
            "noEmitOnError": true,
            "lib": [
                "es6",
                "dom",
                "es2015.iterable"
            ],
            "baseUrl": ".",
            "paths": {
                "~/*": [
                    "app/*"
                ],
                "*": [
                    "./node_modules/tns-core-modules/*",
                    "./node_modules/*"
                ]
            }
        },
        "exclude": [
            "node_modules",
            "platforms"
        ]
    }
    

    and then in the nested routing table use the alias as follows
    items.module.ts

    export const routes: Routes = [{
      path: '',
      component: ItemsComponent
    }, {
      path: ':id',
      loadChildren: '~/item/item-detail/item-detail.module#ItemDetailModule'
    }]
    
    

    With the above configuration, the application will build and run as expected with and without Webpack.

  6. NickIliev commented on Mar 2, 2018

    @NickIliev

    The creation of the alias will be added out-of-the-box with nativescript-dev-typescript with this PR

  7. self-assigned this
    on Mar 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions