Skip to content
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

.use is not a function #175

Open
jak-hammond opened this issue Jul 15, 2022 · 5 comments
Open

.use is not a function #175

jak-hammond opened this issue Jul 15, 2022 · 5 comments

Comments

@jak-hammond
Copy link

I am attempting to use Pinia inside a Vue 2.6.14 app, I have followed the steps outline by Pinia to install the Vue Composition API plugin but when the app loads, a piece of code inside Vue Demi is throwing and after taking a look it seems to be that in the case of the Vue 2, the default property needs to be first accessed before the use function can be called.

image

image

@jak-hammond
Copy link
Author

jak-hammond commented Jul 15, 2022

Did some digging and found a similar issue on the .cjs file previously which is now successfully detecting the presence of defualt so it seems it might be a case of implementing that same check in here. I did a quick and dirty check in my own app by simply referencing default directly and it successfully installs the composition API....obviously that isn't robust like the fix for the prior issue but it does seem to suggest the same root cause.

image

This seems to be related to Webpacks Module Federation and loading in another Vue app, so potentially an issue conflicting with how the Vue instance is being loaded from there.

@promer94
Copy link

I have the same issus
Repro: https://github.com/promer94/demi-mf-bug

@promer94
Copy link

This problem is more like a webpack bug or capability issue
webpack/webpack#16060

@promer94
Copy link

Find a workaroud for this problem.

For vue < 2.7

npx vue-demi-switch 2 vue/dist/vue.runtime.esm.js could change the entry.

@Dreamer-Somebody
Copy link

Dreamer-Somebody commented Aug 11, 2023

For me,set webpack alias can solve the problem;

alias: {
    'vue-demi': 'vue-demi/lib/v2/index.cjs',
}

then clear webpack cache(./node_modules/.cache)and reboot your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants