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

Volar does not reload when script lang=ts src file changes #565

Closed
Shinigami92 opened this issue Oct 7, 2021 · 5 comments
Closed

Volar does not reload when script lang=ts src file changes #565

Shinigami92 opened this issue Oct 7, 2021 · 5 comments

Comments

@Shinigami92
Copy link
Collaborator

Shinigami92 commented Oct 7, 2021

// file.ts
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    return {
      // Comment this in again
      // life: ref(42)
    }
  }
})
<!-- file.vue -->
<template lang="pug">
div {{ life }}
//-    ~~~~ this will still not get recognized after exposing `life`
</template>

<script lang="ts" src="file"></script>

Currently we always need to restart Volar via VS Code command

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Oct 7, 2021

This is a design behavior that takes into account performance issues. #455 can completely solve this problem. Before that, I was still looking for alternatives.

For now you can do that:

  1. Edit your .ts code
  2. If not using take over mode, save .ts code.
  3. Insert a new line into <script ...>|</script>, and then undo.
  4. Template diagnosis should be updated correctly.

@Shinigami92
Copy link
Collaborator Author

Shinigami92 commented Oct 7, 2021

Just theoretically (without looking in how Volar works)
Would it be possible to watch for changes of files that are referenced via src? Or is this exactly the performance issue you mentioned?
So at least we wont need to watch for all changes in the project file structure, but only the script referenced once (from .vue files).

We tried to change

<script lang="ts" src="file"></script>
# to
<script lang="ts" src="fil"></script> # save file
# back to
<script lang="ts" src="file"></script> # save file again

But that didn't work
So we will try your suggestion tomorrow

@johnsoncodehk
Copy link
Member

Just theoretically (without looking in how Volar works) Would it be possible to watch for changes of files that are referenced via src? Or is this exactly the performance issue you mentioned?

This way have no performance problem, but the implement not as simple as it looks.

We tried to change

<script lang="ts" src="file"></script>
# to
<script lang="ts" src="fil"></script> # save file
# back to
<script lang="ts" src="file"></script> # save file again

But that didn't work

This is expected, only <script> content trigger template update for now.

@chenjiangui
Copy link

same problem, when use <script lang="ts" src="file"></script>, file change volar don't reload

@reuwi
Copy link

reuwi commented Apr 18, 2022

@johnsoncodehk I'm writing the script code into the same file of .vue file, still got this problem,and relative version is: 2022/4/16 15:04:20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants