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

HMR for vuex store #325

Closed
uptownhr opened this issue Feb 28, 2017 · 18 comments · Fixed by #4582
Closed

HMR for vuex store #325

uptownhr opened this issue Feb 28, 2017 · 18 comments · Fixed by #4582
Assignees
Projects

Comments

@uptownhr
Copy link

uptownhr commented Feb 28, 2017

I thought using modules mode will automatically add in the HMR code but found out that it is not.

https://vuex.vuejs.org/en/hot-reload.html

This feature request is available on Nuxt.js community (#c276)
@Atinux Atinux self-assigned this Feb 28, 2017
@uptownhr
Copy link
Author

any chance this can be included in the 1.0 releåse?

@uptownhr
Copy link
Author

if (module.hot) {
  module.hot.accept([
    './modules'
  ], () => {
    store.hotUpdate({
      modules: require('./modules')
    })
  })
}

is what i used in another project of mine. Not sure how difficult it is to inject this into the store template.

@Atinux
Copy link
Member

Atinux commented Apr 17, 2017

It will be directly in this file @uptownhr https://github.com/nuxt/nuxt.js/blob/master/lib/app/store.js

@Atinux Atinux added this to 0.11.0 in Roadmap 1.0 Apr 17, 2017
@Atinux Atinux moved this from 0.11.0 to 1.0 in Roadmap 1.0 Jun 20, 2017
@Atinux
Copy link
Member

Atinux commented Nov 2, 2017

HMR for store

@galvez
Copy link

galvez commented Aug 9, 2018

@Atinux @clarkdo closable?

@ghost
Copy link

ghost commented Aug 10, 2018

This feature-request has been cancelled by @manniL.

This is already working out of the box

@ghost ghost closed this as completed Aug 10, 2018
@uptownhr
Copy link
Author

uptownhr commented Aug 10, 2018 via email

@manniL
Copy link
Member

manniL commented Aug 10, 2018

Not sure when it got implemented exactly, but works in nuxt v1.4.2 and in nuxt-edge

@uptownhr
Copy link
Author

uptownhr commented Aug 10, 2018 via email

@manniL
Copy link
Member

manniL commented Aug 10, 2018

@uptownhr Don't think so. When testing the feature I used the store in modules mode and added a new property to the state 🤔

@uptownhr
Copy link
Author

@manniL I just created a sample project off of, vue init nuxt-community/starter-template <project-name> and created a simple store that looks like,

export const state = () => ({
  hmr: true
})


export const getters = {
  hmr (state) {
    return state.hmr
  }
}

I can confirm that on my machine the HMR does not work.

This is what I see in my browser console.

VM429 vendor.js:19773 Ignored an update to unaccepted module ./store/index.js -> ./store recursive ^\.\/(?!-)[^.]+\.(js)$ -> ./.nuxt/store.js -> ./.nuxt/index.js -> ./.nuxt/client.js -> 0
onUnaccepted @ VM429 vendor.js:19773
hotApply @ VM428 manifest.js:468
cb @ VM429 vendor.js:19817
(anonymous) @ VM429 vendor.js:19833
Promise.then (async)
check @ VM429 vendor.js:19832
webpackJsonp../node_modules/webpack-hot-middleware/process-update.js.module.exports @ VM429 vendor.js:19793
processMessage @ VM429 vendor.js:19716
handleMessage @ VM429 vendor.js:19584
handleMessage @ VM429 vendor.js:19547
VM429 vendor.js:19846 [HMR] The following modules couldn't be hot updated: (Full reload needed)
This is usually because the modules which have changed (and their parents) do not know how to hot reload themselves. See https://webpack.js.org/concepts/hot-module-replacement/ for more details.
logUpdates @ VM429 vendor.js:19846
applyCallback @ VM429 vendor.js:19814
(anonymous) @ VM429 vendor.js:19822
Promise.then (async)
cb @ VM429 vendor.js:19821
(anonymous) @ VM429 vendor.js:19833
Promise.then (async)
check @ VM429 vendor.js:19832
webpackJsonp../node_modules/webpack-hot-middleware/process-update.js.module.exports @ VM429 vendor.js:19793
processMessage @ VM429 vendor.js:19716
handleMessage @ VM429 vendor.js:19584
handleMessage @ VM429 vendor.js:19547
VM429 vendor.js:19854 [HMR]  - ./store/index.js
(anonymous) @ VM429 vendor.js:19854
logUpdates @ VM429 vendor.js:19853
applyCallback @ VM429 vendor.js:19814
(anonymous) @ VM429 vendor.js:19822
Promise.then (async)
cb @ VM429 vendor.js:19821
(anonymous) @ VM429 vendor.js:19833
Promise.then (async)
check @ VM429 vendor.js:19832
webpackJsonp../node_modules/webpack-hot-middleware/process-update.js.module.exports @ VM429 vendor.js:19793
processMessage @ VM429 vendor.js:19716
handleMessage @ VM429 vendor.js:19584
handleMessage @ VM429 vendor.js:19547
VM429 vendor.js:19893 [HMR] Reloading page

@manniL manniL reopened this Aug 10, 2018
@manniL
Copy link
Member

manniL commented Aug 10, 2018

@uptownhr I see the point. Will open up a a PR soon, but I’m unsure if it’ll make it to 2.0.

@galvez
Copy link

galvez commented Sep 3, 2018

Closing as there's already a PR in development.

@galvez galvez closed this as completed Sep 3, 2018
@manniL
Copy link
Member

manniL commented Sep 23, 2018

In Nuxt 2, store HMR works as far as possible.

@lock
Copy link

lock bot commented Oct 31, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 31, 2018
@nuxt nuxt unlocked this conversation Dec 18, 2018
@manniL manniL reopened this Dec 18, 2018
@manniL
Copy link
Member

manniL commented Dec 18, 2018

image

HMR could be improved as a full reload of the page is still necessary to update the module

@manniL
Copy link
Member

manniL commented Dec 18, 2018

How to reproduce:

Repo: https://github.com/manniL/nuxt-no-store-module-hmr/tree/master/
CSB: https://codesandbox.io/s/github/manniL/nuxt-no-store-module-hmr/tree/master/

  1. Launch with yarn dev
  2. Uncomment 2nd getter
  3. see message from comment before

@manniL
Copy link
Member

manniL commented Dec 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants