Skip to content

Error lazy loading when using ng build --prod #6567

@MarbleDaemon

Description

@MarbleDaemon

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.1.0
node: 6.10.3
os: win32 x64
@angular/animations: 4.1.3
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/platform-server: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.1.0
@angular/compiler-cli: 4.1.3
@angular/language-service: 4.1.3

Repro steps.

  1. Implement lazy-loading
  2. Build using 'ng build --prod'

The log given by the failure.

ERROR Error: Uncaught (in promise): Error: Cannot find module 'app/modules/dashboard/dashboard.module'.
Error: Cannot find module 'app/modules/dashboard/dashboard.module'.
at l (main.4372417….bundle.js:1)
at t.loadAndCompile (vendor.9485d4a….bundle.js:379)
at t.load (vendor.9485d4a….bundle.js:379)
at t.loadModuleFactory (vendor.9485d4a….bundle.js:428)
at t.load (vendor.9485d4a….bundle.js:428)
at e.project (vendor.9485d4a….bundle.js:428)
at e.XO5T.e._tryNext (vendor.9485d4a….bundle.js:900)
at e.XO5T.e._next (vendor.9485d4a….bundle.js:900)
at e.next (vendor.9485d4a….bundle.js:900)
at e.RRVv.e._subscribe (vendor.9485d4a….bundle.js:739)
at l (main.4372417….bundle.js:1)
at t.loadAndCompile (vendor.9485d4a….bundle.js:379)
at t.load (vendor.9485d4a….bundle.js:379)
at t.loadModuleFactory (vendor.9485d4a….bundle.js:428)
at t.load (vendor.9485d4a….bundle.js:428)
at e.project (vendor.9485d4a….bundle.js:428)
at e.XO5T.e._tryNext (vendor.9485d4a….bundle.js:900)
at e.XO5T.e._next (vendor.9485d4a….bundle.js:900)
at e.next (vendor.9485d4a….bundle.js:900)
at e.RRVv.e._subscribe (vendor.9485d4a….bundle.js:739)
at u (polyfills.74eef9a….bundle.js:43)
at u (polyfills.74eef9a….bundle.js:43)
at polyfills.74eef9a….bundle.js:43
at t.invokeTask (polyfills.74eef9a….bundle.js:36)
at Object.onInvokeTask (vendor.9485d4a….bundle.js:365)
at t.invokeTask (polyfills.74eef9a….bundle.js:36)
at r.runTask (polyfills.74eef9a….bundle.js:36)
at o (polyfills.74eef9a….bundle.js:36)
at

Desired functionality.

The module should be lazy loaded in the same way as using 'ng serve'

Mention any other details that might be useful.

Further investigation seems pointing to a clue: it seems to use SystemJsNgModuleLoader to load the module using 'app/modules/dashboard/dashboard.module' whereas the module is registered as 'app/modules/dashboard/dashboard.module.ngfactory'.

This leads to inability to load the module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions