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 for NPM library components that are appended to a slot #5767

Closed
lingosandi opened this issue Apr 20, 2022 · 20 comments
Closed

Comments

@lingosandi
Copy link

Version

3.2.33

Reproduction link

github.com

Steps to reproduce

  1. download code as zip from https://github.com/lingo3d/vue-bug-example-client
  2. yarn install & yarn dev
  3. open src/App.vue
  4. try changing message prop in the outer component, HMR should update your page immediately
  5. try changing message props in the child component, you can see that no change occurs until you manually refresh the page

What is expected?

HMR should update the child component when props are changed, just like it does for the parent component

What is actually happening?

HMR fails to update the child component


this phenomenon doesn't occur during dev. It only appears when a library is build using Vite's library mode and uploaded to NPM, and is installed by a client. This presents a huge problem for library authors. You can find the source code and build settings of the test library from here: https://github.com/lingo3d/vue3-bug-example

@lingosandi
Copy link
Author

Correction: this phenomenon doesn't only happen with Vite. The same test library built with @vue/cli exhibits identical behavior.

@rtek
Copy link

rtek commented Apr 21, 2022

@lingosandi the vue3-bug-example repo is missing the source. I might be having the same issue demoed at https://stackblitz.com/edit/vite-auuvqt?file=src%2Fcomponents%2FWrapper.vue

@lingosandi
Copy link
Author

@lingosandi the vue3-bug-example repo is missing the source. I might be having the same issue demoed at https://stackblitz.com/edit/vite-auuvqt?file=src%2Fcomponents%2FWrapper.vue

I've uploaded the code, thanks for catching that

@ragokan
Copy link

ragokan commented May 3, 2022

I am also having this issue in Vite. I get the [vite] hot updated: /src/pages/data/category.vue log on my console, yet nothing is updated. I use this with vue-router, so when I change the page and come back, I can see the update.

@molvqingtai
Copy link

molvqingtai commented May 17, 2022

In the same problem, I use elements-plus, the console has hmr log, but the page will not be updated

@adarshmadrecha
Copy link

Same issue. Using Quasar + Windi + Vite

@esfox
Copy link

esfox commented Jun 7, 2022

Using PrimeVue 3's DataTable component, I experience this issue as well. (Was linked here from this).

One workaround I did was to add :key="Date.now()" in the component that wasn't refreshing.

@MilkoEmanuilov
Copy link

I've had the same issue with nuxt3 + vite + vuetify.
In my case adding
server: { watch: { usePolling: true, }, },
This solved the problem for me but for the solution that is posted did not work.
Is there anyone who have any suggestion?

@daniloribeiro00
Copy link

I've had the same issue with nuxt3 + vite + vuetify. In my case adding server: { watch: { usePolling: true, }, }, This solved the problem for me but for the solution that is posted did not work. Is there anyone who have any suggestion?

It didn't work for me (vue 3 + vite)

@aronsuarez
Copy link

Same problem with vue 3 + vite + primevue

@cnguyen-de
Copy link

cnguyen-de commented Aug 4, 2022

Have the same issue, currently doing a migration vue 2 -> 3, application is in compat mode. We have vite 3 + vue 3, polling also doesn't work.

@tintin10q
Copy link

tintin10q commented Aug 18, 2022

For me the solution by @MilkoEmanuilov worked. But it updates much slower than before.

@daniloribeiro00
Copy link

I tried it too, but it didn’t work for me.

@EzeFSpa
Copy link

EzeFSpa commented Sep 9, 2022

Exactly the same thing happens to me too.
When I modify a property of a component, the web page does not refresh it. If I modify any common html element (div, span) it does refresh.

This solution:
server: { watch: { usePolling: true, }, },
it didn't work for me.

Versions:
vite: 3.1.0
vuejs: 3.2.39

@EzeFSpa
Copy link

EzeFSpa commented Sep 11, 2022

I was playing a bit with the example (https://stackblitz.com/edit/vite-auuvqt?file=src%2Fcomponents%2FWrapper.vue) and I discovered that if the properties are associated to a ref variable, the hmr always works, but not with a value expressed in the template

This was what I tried and works:
image

The Child component with its associated aPropRef property is correctly updated in the browser if its value is changed in <script setup>.

Another test I did:
Change the properties of the other Child components with text in the template section and at the end change the value of aPropRef and the browser will reflect ALL the previous changes.

I hope this helps

@yyx990803
Copy link
Member

This has been fixed by #4077 (>=3.2.38)

@aronsuarez
Copy link

This issue still persist

vue 3.2.45
vite 3.2.4
primevue 3.22.3

Is there any workarround?

@IamDamba
Copy link

IamDamba commented Jan 20, 2023

Same for me too, the probleme is still here:
@vitejs/plugin-vue 4.0.0,
vite 4.0.0

@VamoCodar
Copy link

he same problem with Hot reload not updating
It happened to me

vue 3.2.45
quasar/app-vite: 1.2.1,
quasar: 2.11.10,

I changed the vue to version 3.2.38 and it solved

@sanba-anass
Copy link

sanba-anass commented Jul 17, 2023

the issue is still there using the latest version of vue , not using any libray just changing a prop does not hot reload anything
iwas using this to get my props :
const props = defineProps(['msg']);
const msg= props.msg

switching to this fixes the issue :
const props = defineProps({
msg: {
type: String,
required:true
},
});

@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet