Skip to content

@angular-devkit/build-angular:browser-esbuild reloads when navigating to lazy routes for the first time, causing navigation to fail. #26090

@HymanZHAN

Description

@HymanZHAN

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Similar issue: #25455

When serving with the Vite dev server, with caching enabled but no existing cache for lazy routes, the page will reload when I click on a link to a lazy route. And in some cases, the navigation will simply fail.

2023-10-22.17-53-57.mp4

My lazy route shows a list of items in my little test case, and I am using ngFor in the template. The navigation will proceed if the template is a simple <p>lazy-list works!</p>.

Despite the reply in the related issue (#25455), I still expect/hope Angular cache and Vite play more nicely together because I want the cache enabled for faster dev builds. A very very naive idea is that the Vite dev server only reads the cache when it first launches, only writes to the cache before it shuts down, and keeps behaving as if there is no such thing as a cache during the whole life cycle of its process.

Minimal Reproduction

I have a minimal repo with the reproduction.

Exception or Error

No response

Your Environment

> ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 16.2.7
Node: 18.12.1
Package Manager: pnpm 7.25.1
OS: linux x64

Angular: 16.2.10
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.7
@angular-devkit/build-angular   16.2.7
@angular-devkit/core            16.2.7
@angular-devkit/schematics      16.2.7
@angular/cli                    16.2.7
@schematics/angular             16.2.7
rxjs                            7.8.1
typescript                      5.1.6
zone.js                         0.13.3

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions