vuejs / pinia

🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support
https://pinia.vuejs.org
MIT License
13.06k stars 1.05k forks source link

Bundling breaks things #778

Closed Rigo-m closed 2 years ago

Rigo-m commented 2 years ago

Reproduction

https://github.com/Rigo-m/pinia-issue-repro

Steps to reproduce the behavior

  1. yarn generate
  2. yarn start'
  3. See error in console (Vue2.use is not a function)

Expected behavior

Should compile correctly

Actual behavior

Development environment works correctly, bundling nuxt2 with nuxt generate breaks the website.

Additional information

The reproduction repo is the same as issue #767 , so pull new version if you hadn't. Also, in the repo you can see issue #767 fixed by using @nuxtjs/composition-api#fix/transpile-server-vue. Also, in the repo you can switch between official @pinia/nuxt module and a local module (line 33/34 nuxt.config.js) which has been stripped from Vue Demi logic (thanks to @nash403 ) and shows that the culprit is Vue Demi itself somehow.

I thought of creating a new issue since this problem is now reproducible with the latest @pinia/nuxt module.

posva commented 2 years ago

What is that custom composition api dependency? Please give more details

Rigo-m commented 2 years ago

As I stated in Additional information it's a branch that fixes issue #767 that @danielroe crafted this morning.

posva commented 2 years ago

aah, the issue was blank on mobile lol

posva commented 2 years ago

@danielroe Is https://github.com/nuxt-community/composition-api/commit/a5f54601ea3c7af8b9cf97d0493d917ed71ee08c something planned on being released or was it a test maybe? @Rigo-m Thanks for looking into it! We don't know yet what the proper fix will be but it's great you found a workaround!

Rigo-m commented 2 years ago

@posva thanks to you for pinia, it really helped me with development. I'm sorry about all the fuss of the last week. I wish I could do more about fixing the issues but I am really struggling with a project and I don't have much spare time. If you need anything just ask, I will make a donation for sure ;)

eMeRiKa13 commented 2 years ago

A fix has been pushed on Nuxt https://github.com/nuxt/framework/pull/1779

but quoting pi0:

Thanks! LGTM however this doesn't fix latest pinia module since they reverted back from using kit. We also need to normalize in template utils

posva commented 2 years ago

I pushed a new version that seems to work. Make sure to remove pinia from transpile option if you still have it and let me know if it doesn't work (I tested with your repro and now it works)

nash403 commented 2 years ago

Thank you ! Just had to also update @nuxtjs/composition-api and now it works 😃

And also thanks for this amazing package ! 👌