Closed phiberber closed 1 year ago
Can you maybe provide an example repository or CodeSandbox link? If I run npm run dev
in the React example and modify Home.tsx
hot reload works as intended. What steps are needed to reproduce the issue?
Could you try to run the Preact example then? I can reproduce it by just installing the preact example and changing an entry file.
Ah okay, I see. I can change any file but the entry script, i.e. changing Home.tsx
(or any other component) works but changing main.tsx
breaks. I hope I'll find some time to look into this tomorrow.
Okay, I know what's going on. It all boils down to this line and me being lazy - I used the wrapper mechanism to serve the client hydration code even if the server entry is requested. The idea was to allow projects having only a server entry and no client entry file at all.
One problem that I've had with Capri was the Hot Reload, seems that every Hot Reload makes Vite return the
virtual/client.js
file without the entry code, I can reproduce it just by running the preact example and changing themain.tsx
file, here is the content Vite serves before the changes:Here is the content after the changes:
Seems that the t query parameter is added but it seems to have no effect on what Vite serves as the
main.tsx
file. To fix this issue I've changed the line 26 at https://github.com/capri-js/capri/blob/main/packages/capri/src/wrapper.ts fromto
Seems that
this.getModuleInfo(id)
returns{}
when the project starts, adding the wrapper and wrapped values when hot reload is called. Seems the meta properties are only being added after the Hot Reload and I couldn't find the reason why.I would like to know if you have any ideas on what could be happening here, if not I guess I will continue my debugging session.