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 is not working when including component from some npm package #58

Closed
7 tasks done
tchiotludo opened this issue Dec 13, 2022 · 1 comment
Closed
7 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@tchiotludo
Copy link

Describe the bug

I use vue-material-design-icons on vue-cli project without any issues. I try to move to vite and all is working except this package, can't figure why.

  • When I include an icon from the lib (uncomment line 3 from HelloWorld.vue), the HMR is not working
  • I see on the network tab the right, that the module is properly loaded, but not refresh on the page
  • With a full refresh (f5), I can see the modification.

I've try to include exactly the same component on Local (Local.vue) and the HMR is working fine.

Reproduction

https://stackblitz.com/edit/vitejs-vite-ryvwef?file=src%2Fcomponents%2FHelloWorld.vue&terminal=dev

Steps to reproduce

  • uncomment line 3 from HelloWorld.vue
  • See the HMR that is not working anymore

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-vue: ^4.0.0 => 4.0.0 
    vite: ^4.0.0 => 4.0.1

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

Adding optimizeDeps.exclude = ['vue'] to vite.config.js seems to work.

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  optimizeDeps: {
    exclude: ['vue']
  }
})

Because vue-material-design-icons imports vue inside a vue file and vue is optimized, this is a duplicate of vitejs/vite#3910.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2023
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Jan 5, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants