You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am developing a Vite plugin (vite-plugin-vue-css-module) that slightly modifies Vue templates before they are actually rendered. For that, I am adding the transform hook (with enforce: 'pre') where I modify user-provided source code.
I test my modifications to work fine in various user flows, including Vue and pug templates, and of course HMR. I've noticed that vite-plugin-vue works differently when doing HMR on Vue and pug templates, but what I expect is that it behaves consistently on the same type of template after I switch between languages there and back.
What is actually happening is that HMR flow is different on these scenarios:
A. User is only using Vue templates.
B. User was using Vue templates then switched to pug and then back.
While this itself doesn't introduce an immediate user-facing problem, it breaks things for plugin authors.
Namely, after changing language from none to pug and then back, all code modifications returned by transform hooks are completely ignored (see reproduction).
I suspect this also could lead to other subtle problems and/or inefficiencies.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Related plugins
plugin-vue
plugin-vue-jsx
Describe the bug
I am developing a Vite plugin (vite-plugin-vue-css-module) that slightly modifies Vue templates before they are actually rendered. For that, I am adding the
transform
hook (withenforce: 'pre'
) where I modify user-provided source code.I test my modifications to work fine in various user flows, including Vue and pug templates, and of course HMR. I've noticed that
vite-plugin-vue
works differently when doing HMR on Vue and pug templates, but what I expect is that it behaves consistently on the same type of template after I switch between languages there and back.What is actually happening is that HMR flow is different on these scenarios:
A. User is only using Vue templates.
B. User was using Vue templates then switched to pug and then back.
Initially, HMR updates for Vue templates go like:
after changing
<template>
to<template lang="pug">
, it becomes:but after changing it back to
<template>
, the HMR method is not restored to full SFC transform, it still goes with?type=template
submodule updates:While this itself doesn't introduce an immediate user-facing problem, it breaks things for plugin authors.
Namely, after changing language from none to pug and then back, all code modifications returned by
transform
hooks are completely ignored (see reproduction).I suspect this also could lead to other subtle problems and/or inefficiencies.
Reproduction
https://stackblitz.com/edit/nuxt-starter-anyrc6?file=app.vue,nuxt.config.ts
Steps to reproduce
Run
npm install
followed bynpm run dev
(happens automatically in Stackblitz).Then:
app.vue
to see HMR+transform working;System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: