A plugin must either be a function or an object with an "install" function
amit-ksh opened this issue Β· comments
π Current behavior
I am not able to install the plugin. I receive a warning on the vue console in my browser.
[Vue warn]: A plugin must either be a function or an object with an "install" function.
More info: Related issue
π Steps to reproduce
- Go to https://codepen.io/amit-ksh/pen/jOvMEEw
- Open the browser's console and see the warning
Live reproduction
https://codepen.io/amit-ksh/pen/jOvMEEw
π Expected behavior
- Plugin should be a function or have an install function
- Able to use the plugin without any additional steps
Package version
vue-instantsearch 4.13.6
Operating system
Microsoft Windows 11
Browser
Sidekick
Code of Conduct
- I agree to follow this project's Code of Conduct
The Vue InstantSearch for Vue 3 umd build doesn't have the plugin builtin, as in general you want to pick and choose which files you want included. However rewriting the plugin yourself is really simple:
const VueInstantSearchPlugin = {
install(localVue) {
Object.keys(VueInstantSearch).forEach((widgetName) => {
localVue.component(
VueInstantSearch[widgetName].name,
VueInstantSearch[widgetName]
);
});
}
};
@Haroenv curious to know why it is delivered as a dictionary and not as a Vue plugin.
Also, will it remain as a dictionary or be updated to a plugin in the future?
Nobody has asked for a plugin before you in the last couple years since we released Vue 3. Main reason is that the plugin needs to manually be instantiated, which isn't the case for Vue 2 as it can be done globally.
The preferred consumption method isn't through UMD, but through bundling CJS or ESM, so we likely won't change this to a plugin soon.
Yeah! I know UMD is not used in prod app, I just wanted to confirm if it's going to available in future or not.
Got the answers I was looking for so, closing this issue.
Thanks for answering, @Haroenv!