-
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
Building libraries using @vue/composition-api #228
Comments
This is one of the caveats of local development of plugins using the composition api: when located in different projects with their own One buggy solution I've used personally is using
IMO this is a big issue because it prevents plugin authors to be productive and simply makes it harder to contribute to the Vue ecosystem. Ideas on how to solve this are welcome |
Hello Posva, thanks for your reply.. |
unfortunately no luck with new approach because of using vapperjs :( https://github.com/shuidi-fed/vapper/issues/52#issue-549487498 |
running into this issue as well with
|
The issue is: the version of composition-api in your library differs from the user importing your library, making webpack linking both libraries, you cannot use two Vue or Vue-composition libraries on your project. You can change to |
hello @pikax |
@mikimoresi you are welcome! 👍 I recommend having a look on some projects using composition-api 💯 |
I think I'm quite prepared now about how to set up components with composition API, anyway I think I have a lack of knowledge about package management, I mean, I would not even know where to look and how to figure out when and why using this peerDependency prop. Do you have any hint? Thank you again |
I had similar issue, not sure if I checked with other libraries to check how they do it, https://github.com/kefranabg/awesome-vue-composition-api#-composition-api-functions there's a few projects, if something is not working properly might be useful checking them :) |
I had the same issue, I developed a library of widgets using this tutorial. I guess 'peer-dependency' it's not possible because my library can't be build without It's more a quick fix, I hope with Vue 3 the problem will disappear. It's not nice sorry, I really hope a better solution ... My library exports: export {
Plugin, // install all components
components, // exported components
plugins,
compositions,
}; I'm free to export the import VueCompositionApi from '@vue/composition-api';
export {
VueCompositionApi,
}; I can import and use VueCompositionApi from the widget library. |
@shenron you can set the |
I did not thought to use |
Well I'll add here that importing and using the plugin in the main.js doesn't work as you still get the "must use plugin.." error. But if you do the import from another file that does the importing and using plugin, it seems to work. |
I ran into this issue too. We were trying to access an exported composition function within the
For anyone else running into this you can find the solution on StackOverflow. |
I meet same issue today |
If i load component from an external dir using a webpack alias (created in vue.config.js) composition components don't work properly.
I created a repository to test the setup: https://github.com/mikimoresi/vapcompvuex
This are the issues:
If I don't use "import Vue from 'vue'; import VueCompositionApi from "@vue/composition-api"; Vue.use(VueCompositionApi);" in the components, Vue alerts me that I must use Vue.use before. This not happens if the component is in the same src of the main project.
If I use "import Vue from 'vue'; import VueCompositionApi from "@vue/composition-api"; Vue.use(VueCompositionApi);" in the components, the components is kinda working but I get "[Vue warn]: The setup binding property "xxx" is already declared." for any property
If I try to use a lifecycle hooks like onMount i get this error "Error in data(): "Error: [vue-composition-api] "onMounted" get called outside of "setup()""
It looks like the problem occur only when I load my components from an external directory via alias. Once I load components from dirs inside main project dir anything starts working properly.
We need components to be in an external dir because we use them in different projects. We prefer to not use them as node modules because is faster while developing. We would love to mantain the webpack alias method if possible.
Thank you.
The text was updated successfully, but these errors were encountered: