Skip to content

ngtools with nested lazy modules routing #3593

Closed

Description

@jmpmscorp

Please provide us with the following information:

OS?

Windows 10

Versions.

angular-cli: 1.0.0-beta.22-1
node: 6.7.0
os: win32 x64

Repro steps.

Suppose there are two nested lazy modules routes like this:

Module A: app-routing.module

`export const routes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'login', loadChildren: './login/login.module#LoginModule' },
{ path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule'}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {}`

Module B (lazy module with another lazy module) dashboard-routing.module:

`const routes: Routes = [
{ path: '', component: DashboardComponent, pathMatch: 'full' },
{ path: 'explotaciones', component: DashboardComponent,
children: [
{ path: '', loadChildren: './explotaciones/explotaciones.module#ExplotacionesModule'}
]
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class DashboardRoutingModule {}`

The log given by the failure.

Error: Could not resolve route "./explotaciones/explotaciones.module#ExplotacionesModule" from file "D:\Code\DL-GEST\src\client\app\dashboard\dashboard.module".
at D:\Code\DL-GEST\node_modules@ngtools\webpack\src\plugin.js:280:23
at Array.map (native)
at AotPlugin._processNgModule (D:\Code\DL-GEST\node_modules@ngtools\webpack\src\plugin.js:275:14)
at _loop_1 (D:\Code\DL-GEST\node_modules@ngtools\webpack\src\plugin.js:309:35)
at AotPlugin._processNgModule (D:\Code\DL-GEST\node_modules@ngtools\webpack\src\plugin.js:328:13)
at D:\Code\DL-GEST\node_modules@ngtools\webpack\src\plugin.js:242:39
at process._tickCallback (internal/process/next_tick.js:103:7)
70% building modules 716/716 modules 0 active

Mention any other details that might be useful.

I have been looking for the error and I find a problem in plugin.js. At line 274, this.extractLoading function use a variable called 'relativeModulePath'. With module A, this variable use '/' on paths (D:/Code/DL-GEST/src/client/app/app.module) and there is no problem with it, but with module B, this variable use '\' on path and then, emit error I wrote lines before.

I have changed function var relativeModulePath = this._resolveModulePath(module, containingFile) to
var relativeModulePath = this._resolveModulePath(module, containingFile).replace(/\\/g,'/') and it solves my problems.

Is there a better approach to solve it??

Thanks and excuse my english :).


Thanks! We'll be in touch soon.

Activity

  1. masaanli commented on Dec 16, 2016

    @masaanli

    I Have the same issue:

    I tried it with just:

    A lazy loaded module route and inside that lazy loaded module route a new lazy loaded module route.

    It hangs then at 10% module 2/2.

    After 10 minutes it throws an error:

    10% building modules 2/2 modules 0 active(node:1281) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RangeError: Maximum ca ll stack size exceeded 20% building modules 84/84 modules 0 active

  2. Destreyf commented on Dec 17, 2016

    @Destreyf

    @jmpmscorp I can confirm this behavior, and that your fix resolves the issue.

  3. filipesilva commented on Dec 30, 2016

    @filipesilva
    Contributor

    Marking as dupe of #3663 since it has a bit more discussion.

  4. Destreyf commented on Dec 30, 2016

    @Destreyf

    @filipesilva This was an issue in beta.22 (more specifically the @ngtools for that release so going back to 21 still had the same issue) this does not affect beta.24, and the fix does not work for beta.24 either. #3663 is a newly introduced problem that prevents nested lazy loading beyond a certain depth.

  5. filipesilva commented on Dec 30, 2016

    @filipesilva
    Contributor

    Hm, I see. I guess then it's closed as fixed, since it doesn't affect beta.24 and we can't fix the old one anyway.

  6. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

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

    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfultype: bug/fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions