-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
web component object as props weird usage doesnt update as it should #5313
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
Comments
Your issue here is that you have two local copies of vue in this repository:
Since Vue relies on a couple of singletons to make reactivity work, you need to make sure that only one copy is every loaded into your app - usually by resolving the An alternative would be a monorepo with workspaces. I did that to your example and it works fine for me: Sidenote: |
On second look I need to reopen, made a mistake and need to re-evaluate |
Ah, still the same reason: 2 copies of Vue. But the real culprit was that you didn't exclude vue from the web components bundle. You need to externalize Vue so that in the consuming app, the same copy of Vue is used for the app and the Vue web component from your lib. build: {
lib: {
entry: path.resolve(__dirname, './src/custom-elements.js'),
name: 'paper-ds',
fileName: (format) => `paper-ds.${format}.js`,
},
rollupOptions: {
external: ['vue']
} also keep in mind that the alias mentioned above might still be necessary in local test scenarios. |
Thank you linus. But if I do that. For other framework like angular or react. They will have to install vue3 right ? Cause it will not work in this case if they don't. Same for vue2 project |
Yes. Which, in my opinion isn't much of a problem. Rather can be an advantage if the consumers might choose to use another web component built on Vue 3 from another vendor. If it is a problem though for you or your consumers tough, you could do 2 builds, one which includes Vue 3 and one which doesn't. |
Agree with you. For vue2 I am going to have an issue no ? how can I an make both working good ? |
Version
3.2.29
Reproduction link
github.com
Steps to reproduce
What is expected?
I can understand for vue2 due to old reactivity that it doens't work properly. But for vue3 with new reactivity even if a data object change it should be able to re render the web component
What is actually happening?
have to spread my object for vue2 and vue3 to make it re render my web component {...obj } that looks like an anti pattern to vue3
The text was updated successfully, but these errors were encountered: