Skip to content
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
mxth opened this issue Dec 21, 2017 · 5 comments
Closed

Different relative paths for lazy route files #372

mxth opened this issue Dec 21, 2017 · 5 comments

Comments

@mxth
Copy link

mxth commented Dec 21, 2017

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

@mxth
Copy link
Author

mxth commented Jan 11, 2018

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

@NickIliev
Copy link
Contributor

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

@SmailHammour
Copy link

@NickIliev when can we expect a fix for this?

@NickIliev
Copy link
Contributor

NickIliev commented Mar 2, 2018

@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.

@NickIliev
Copy link
Contributor

NickIliev commented Mar 2, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants