Skip to content

[AOT] [Lazy Loading] Error: Cannot find module './routes/home/home.module.ngfactory'. #8597

@strongpauly

Description

@strongpauly

Versions

@ngtools/webpack 1.8.2
node 8.9.1
npm 5.5.1
webpack 3.8.1
angular 5.0.2

Repro steps

Apologies if this is a duplicate, or a simple configuration issue, but I really can't progress this any further myself. During an attempt to convert our project into an AOT production build I have run into these errors. I have created a stub version of it here to demonstrate the issue: https://github.com/strongpauly/angular-5-aot-lazy

Installing this project and compiling using JIT works as expected - the two routes, root (or home) and lazy, load correctly.

Using AOT causes the below error message when navigating to the root url.

Observed behavior

Error thrown.

app.df2918c1fc6f0b8f449f.js:1 ERROR Error: Uncaught (in promise): Error: Cannot find module './routes/home/home.module.ngfactory'.
Error: Cannot find module './routes/home/home.module.ngfactory'.
    at app.df2918c1fc6f0b8f449f.js:1
    at ZoneDelegate.invoke (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Object.onInvoke (app.df2918c1fc6f0b8f449f.js:1)
    at ZoneDelegate.invoke (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Zone.run (polyfills.df2918c1fc6f0b8f449f.js:1)
    at polyfills.df2918c1fc6f0b8f449f.js:1
    at ZoneDelegate.invokeTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Object.onInvokeTask (app.df2918c1fc6f0b8f449f.js:1)
    at ZoneDelegate.invokeTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Zone.runTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at app.df2918c1fc6f0b8f449f.js:1
    at ZoneDelegate.invoke (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Object.onInvoke (app.df2918c1fc6f0b8f449f.js:1)
    at ZoneDelegate.invoke (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Zone.run (polyfills.df2918c1fc6f0b8f449f.js:1)
    at polyfills.df2918c1fc6f0b8f449f.js:1
    at ZoneDelegate.invokeTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Object.onInvokeTask (app.df2918c1fc6f0b8f449f.js:1)
    at ZoneDelegate.invokeTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Zone.runTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at resolvePromise (polyfills.df2918c1fc6f0b8f449f.js:1)
    at resolvePromise (polyfills.df2918c1fc6f0b8f449f.js:1)
    at polyfills.df2918c1fc6f0b8f449f.js:1
    at ZoneDelegate.invokeTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Object.onInvokeTask (app.df2918c1fc6f0b8f449f.js:1)
    at ZoneDelegate.invokeTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at Zone.runTask (polyfills.df2918c1fc6f0b8f449f.js:1)
    at drainMicroTaskQueue (polyfills.df2918c1fc6f0b8f449f.js:1)
    at <anonymous>

Desired behavior

AOT should load routes lazily in the same way as JIT.

This may have been easier to debug, either with actual documentation specific to ngtools/webpack or with a way to output intermediate files on a failure, but I see there is a separate issue for that.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfreq1: lowOnly reported by a handful of users who observe it rarelyneeds: investigationRequires some digging to determine if action is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions