question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
hettigercommented, Jan 22, 2018

I’m having the exact same problem.

0reactions
angular-automatic-lock-bot[bot]commented, Feb 24, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AOT - Lazy loaded routes are not being compiled
The main project uses some modules provided by carbonldp-panel and it compiles them ONLY when they are imported, but not when they are...
Read more >
Cheat Sheet - Angular
Defines a module that contains components, directives, pipes, and providers. ... List of components to bootstrap when this module is bootstrapped.
Read more >
Pillar 3 — Lazy Loading, AOT, and Preloading - Angular inDepth
Lazy loading is a useful technique for faster initial page loads. ... When AOT is in use, offlineMode is set to true ,...
Read more >
Experimenting With Lazy Loaded Modules, Ahead Of Time ...
One thing to be aware of is that the route definitions in a lazy-loaded ... the Angular application would no longer compile in...
Read more >
Lazy Loading Components In Angular - Axelerant
We have seen many examples of lazy loading components in Angular using route based loading. In this blog, we would be looking at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found