Store not working in web components
See original GitHub issueVersion
3.0.1

Node and OS info
node 10.7.0 / npm 6.3.0
Steps to reproduce
– Go to vue-cli GUI
– create new project (vuex, babel, less-css, no typescript)
– make a simple state in vuex: foo: "bar"
– make it a getter aswell
– go to App.vue
– import mapGetters from vuex
– use mapGetters in computed to get the foo value
– use it in the App.vue template: This is foo: {{ foo }}
– build a web component named: my-component
– open demo.html in a browser
What is expected?
No error
What is actually happening?
Error in console regarding the store 😦
Without the store, webcomponents seem to work fine
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:19 (17 by maintainers)
Top Results From Across the Web
Web component not appearing in html file - Stack Overflow
I call this code using my-navbar in the body and script src="components/navbar. js" in the head because my . js file is in...
Read more >What happened to web components? - LogRocket Blog
HTML imports were abandoned by browser vendors, so even though they're still working with a polyfill, it's not recommended to use them in...
Read more >Web Components - MDN Web Docs - Mozilla
A guide showing how to use the features of custom elements to create simple web components, as well as looking into lifecycle callbacks...
Read more >Vue and Web Components
Using these frameworks entails buying into their technical decisions on how to solve these problems - which, despite what may be advertised, doesn't ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

A web component is a library, conceptually.
So its entry point is not
main.js, but anentry-wc.jsfile generated here: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.jsSo to use vuex in web component target, you need to initialize the store in
App.vue:From the Vuex docs:
Is this somehow possible to set up with a library build target? In lib mode, Vue is externalized, so we can’t rely on
new Vue({ store, ... }).