-
Notifications
You must be signed in to change notification settings - Fork 344
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
Usage in component library #181
Comments
For future like-me, and thanks to @pikax, I managed to make it work by removing the composition-api from the build of my component library and set it as external. So like this it's sure there is only one instance of VueCompositionApi no matter of where you installed it (app or lib wise). You can see here its rollup config: https://github.com/pikax/vue-composable |
I'm using Vue cli to build my library, so I set // library export
import VueCompositionApi from "@vue/composition-api"
const Plugin = {
install(Vue) {
Vue.use(VueCompositionApi)
Object.keys(components).forEach(key => Vue.component(key, components[key]))
}
} Why would it create another instance if I import That's one way I could get it work. Another way, is your way. I set it as an external package in // library vue.config.js
module.exports = {
chainWebpack: config => {
config.externals(['@vue/composition-api'])
}
} What didn't workDoing this in the app, without installing // app main.js
Vue.use(Components)
Vue.use(VueCompositionApi) |
@adi518 i'm facing the same issue, i created a component and published it to npm but when i install it again in another app it raises the issue when i do |
You have to set it as a peer dependency in your library, add it your app and install with |
Hello,
I would like to use vue-compositon-api into a component library.
Should I do a Vue.use(VueCompositionApi) inside my library's install function or only the app, or both ?
Currently, I have an error, asking me to install it inside my component library if I don't do it there, but only App wise.
vue.runtime.esm.js?2b0e:1888 Error: [vue-composition-api] must call Vue.use(plugin) before using any function.
A reproductible example:
https://github.com/nestarz/vue-simple-maps/blob/master/demo/client-with-composition-api.html
The text was updated successfully, but these errors were encountered: