Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError (analogjs): Cannot read properties of undefined (reading 'push') when launching shell #210

Closed
Seifenn opened this issue Dec 3, 2024 · 2 comments · Fixed by #222

Comments

@Seifenn
Copy link

Seifenn commented Dec 3, 2024

When i launch my application using module federation i get the following error

TypeError: Cannot read properties of undefined (reading 'push')

When i enter inside the code of the federation module i noticed that this part is causing the error inside index.cjs

     name: 'watchLocalSharedImportMap',
    apply: 'serve',
    config: function config(_config3) {
      _config3.optimizeDeps = defu.defu(_config3.optimizeDeps, {
        exclude: [getLocalSharedImportMapPath()]
      });
      _config3.server = defu.defu(_config3.server, {
        watch: {
          ignored: []
        }
      });
      var watch = _config3.server.watch;
      watch.ignored = [].concat(watch.ignored);
      watch.ignored.push("!**" + getLocalSharedImportMapPath() + "**");
    }
  }];

when i log the value of the watch variable i get false but it should be

watch: {
          ignored: []
        }

So i initialized it to this value and its working i can run the shell and the remote loaded in the shell

       name: 'watchLocalSharedImportMap',
    apply: 'serve',
    config: function config(_config3) {
      _config3.optimizeDeps = defu.defu(_config3.optimizeDeps, {
        exclude: [getLocalSharedImportMapPath()]
      });
      _config3.server = defu.defu(_config3.server, {
        watch: {
          ignored: []
        }
      });
      var watch = _config3.server.watch;
      console.log(watch)
      watch =  {
        ignored: []
      }
      watch.ignored = [].concat(watch.ignored);
      watch.ignored.push("!**" + getLocalSharedImportMapPath() + "**");
    }
  }];
}

here the value of watch inside _config3.server is false and the code should change this value

 _config3.server = defu.defu(_config3.server, {
        watch: {
          ignored: []
        }
      });

But its not overriding the value of watch . I dont know if this error is happening for a specific case in my project since i'm using analog js as a host or it should be corrected when the value is false it should be initialized if the defu function does not update the value my project can be found on github vite-module-federation-angular-test.

@Seifenn Seifenn changed the title TypeError: Cannot read properties of undefined (reading 'push') TypeError: Cannot read properties of undefined (reading 'push') when launching shell Dec 3, 2024
@gioboa
Copy link
Collaborator

gioboa commented Dec 3, 2024

Hi @Seifenn I didn't look into the code yet
What's the difference between your example and the official one?

@Seifenn
Copy link
Author

Seifenn commented Dec 4, 2024

The difference is that i'm using an analogjs project as a host not only bare angular. The problem appeared when using analog since i have another example with angular vite that is working correctly.

@gioboa gioboa changed the title TypeError: Cannot read properties of undefined (reading 'push') when launching shell TypeError (analogjs): Cannot read properties of undefined (reading 'push') when launching shell Dec 4, 2024
zhangHongEn added a commit to zhangHongEn/vite that referenced this issue Dec 15, 2024
@gioboa gioboa closed this as completed in fe601c1 Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants