[Bug?]: dev hmr error: "template2 is not a function"
Duplicates
- [x] I have searched the existing issues
Latest version
- [x] I have tested the latest version
Current behavior 😯
npm run dev causes HMR error for notes template
Expected behavior 🤔
no error
Steps to reproduce 🕹
Steps:
- npm init solid@latest
- select TypeScript, notes
- npm i
- npm run dev, open browser
- modify src/routes/(home).tsx, e.g. add extra "!"
- observe browser state
Context 🔦
No response
Your environment 🌎
Can verify this issue.
Do we know is it only the notes template? I tried downgrading and the same issue with HMR
fwiw, I was checking out some other templates and building something small off of the basic template and haven't seen that issue elsewhere
The use of $ServerOnly causes this issue. If you remove the $ServerOnly in
examples/notes/src/app.tsx:14, examples/notes/src/components/SearchField.tsx:15
HMR works fine.
Of course if the browser ever tried to re-rerun it well you are in trouble.
So, by inference, it's probably not a good fit for HMR either.
While I recognize the intent of $ServerOnly from a performance perspective, I also consider that the benefits of HMR may outweigh the opportunity cost of performance improvements due to $ServerOnly, and that there may be other potential issues.
Therefore, I have prepared a commit that removes $ServerOnly from this example. (I have reserved judgment on the $ServerOnly that exists in archived_examples).
Should I replace this example? Or does anyone have another opinion?
I'm encountering the same issue in my pet project. Could you give some hints on where this problem stems from?