-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
when use <script lang="tsx" setup> with template. HMR can not resolve import component using in template #22
Comments
video can see in issue vuejs/core#6171 (comment) |
I found that the bug was caused by the Vite cache. I've tried if remove them and that can fixes the issue. If that solution is okay, I can try to pr it. 😄 |
@glitchboyl the issue is only show while using<script setup lang="tsx">. <script setup>is ok. maybe it was vue-jsx |
@we125182 Yeah, thank you for your complement. While using |
这个问题目前有解决方案吗? |
@sapphi-red @patak-dev // packages/plugin-vue/src/handleHotUpdate.ts
export async function handleHotUpdate(
{ file, modules, read, server }: HmrContext,
options: ResolvedOptions
): Promise<ModuleNode[] | void> {
...
const affectedModules = new Set<ModuleNode | undefined>()
const mainModule = modules.find(
(m) => !/type=/.test(m.url) || /type=script/.test(m.url)
)
const templateModule = modules.find((m) => /type=template/.test(m.url))
if (hasScriptChanged(prevDescriptor, descriptor)) {
let scriptModule: ModuleNode | undefined // TODO: this line should move out of block
if (
(descriptor.scriptSetup?.lang && !descriptor.scriptSetup.src) ||
(descriptor.script?.lang && !descriptor.script.src)
) {
const scriptModuleRE = new RegExp(
`type=script.*&lang\.${
descriptor.scriptSetup?.lang || descriptor.script?.lang
}$`
)
scriptModule = modules.find((m) => scriptModuleRE.test(m.url))
}
affectedModules.add(scriptModule || mainModule)
}
if (!isEqualBlock(descriptor.template, prevDescriptor.template)) {
// when a <script setup> component's template changes, it will need correct
// binding metadata. However, when reloading the template alone the binding
// metadata will not be available since the script part isn't loaded.
// in this case, reuse the compiled script from previous descriptor.
if (mainModule && !affectedModules.has(mainModule)) { // TODO: here should add condition: !affectedModules.has(scriptModule)
setResolvedScript(
descriptor,
getResolvedScript(prevDescriptor, false)!,
false
)
}
affectedModules.add(templateModule)
needRerender = true
} |
Has it been resolved? Currently, there is still this problem. |
Closing as it can't reproduce with: "dependencies": {
"vue": "3.5.8"
},
"devDependencies": {
"@vitejs/plugin-vue": "5.1.4",
"@vitejs/plugin-vue-jsx": " 4.0.1",
"vite": "5.4.7",
} |
Describe the bug
after project run. replace App.vue<script>code with follows
Reproduction
https://stackblitz.com/edit/vitejs-vite-qrc4zw?file=src/App.vue
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: