Skip to content

Routes defined by loadChildren with a factory function do not get compiled by AOT #8429

@babeal

Description

@babeal

Bug Report or Feature Request (mark with an x)

[x ] bug report

Versions.

Angular CLI: 1.5.0
Node: 6.9.1
OS: darwin x64

Repro steps.

When compiling an app AOT, modules that are loaded using a function for loadChildren do not get compiled properly. We need this functionality to properly load routes from modules. We cannot use the lazy load string syntax because these modules exist as packages in the node_module folders and lazy loaded routes inside of a node module package are not supported by the CLI yet.

export function loadChildModule() {
    return ChildModule;
}

export const routes: Routes = [
    {
        path: '',
        component: ParentComponent,
        children: [
            {
                path: '',
                loadChildren: loadChildModule
            }
        ]
    }
];

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

The log given by the failure.

vendor.bf2a9d83f92ee4918125.bundle.js:1 ERROR Error: Uncaught (in promise): Error: Runtime compiler is not loaded
Error: Runtime compiler is not loaded
    at J (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at t.compileModuleAsync (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.project (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e._tryNext (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e._next (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.T14+.e.next (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e._subscribe (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.t._trySubscribe (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.t.subscribe (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at t.call (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at J (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at t.compileModuleAsync (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.project (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e._tryNext (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e._next (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.T14+.e.next (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e._subscribe (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.t._trySubscribe (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at e.t.subscribe (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at t.call (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at c (polyfills.f5c660f62615965d5e39.bundle.js:1)
    at c (polyfills.f5c660f62615965d5e39.bundle.js:1)
    at polyfills.f5c660f62615965d5e39.bundle.js:1
    at t.invokeTask (polyfills.f5c660f62615965d5e39.bundle.js:1)
    at Object.onInvokeTask (vendor.bf2a9d83f92ee4918125.bundle.js:1)
    at t.invokeTask (polyfills.f5c660f62615965d5e39.bundle.js:1)
    at r.runTask (polyfills.f5c660f62615965d5e39.bundle.js:1)
    at o (polyfills.f5c660f62615965d5e39.bundle.js:1)
    at <anonymous>

Desired functionality.

This should properly compile the modules returned by the factory function.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions