-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed as not planned
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists
Description
Describe the bug
hmr: 编辑 .vue 组件 template 后,再去编辑组件中导入的外部脚本时,外部脚本的 hmr 失效
这是一个通过 npm 创建的 vite vue3 项目,纯净的,未导入任何插件。
修改 HellowWorld.vue 文件 template 后,修改 data.js 的 text 值,text 值不能热更新;
代码
HelloWorld.vue
<script setup lang="ts">
import { text } from './data';
</script>
<template>
<h3>HelloWorld</h3>
<h4>text: {{ text }}</h4>
</template>data.ts
export const text: string = 'text'Reproduction
Steps to reproduce
- npm run dev;
- compoents/data.ts: 修改 export const text: string = 'text' 为 export const text: string = 'text1'; // hmr 正常
- comonents/HelloWorld.vue: 修改 template, 列如
HelloWorld改为 Hello; // hmr 正常运行 - compoents/data.ts: 修改 export const text: string = 'text1' 为 export const text: string = 'text2'; // 控制台打印 hmr updated,页面未更新
- 刷新页面,text 更新;
- 再次修改 data.ts 中 text 的值 // hmr 失效
如果 HelloWorld.vue 中更改的是 script 脚本,则 hmr 正常
System Info
System:
OS: Windows 10 10.0.19044
CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
Memory: 1.55 GB / 15.36 GB
Binaries:
Node: 14.19.0 - D:\program\nodejs\node.EXE
Yarn: 1.22.19 - D:\program\nodejs_g\node_global\yarn.CMD
npm: 6.14.16 - D:\program\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (106.0.1370.37)
Internet Explorer: 11.0.19041.1566Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- 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.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists