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

vite: true breaks Nuxt 2 Vuex store #847

Closed
deleteme opened this issue Jun 28, 2023 · 0 comments · Fixed by #851
Closed

vite: true breaks Nuxt 2 Vuex store #847

deleteme opened this issue Jun 28, 2023 · 0 comments · Fixed by #851

Comments

@deleteme
Copy link
Contributor

deleteme commented Jun 28, 2023

Environment

  • Operating System: Darwin
  • Node Version: v18.15.0
  • Nuxt Version: 2.17.0
  • Nitro Version: 2.5.2
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: head, css, plugins, components, buildModules, modules, axios, build, bridge, serverHandlers, devServerHandlers, devServer, typescript, nitro
  • Runtime Modules: @nuxtjs/axios@5.13.6
  • Build Modules: (), @nuxt/bridge@3.0.0-28132497.798694a

Reproduction

https://github.com/deleteme/nuxt2-bridge-vite-bug/tree/vite-with-vuex-store

Steps to reproduce:

  1. Clone a copy of the https://github.com/deleteme/nuxt2-bridge-vite-bug repo and check out the vite-with-vuex-store branch
  2. yarn
  3. yarn dev
  4. visit http://localhost:3000/usestore in the browser
  5. Notice that the Vuex store state is undefined and that the Increment button doesn't work

Describe the bug

After changing vite: true in nuxt.config.js, the Vuex store is not initialized properly when starting a Nuxt 2 server that uses a basic Vuex store. Initial state is undefined. Here's a short video demonstrating the bug:

vite-vuex-store-bug.mov

Something interesting that's happening is that if you restart the server process while having the page open, sometimes the server is able to initialize the Vuex store and the hot reloading can scoop it up.

vite-vuex-store-bug-pt2.mov

Additional context

This is a fresh Nuxt 2 app with the latest bridge added.

  • Vuex store code was lifted from the official docs
  • The only config change is setting vite: true.
  • No errors were thrown in the server log output when running nuxi dev.

Logs

No response

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.

1 participant