Skip to content

lazy loading chunks not built if bootstrap is not in main.ts file #12025

Closed
@devversion

Description

@devversion

Currently if people want to use lazy loading within Angular CLI projects and their bootstrap code is not placed inside of the $PROJECT_ROOT/main.ts file, the chunks for the lazy-loading module are not being generated.

This leads to JIT runtime errors that indicate that the lazy module couldn't be found.

core.js:1673 ERROR Error: Uncaught (in promise): Error: Cannot find module 'lazy/slider.module'
Error: Cannot find module 'lazy/slider.module'
    at $_lazy_route_resource lazy namespace object:5

Moving the boostrap call to the main.ts file fixes this issue (credits to @filipesilva for this finding)

--

It would be good to have some warning or note that implicates that lazy modules won't be detected if the bootstrap call is placed somewhere else.

Issue demonstration: https://github.com/DevVersion/lazy-load-test-cli

cc. @filipesilva

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions