solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[Bug?]: dev hmr error: "template2 is not a function"

Open drdxk opened this issue 5 months ago • 5 comments

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:

  1. npm init solid@latest
  2. select TypeScript, notes
  3. npm i
  4. npm run dev, open browser
  5. modify src/routes/(home).tsx, e.g. add extra "!"
  6. observe browser state

Context 🔦

No response

Your environment 🌎


drdxk avatar Jul 30 '25 20:07 drdxk

Can verify this issue.

Image

brenelz avatar Aug 04 '25 02:08 brenelz

Do we know is it only the notes template? I tried downgrading and the same issue with HMR

brenelz avatar Aug 04 '25 02:08 brenelz

fwiw, I was checking out some other templates and building something small off of the basic template and haven't seen that issue elsewhere

drdxk avatar Aug 04 '25 11:08 drdxk

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.

In the mentioned issue:

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?

dennev avatar Aug 05 '25 16:08 dennev

I'm encountering the same issue in my pet project. Could you give some hints on where this problem stems from?

htndev avatar Sep 03 '25 21:09 htndev