Vite HMR stops working when subscribing to events in Vue 3 components when mitt is bundled in another package
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- typescript, vite
- Ambito
- build-system, frontend, tooling
Direzione di ricerca
Riproducete il problema in un progetto Vue 3 + Vite usando mitt-vue 2.1.0, quindi confrontate la copia locale di src/lib/mitt-vue.js con la build CommonJS del pacchetto. Iniziate da useEventEmit, useEventListener e dalla configurazione di Vite, e verificate che le modifiche ai componenti attivino aggiornamenti HMR visibili senza un refresh manuale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I’m encountering an issue where Hot Module Replacement (HMR) stops working when using the functions useEventEmit or useEventListener from mitt-vue in my Vue 3 project.
mitt-vue is a package that bundles event subscription and unsubscription in the onMounted and onUnmounted Vue lifecycles so developers don't have to code it every single time they want a component to listen to events.
The issue doesn't occur when I replicate mitt-vue locally by copying the contents of the package into my project. It works fine in that case, and HMR functions normally. However, when importing and invoking useEventEmit or useEventListener directly from mitt-vue, HMR ceases to update the components as expected.
Here’s a quick summary of the setup and the steps to reproduce the issue:
Steps to Reproduce:
- Install
mitt-vuein a Vue 3 + Vite project. - Import and use the functions
useEventEmitanduseEventListenerin any Vue component. - Modify any component or file (e.g., .vue or .ts) and observe that HMR stops updating the component properly or even the whole application.
Expected Behavior:
HMR should update the Vue components live without the need to manually refresh the page, even when using mitt-vue functions.
Actual Behavior:
HMR stops working, and changes to Vue components or other files don't trigger the automatic update in the browser. However, the Vite logs indicate that the component is being updated, but the screen does not reflect the change.
Environment:
- Vite Version: 6.0.11 (also failing in 5.X.X)
- Vue Version: 3.5.13
- mitt-vue Version: 2.1.0
- OS: macOS / Linux / Windows
- Node.js Version: 18.19.0 (also failing in 20.X.X)
Additional Notes:
- Local Reimplementation: When I locally replicate the contents of mitt-vue in my project (i.e., copying the mitt-vue.js file into src/lib/), HMR works perfectly.
- I’ve tried resolving the issue by aliasing the package in Vite config, but it still doesn’t work when invoking
useEventEmitoruseEventListener. - I suspect the issue might be related to how Vite handles HMR with packages that are treated as external dependencies, particularly with how
mitt-vueis structured (using require in its CommonJS build). Any guidance or fixes would be greatly appreciated!
- Lingua principale
- TypeScript
- Stelle
- 11.9k
- Fork
- 490
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di developit/mitt
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 1/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Tutte le issue di developit/mitt
Issue simili
-
blocklist removal
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MetaMask/eth-phishing-detect#296544 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pastelsky/bundlephobia#1122 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100