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

Add storeToRefs to the auto imports in @pinia/nuxt #1876

Closed
productdevbook opened this issue Dec 14, 2022 · 6 comments · Fixed by #2427
Closed

Add storeToRefs to the auto imports in @pinia/nuxt #1876

productdevbook opened this issue Dec 14, 2022 · 6 comments · Fixed by #2427

Comments

@productdevbook
Copy link

productdevbook commented Dec 14, 2022

What problem is this solving

image

Proposed solution

it needs to be added to the auto import field

Describe alternatives you've considered

No response

@posva posva changed the title Pinia Nuxt 3 storeToRefs dont auto import Add storeToRefs to the auto imports in @pinia/nuxt Dec 21, 2022
@Cyclodex
Copy link

Cyclodex commented Dec 29, 2022

Hi, I just came across this ( I am moving from Vue 2 to Vue 3 + Nuxt + Pinia and learning how to setup things).

I just tried something, which actually seems to work, but not sure if something else would still be needed etc.

Add the storeToRefs-function name to the autoImports within the nuxt.config.ts:

modules: [
    [
      '@pinia/nuxt',
      {
        autoImports: [
          'storeToRefs',

I am using

Nuxt Version:     `3.0.0`
Runtime Modules:  `@pinia/nuxt@0.4.6`

No need to import it again :)

@mrleblanc101
Copy link

Shouldn't this be the default ?

@KnifeFed
Copy link

@pinia/nuxt 0.5.0 removed the autoImports option which broke all my references to storeToRefs. In the CHANGELOG it says "the option autoImports has been removed as it offered no value compared to the existing imports option in Nuxt". But as far as I can tell, you can only add directories to that option. So I guess this is broken until #2427 is released?

@Q16solver
Copy link

Yes, 0.5.0 is breaking my builds as well. Any user that is using storeToRefs as an auto import will have this issue, I believe we'll have to wait till it's added back

@minkoonim
Copy link

why remove autoimports config anyway
it was great option

@minkoonim
Copy link

minkoonim commented Oct 14, 2023

Yes, 0.5.0 is breaking my builds as well. Any user that is using storeToRefs as an auto import will have this issue, I believe we'll have to wait till it's added back

@pinia/nuxt 0.5.0 removed the autoImports option which broke all my references to storeToRefs. In the CHANGELOG it says "the option autoImports has been removed as it offered no value compared to the existing imports option in Nuxt". But as far as I can tell, you can only add directories to that option. So I guess this is broken until #2427 is released?

@Q16solver @KnifeFed
https://nuxt.com/docs/guide/concepts/auto-imports#auto-import-from-third-party-packages

//nuxt.config.ts
...
  imports: {
    presets: [{
      from: 'pinia',
      imports: ['defineStore', 'storeToRefs', 'acceptHMRUpdate'],
    }],
  },

posva added a commit that referenced this issue Oct 16, 2023
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
Co-authored-by: Eduardo San Martin Morote <posva13@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants