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

Pragma is not detected if it's not the first comment in file

Open victor-wm opened this issue 4 years ago • 9 comments

Hello!

We have encountered a situation where the /* @refresh reload */ pragma is not respected because it's not the first comment in the file.

It's particularly tricky because our files have a copyright header which is added automatically, meaning we need /* @refresh reload */ to appear after the copyright.

In contrast, both Typescript and ESLint pragmas work fine after the copyright header. i would expect solid-refresh to be the same.

Example:

// This is a copyright header
// which is automatically injected

/* @refresh reload */

const App = (props) => {
...
}

victor-wm avatar Aug 24 '22 21:08 victor-wm

Weird that it should work given that the plugin checks for every known comment in the file. What version of solid-refresh are you using?

lxsmnsyc avatar Aug 25 '22 02:08 lxsmnsyc

I'm using 0.4.1.

Not sure if there's something in my setup that makes it work differently but I'm using Webpack and the solid preset points to generate universal.

After some investigation I noticed it doesn't work for the App.tsx but it does work if I place the pragma in another component. So right now the place I see it not working is my root component.

I will investigate it a bit more.

victor-wm avatar Aug 25 '22 06:08 victor-wm

I can confirm what @victor-wm said is still an issue. And it looks like they are onto something. If the comment is in the entry point file it doesn't work. But if you move it one file deeper then it works as expected.

CreativeTechGuy avatar Jan 30 '24 08:01 CreativeTechGuy

@CreativeTechGuy I cannot reproduce this anymore in the latest Refresh, could you provide more details on the setup you're using?

lxsmnsyc avatar Jan 31 '24 02:01 lxsmnsyc

@lxsmnsyc Here's a minimal repo reproducing the issue. With the latest versions of the dependent packages.

https://github.com/CreativeTechGuy/solid-refresh-pragma-repro

If the latest version of solid-refresh is working, then maybe the solution is that the other solid packages (like vite-plugin-solid) which depend on it be updated also. 🤷‍♂️

CreativeTechGuy avatar Jan 31 '24 07:01 CreativeTechGuy

Hi @lxsmnsyc . Were you able to take a look at the repo I linked demonstrating this issue?

CreativeTechGuy avatar Feb 08 '24 19:02 CreativeTechGuy

Hey just checking in @lxsmnsyc were you able to take a look at my reproduction?

CreativeTechGuy avatar Mar 22 '24 21:03 CreativeTechGuy

@CreativeTechGuy I've tested it and I can only conclude one summary: this behavior is undefined.

The compiled code is correct, the runtime implementation is correct, and the HMR logs are correct. However, the reason it's undefined behavior is because Vite is expected to reload when the root module invalidates, but it didn't. There's no description of how invalidate is supposed to work (in the docs) so it's pretty much undescribed. Whether or not this is intended is unknown.

lxsmnsyc avatar Mar 23 '24 04:03 lxsmnsyc

You know what, I'll just use a different output for this one.

lxsmnsyc avatar Mar 23 '24 16:03 lxsmnsyc