vue-meta icon indicating copy to clipboard operation
vue-meta copied to clipboard

Callback-influenced values reset via HMR

Open TheAlexLichter opened this issue 6 years ago • 2 comments

Hey :wave:

data values that are manipulated via a callback function are (wrongly) changed to their original values when HMR kicks in.

Reproduction:

  1. Fork https://codesandbox.io/s/codesandbox-nuxt-exyst
  2. See that isStripeLoaded is "no" first and then turns to "yes" when the script is loaded
  3. Write something in the template and save
  4. See that it turns to "no" again and stays at "no" even though the script is (still) loaded.

Solution

Re-execute callbacks after HMR (might have some false positives related to the value of skip ?)

TheAlexLichter avatar Oct 12 '19 10:10 TheAlexLichter

Have been thinking about the best way to solve this issue. The main difficulty with the proposed solution is to know when after HMR is. There arent any global hmr events available it seems, so we'd have to subscribe to all hmr events using a new hmr client. We could mitigate that a bit by only providing a method to re-apply callbacks which users would need to call themselves on hmr. The other difficulty I guess is that adding dev-only stuff like this to the client build means that it will also be included in production builds, which needlessly increases the bundle size.

pimlie avatar Oct 16 '19 09:10 pimlie

Thanks for your contribution to vue-meta! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of vue-meta
  2. Comment the steps to reproduce it Issues that are labeled as pending will not be automatically marked as stale.

stale[bot] avatar Nov 06 '19 09:11 stale[bot]