You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I generate a navigation component from vue-router/auto/routes.
When modifying a <route> block, I can see the update callbacks working (e.g. in extendRoute) yet most of the time my app is not properly refreshed. Strangely rarely it seems to work with no visible explanation.
Below is a video demonstrating the bug and a bit of debugging from my part.
The change handler works (albeit updatePage is called twice for a single save event... maybe a missed opportunity to debounce FS events), and internal structures look updated alright.
It seems to me that the problem is: no code notifies Vite that the virtual module was changed.
And after a bit of manual calls to server.invalidate("vue-router/auto/routes") and server.reload() it actually works!
I observe though that it works forever which kind of hints at why it sometimes persistently works in my project... Looks like the virtual file remains invalidated, maybe there's a missing call to tell Vite the file has been re-"validated" and should be cached?
2024-01-09_01-18-07.mp4
Side notes from my exploration of the source code for this issue:
getRouteBlock takes a file path as input and reads it from disk, although its only caller writeRouteInfoToNode already has the contents in a string (passed to extractDefinePageNameAndPath). Looks like unneeded I/O.
extractDefinePageNameAndPath only returns name and path? The docs make it sounds like you can use definePage for any purpose, like <route> block:
The macro definePage() allows you to define any extra properties related to the route. It is useful when you need to customize the path, the name, meta, etc
The text was updated successfully, but these errors were encountered:
Upon further thinking: I guess uplugin-vue-router should cache the route block value and the definePage argument.
so that it performs less work every time I save a file (most of the time unrelated to the router);
but more importantly so that it doesn't trigger a reload with every file save, just because "routes may have changed". It needs to be more precise than that to be useable.
I generate a navigation component from
vue-router/auto/routes
.When modifying a
<route>
block, I can see the update callbacks working (e.g. inextendRoute
) yet most of the time my app is not properly refreshed. Strangely rarely it seems to work with no visible explanation.I have a very trivial repro for you here:
https://github.com/jods4/unplugin-router-bug
Below is a video demonstrating the bug and a bit of debugging from my part.
The change handler works (albeit
updatePage
is called twice for a single save event... maybe a missed opportunity to debounce FS events), and internal structures look updated alright.It seems to me that the problem is: no code notifies Vite that the virtual module was changed.
And after a bit of manual calls to
server.invalidate("vue-router/auto/routes")
andserver.reload()
it actually works!I observe though that it works forever which kind of hints at why it sometimes persistently works in my project... Looks like the virtual file remains invalidated, maybe there's a missing call to tell Vite the file has been re-"validated" and should be cached?
2024-01-09_01-18-07.mp4
Side notes from my exploration of the source code for this issue:
getRouteBlock
takes a file path as input and reads it from disk, although its only callerwriteRouteInfoToNode
already has the contents in a string (passed toextractDefinePageNameAndPath
). Looks like unneeded I/O.extractDefinePageNameAndPath
only returnsname
andpath
? The docs make it sounds like you can usedefinePage
for any purpose, like<route>
block:The text was updated successfully, but these errors were encountered: