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 not working on import code snippets #117

Closed
yuxino opened this issue Nov 6, 2020 · 14 comments · Fixed by #2581 or #3005
Closed

HMR not working on import code snippets #117

yuxino opened this issue Nov 6, 2020 · 14 comments · Fixed by #2581 or #3005
Assignees
Labels
bug Something isn't working build Related to the build system

Comments

@yuxino
Copy link

yuxino commented Nov 6, 2020

Describe the bug

HMR not working on import code snippets

To Reproduce

Steps to reproduce the behavior:

see this video

Expected behavior

auto update code

System Info

  • vitepress version: 0.7.2
  • Node version: v13.14.0
  • OS version: osx 10.15.3
@yuxino yuxino added the bug: pending triage Maybe a bug, waiting for confirmation label Nov 6, 2020
@kiaking
Copy link
Member

kiaking commented Nov 10, 2020

@yuxino Hi! I can't even make code snippet import to work in the first place 😅 Your reproduction repo is 404, could you fix that?

@kiaking kiaking added need more info Further information is requested and removed bug: pending triage Maybe a bug, waiting for confirmation labels Nov 10, 2020
@yuxino
Copy link
Author

yuxino commented Nov 11, 2020

@kiaking my bad ,now repo is public

@kiaking
Copy link
Member

kiaking commented Nov 16, 2020

OK thanks! I've confirmed it. I'm not sure if this feature is fully supported yet... 😅 Let's mark this issue as an enhancement and see if we can make it work.

@kiaking kiaking added enhancement New feature or request and removed need more info Further information is requested labels Nov 16, 2020
@lovetingyuan
Copy link

any update on this feature?

@brc-dd brc-dd added the build Related to the build system label Jun 5, 2022
@brc-dd

This comment was marked as outdated.

@brc-dd brc-dd closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2022
@brc-dd brc-dd reopened this Jul 7, 2022
@brc-dd brc-dd mentioned this issue Jul 7, 2022
4 tasks
@brc-dd
Copy link
Member

brc-dd commented Jul 8, 2022

Also not on imported markdown files. HMR is triggering for them, but we are using custom handleHotUpdate that's not able to handle the updates in that case.

@brc-dd
Copy link
Member

brc-dd commented Jul 9, 2022

https://github.com/vuejs/vitepress/compare/chore/vite-3...fix/hmr?expand=1 -- these changes seem to fix this. But I'm not sure if this is proper/elegant way to do stuff.

@yl-199807
Copy link

I also met. Hope to be fixed.
The same problem on vuepress is fixed.
vuejs/vuepress#1309
vuejs/vuepress#1358

@wycats
Copy link

wycats commented Aug 29, 2022

@brc-dd said:

chore?expand=1 (compare) -- these changes seem to fix this. But I'm not sure if this is proper/elegant way to do stuff.

This link isn't working (anymore?). What did your kludgy fix do?

@brc-dd
Copy link
Member

brc-dd commented Aug 29, 2022

Ah, that vite-3 branch was deleted after merging. That HMR branch is still there (outdated though). These were the changes I was referring to: 7dbceaa?w=1

@wycats
Copy link

wycats commented Nov 29, 2022

Is there any more progress on this? I can see how to do it in a fork, but I'd rather not rely on code that will inevitably become stale.

If I'm thinking about this correctly, what we need is a way to augment the includes that are currently hardcoded to the @include syntax (the code already calls server.addWatchFile for all files that the markdown function returns as includes).

Adding a way to collect additional includes to the markdown-it env seems straightforward. If there's interest, I'd be happy to take a stab at a pull request that does that 😄

@wycats
Copy link

wycats commented Nov 30, 2022

Ah, I can see that this problem exists even if an include is added. I was so focused on my use-case that I didn't notice that the HMR issue exists even if server.addWatchFile is used.

I still think that it would be good to let markdown plugins do custom includes, but perhaps the API needs to be rich enough to support HMR. If there's interest, I can dig into that 😄

@brc-dd brc-dd added bug Something isn't working has-workaround Has workaround, low priority and removed enhancement New feature or request labels Jan 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 12, 2023
@brc-dd brc-dd reopened this Jul 31, 2023
@vuejs vuejs unlocked this conversation Jul 31, 2023
@brc-dd brc-dd self-assigned this Jul 31, 2023
@brc-dd
Copy link
Member

brc-dd commented Aug 1, 2023

The solution in #2581 seems to work for most cases, but one might also need to add some plugin like https://github.com/ElMassimo/vite-plugin-full-reload e.g. in cases where a vue component is both imported and included as code snippet.

@brc-dd
Copy link
Member

brc-dd commented Sep 23, 2023

Okay, so this should work fine without any extra config in next version. I went with a slightly modified approach of what I had earlier proposed in 7dbceaa

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working build Related to the build system
Projects
None yet
6 participants