codecasts / spa-starter-kit

A highly opinionated starter kit for building Single Page Applications with Laravel and Vue.js
MIT License
913 stars 134 forks source link

Import store in eager components causes a circular dependency #112

Open stefanosandes opened 7 years ago

stefanosandes commented 7 years ago

The problems only happens on eager components.

For example:

If you import and log the store on app/auth/components/main.vue, the output is the store object. But, if you make this component eager and run de test again, the output will be undefined.

I belive that the problem is caused by an circular dependency:

store/index -> store/modules -> app/index -> app/routes -> app/auth/index -> app/auth/routes -> app/auth/components/main -> src/store

In my specific case, a need to use the store inside de vue-router beforeRouteEnter guard to access some info in the store. Inside this guard, this.$route will not be available, because the component instance has no created yet.