Error in Angular 19 with Vite and Lazy Loading of Ionic Modules

Discussão em 'Angular' iniciado por AlejoDev, Fevereiro 16, 2025.

  1. AlejoDev

    AlejoDev Guest

    I recently migrated my Angular application to version 19. The app uses NgModules and loads Ionic modules with lazy loading. Before the migration, everything worked fine, but after upgrading to Angular 19, running ng serve throws the following error related to Vite and dependency optimization:

    /Users/fer/Documents/xxxxxx/xxxxx-business/.angular/cache/19.1.7/app/vite/deps/chunk-7D5EXCLD.js
    900| return i[n];
    901| }
    902| return import("./".concat(a, ".entry.js").concat("")).then(function(e2) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    903| {
    904| cmpModules.set(a, e2);
    The above dynamic import cannot be analyzed by Vite.
    See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats.


    Additionally, I see messages like:

    The file does not exist at "/Users/xxxxxxxx/Documents/xxx/xxxx-business/.angular/cache/19.1.7/app/vite/deps/ion-app_8.entry.js"
    The dependency might be incompatible with the dep optimizer. Try adding it to optimizeDeps.exclude.


    When opening the browser console, the following error appears:

    TypeError: Failed to fetch dynamically imported module


    What I’ve tried:

    Clearing cache and reinstalling dependencies:

    rm -rf node_modules package-lock.json .angular
    npm cache clean --force
    npm install


    Question:

    What could be causing this issue in Angular 19 with Vite when using lazy loading with Ionic? The application worked fine before upgrading Angular, but after the migration, this error prevents modules from loading correctly. How can I fix this?

    Many Thanks!

    Continue reading...

Compartilhe esta Página