Skip to content

CLI version 22.1 breaks ionic dependencies in ng serve #33742

Closed as not planned
Closed as not planned

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

Activity

  1. added
    gemini-triaged
    on Aug 4, 2026
  2. added this to the needsTriage milestone on Aug 4, 2026
  3. alan-agius4 commented on Aug 6, 2026

    @alan-agius4
    Collaborator

    In version 22.1, the CLI upgraded to Vite 8, which transitioned dependency prebundling from esbuild to Rolldown.

    @ionic/angular and @ionic/core are built using Stencil, which lazily loads component entry chunks using dynamic imports annotated with Vite suppression comments:

    import(/* @vite-ignore */ './ion-app_8.entry.js');
    • With esbuild (Vite 7 / Angular 22.0): esbuild does not recognize the Rollup/Vite /* @vite-ignore */ comment. It parsed the dynamic imports as regular bundle dependencies and emitted all the corresponding ion-*.entry.js chunk files directly into the .angular/cache/.../vite/deps/ directory.
    • With Rolldown (Vite 8 / Angular 22.1): Rolldown natively recognizes /* @vite-ignore */ and leaves the import untouched as a raw runtime dynamic import without emitting or copying the referenced .entry.js files into vite/deps/. When the prebundled @ionic_angular.js module runs in the browser, Stencil resolves ./ion-app_8.entry.js relative to vite/deps/ (where the file does not exist), triggering the 404 error.

    You can resolve this by excluding @ionic/angular and @ionic/core from prebundling in your angular.json under your serve target options:

    "serve": {
      "builder": "@angular/build:dev-server",
      "options": {
        "buildTarget": "<project-name>:build",
        "prebundle": {
          "exclude": [
            "@ionic/angular",
            "@ionic/core"
          ]
        }
      }
    }
  4. angular-automatic-lock-bot commented on Oct 18, 2026

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular/buildgemini-triaged

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions