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 doesn't work on Vue components #8071

Closed
1 task
TechAkayy opened this issue Aug 14, 2023 · 8 comments · Fixed by #8860
Closed
1 task

HMR doesn't work on Vue components #8071

TechAkayy opened this issue Aug 14, 2023 · 8 comments · Fixed by #8860
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: hmr Related to HMR (scope) pkg: vue Related to Vue (scope)

Comments

@TechAkayy
Copy link

What version of astro are you using?

2.10.7

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

When updating Vue component (client:load applied), HMR doesn't apply.

Here is the github repo - https://github.com/TechAkayy/pg-astro

In the stackblitz version of the github repo, in HeroSection, uncomment the console.log statement. The whole component vanishes from the page on HMR update.

Again, refresh the page, and now change the count variable from 0 to 1. HMR again breaks. Same issue, the whole component vanishes from the page.

image

What's the expected result?

HMR should apply correctly.

Link to Minimal Reproducible Example

https://stackblitz.com/github/TechAkayy/pg-astro?file=src%2Fcomponents%2FHeroSection.vue

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 14, 2023
@natemoo-re natemoo-re added pkg: vue Related to Vue (scope) - P3: minor bug An edge case that only affects very specific usage (priority) feat: hmr Related to HMR (scope) labels Aug 14, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Aug 14, 2023
@natemoo-re natemoo-re added - P4: important Violate documented behavior or significantly impacts performance (priority) and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Aug 14, 2023
@natemoo-re
Copy link
Member

Thanks, we'll take a look at this as soon as we can!

@natemoo-re
Copy link
Member

I noticed that you're using both of these in the same component... is that supported? I don't think I've ever seen it before.

<script lang="ts">
  export default {
    data() {
      return {
        count: 0,
      }
    },
    mounted() {
      /* uncomment the below line */
      // console.log(this.count)
    },
  }
</script>

<script setup lang="ts">
  defineProps({
    name: {
      type: String,
      default: 'HeroSection',
    },
  })
</script>

@natemoo-re natemoo-re added the needs response Issue needs response from OP label Aug 16, 2023
@TechAkayy
Copy link
Author

TechAkayy commented Aug 17, 2023

I just removed the second script section from the reproduction. The HMR issue still exists, and it doesn't seem to be related to the 2 script tags.

Try opening the above stackblitz link, and uncomment the console.log line. HMR breaks and the whole component vanishes from the index page.

Though very uncommon, for certain scenarios, the script setup can be used alongside normal script tag in a Vue SFC - https://vuejs.org/api/sfc-script-setup.html#usage-alongside-normal-script.

The above double script tags example in the SFC playground. HMR works fine if you uncomment like above and edit the component in this playground.

@natemoo-re natemoo-re removed the needs response Issue needs response from OP label Aug 17, 2023
@natemoo-re
Copy link
Member

Thanks for clarifying, definitely still valid then! Will continue to investigate.

@louiss0
Copy link
Contributor

louiss0 commented Sep 6, 2023

I decided to just ignore it but yes the component disappears in SSR. Oh I'd like to add that it takes a long time to load

@McSmog
Copy link

McSmog commented Oct 2, 2023

Need fix this too

@TechAkayy
Copy link
Author

Hi @natemoo-re, just checking if there are any workaround for now until this HMR issue is fixed?

Could it be related to applying client directives directly on Vue components? Wondering if wrapping the Vue components in an .astro intermediary will help, though I haven't tried that.

Thanks for looking into this!

@louiss0
Copy link
Contributor

louiss0 commented Oct 8, 2023

Hi @natemoo-re, just checking if there are any workaround for now until this HMR issue is fixed?

Could it be related to applying client directives directly on Vue components? Wondering if wrapping the Vue components in an .astro intermediary will help, though I haven't tried that.

Thanks for looking into this!

He has not said anything in a long time. Did switching to 3.0.0 change anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: hmr Related to HMR (scope) pkg: vue Related to Vue (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants