Skip to content

CLI version 22.1 breaks ionic dependencies in ng serve #33742

Description

@silverwing102

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

22.0.9

Description

I maintain an app that our team recently migrated to Angular 22, from 17. This application uses the traditional platformBrowser().bootstrapModule(AppModule) bootstrap with IonicModule.forRoot().

We have used this for a month with no issues, but yesterday when we upgraded the CLI and core to version 22.1 (22.1.0 for core, 22.1.2 in CLI), we started getting this error in the command prompt console after opening localhost on the browser:

The file does not exist at "<project location>/.angular/cache/22.1.2/<project-name>/vite/deps/ion-app_8.entry.js" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to optimizeDeps.exclude.

After inspecting .angular/cache/.../vite/deps, I observed that no ion-*.entry.js files were generated. The only Ionic-related optimized file present was @ionic_angular.js.

On rolling back to 22.0 (core 22.0.8, CLI 22.0.9), it fixed the issue.

Minimal Reproduction

I do not currently have a minimal reproduction. However, the issue occurs consistently in an NgModule-based Ionic application after upgrading Angular CLI from 22.0.9 to 22.1.2. The closest reproduction steps I can provide are:

  1. Create an NgModule-based Angular application.
  2. Add @ionic/angular (tested with 8.8.15 and 8.8.16) and configure IonicModule.forRoot().
  3. Upgrade Angular CLI to 22.1.2.
  4. Run ng serve and open the application.

Exception or Error

The file does not exist at "<project location>/.angular/cache/22.1.2/<project-name>/vite/deps/ion-app_8.entry.js" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to optimizeDeps.exclude.

Your Environment

Angular CLI       : 22.1.2
Angular           : 22.1.0
Node.js           : 24.18.0
Package Manager   : npm 11.16.0
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 22.1.2            │ ^22.1.2           │
│ @angular/cdk              │ 22.1.0            │ ^22.1.0           │
│ @angular/cli              │ 22.1.2            │ ^22.1.2           │
│ @angular/common           │ 22.1.0            │ ^22.1.0           │
│ @angular/compiler         │ 22.1.0            │ ^22.1.0           │
│ @angular/compiler-cli     │ 22.1.0            │ ^22.1.0           │
│ @angular/core             │ 22.1.0            │ ^22.1.0           │
│ @angular/forms            │ 22.1.0            │ ^22.1.0           │
│ @angular/localize         │ 22.1.0            │ ^22.1.0           │
│ @angular/platform-browser │ 22.1.0            │ ^22.1.0           │
│ @angular/router           │ 22.1.0            │ ^22.1.0           │
│ @angular/service-worker   │ 22.1.0            │ ^22.1.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 6.0.3             │ ~6.0.2            │
│ vitest                    │ 4.1.10            │ ^4.0.8            │
│ zone.js                   │ 0.16.2            │ ^0.16.2           │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions