-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
Version
2.6.11
Reproduction link
https://new-issue.vuejs.org/?repo=vuejs/vue
Steps to reproduce
I have a vue plugin reusable project which i developed and runs stand alone fine. I converted this project to plugin as this ui project can be reused at multiple places.
When i registered this plugin in another main project, it fails to start with below error.
This is how i register in main project's main.ts file:
Vue.use(ProfilePlugin, { store });
This is how i defined my vue plugin vuex -> action with async function:
async getProfile({ commit },email) {
await profileService.getUserProfile(email);//this line 2 is causing an issue
commit('SET_PROFILE READ SUCCESS', true);
}
I export all the vuex modules() from plugin like below..
export {
profileStore
};
But when my project tries to register this plugin in my main project
Uncaught TypeError: rawModule is undefined
When i comment line 2 which is the await statement in my async function everything works fine. I used link below to develop my resuable ui library component with its own vuex
https://vuejs.org/v2/guide/plugins.html#Using-a-Plugin
The code i have from plugin with install method:
import * as storeModules from '@/state/_index';
import routes from '@/router/_index';
export { routes };//to register with main vue project
import _Vue from 'vue';
const components: any = { EngHomeComponent };
const modules: any = { ...storeModules };
const install = (Vue: typeof _Vue, options: any): void => {
if (!options || !options.store) {
throw new Error('Please initialise plugin with a Vuex store.');
}
Object.keys(modules).forEach((key) => {
options.store.registerModule(key, modules[key]);
});
Object.keys(components).forEach((componentName) => {
const component = components[componentName];
Vue.component(component.name, component);
});
};
export default {
install,
};
What is expected?
vue project should be able to import plugin register the plugin's store even when plugin store has actions with async await keyword
What is actually happening?
Uncaught TypeError: rawModule is undefined
If i remove my api call then the code works fine.