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 stops if mixin is used #4174

Closed
PeterAlfredLee opened this issue Jul 22, 2021 · 0 comments
Closed

HMR stops if mixin is used #4174

PeterAlfredLee opened this issue Jul 22, 2021 · 0 comments

Comments

@PeterAlfredLee
Copy link

Version

3.2.0-beta.4

Reproduction link

https://github.com/PeterAlfredLee/vue3_hmr_stop

Steps to reproduce

  1. Visit http://localhost:8080/
  2. Check the console output
  3. Change the console.log value in created of src/App.vue
  4. Check the console output
  5. Remove the app.mixin({}) in src/main.js
  6. Check the console output
  7. Change the console.log value in created of src/App.vue
  8. Check the console output

What is expected?

HMR will work and the console log output could be auto updated

What is actually happening?

With the mixin called, the HMR stops and the console log is not auto updated


I found this issue in vue-i18n that reports HMR stops. After some investigation, I found this problem was caused by call of mixin in vue, and it's introduced in version 3.1.0-beta.7.

I think the problem is caused by this :

    resolved = {}
    if (globalMixins.length) {
      globalMixins.forEach(m =>
        mergeOptions(resolved, m, optionMergeStrategies, true)
      )
    }
    mergeOptions(resolved, base, optionMergeStrategies)

The resolved was assigned with a new object and was mixined with globalMixins and base. Therefore the change of base will not influence the actual working var resolved.

I fixed this with simply some simple code change :

    resolved = base
    if (globalMixins.length) {
      globalMixins.forEach(m =>
        mergeOptions(resolved, m, optionMergeStrategies, true)
      )
    }

Hope this helps.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants