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: 编辑 .vue 组件 template 后,再去编辑组件中导入的外部脚本时,外部脚本的 hmr 失效 #10422

Closed
7 tasks done
ghost opened this issue Oct 11, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@ghost
Copy link

ghost commented Oct 11, 2022

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

https://stackblitz.com/edit/vitejs-vite-vhs1cm?file=vite-project%2Fsrc%2Fcomponents%2FHelloWorld.vue,vite-project%2Fsrc%2Fcomponents%2Fdata.ts&terminal=dev

Steps to reproduce

  1. npm run dev;
  2. compoents/data.ts: 修改 export const text: string = 'text' 为 export const text: string = 'text1'; // hmr 正常
  3. comonents/HelloWorld.vue: 修改 template, 列如 HelloWorld 改为 Hello; // hmr 正常运行
  4. compoents/data.ts: 修改 export const text: string = 'text1' 为 export const text: string = 'text2'; // 控制台打印 hmr updated,页面未更新
  5. 刷新页面,text 更新;
  6. 再次修改 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.1566

Used Package Manager

npm

Logs

No response

Validations

@ghost ghost added the pending triage label Oct 11, 2022
@sapphi-red
Copy link
Member

Duplicate of vitejs/vite-plugin-vue#7

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2022
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Oct 23, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2022
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

1 participant