nuejs / nue

The UX Framework for the Web
https://nuejs.org
MIT License
6.09k stars 180 forks source link

Vim "4913" file causes hotreload to fail #130

Open Korab-Doroci opened 10 months ago

Korab-Doroci commented 10 months ago

I reinstalled Nue with the latest version of bun. Tested it out with bun create nue@latest and I chose the hot reload test preset.

Everytime I change something in the source files, my terminal returns Removed .dist/dev/4913 Everytime, no matter what file I edit or delete and it does not hot reload. To force it to reload I have to delete the dist folder and restart the nue command in the terminal.

`✓ Initialize ./.dist/dev nue.js diffdom.js page-router.js app-router.js mount.js hotreload.js error.css favicon.ico

✓ Nue 0.1.7 • Bun 1.0.18 ✓ Serving site from ./.dist/dev ✓ Building site to: ./.dist/dev

✓ Processing styles 3 media.css content.css layout.css

✓ Generating pages 1 index.md

✓ Copying static files 1 hello.jpg

Time taken: 128ms

http://localhost:8080/ ✓ Removed .dist/dev/4913 `

Extra details: Project was created in the downloads directory of the home directory. Bun was not installed with root. Issue recreated using different presets like the app skeleton and hot reload but also initializing a project myself. I'm on Debian sid. Nue v0.1.7. Bun v1.0.18. Node v18.19.0.

tipiirai commented 10 months ago

Are you using Vim by any chance? Noticed that it creates a file called 4913. Likely relates to that.

tipiirai commented 10 months ago

Trying to repeat this issue with Mac. Hotreload worked fine with a console command such as

echo '# Test 36' > test.md && touch 4913 && rm 4913
Korab-Doroci commented 10 months ago

Yes, I do use Vim. I tried changing editor and it worked perfectly, thanks for pointing it out!

tipiirai commented 10 months ago

I re-opened this issue, since Vim still fails. Need to fix that somehow.

Thanks!

Darth-Ness commented 9 months ago

It seems I'm noticing the same issue on my machine as well. But for clarification, hot reloading refers to being able to edit a file and have the site change without a reload being necessary correct?

tipiirai commented 9 months ago

@Darth-Ness Any ideas on how I could repeat this issue? I tried different echo/touch combinations and MacVim without luck.

Darth-Ness commented 9 months ago

Unfortunately no. Maybe it's just a Linux thing? But I did notice when trying to track the issue down, after editing a file with Vim, the XHR request originating from line 4 in hotreload.js wouldn't fire anymore Although on my machine it's actually line 65.

tipiirai commented 9 months ago

@Darth-Ness can you try with the latest version (0.3.1) and see if it works? I pushed a potential fix. Thanks!

Darth-Ness commented 9 months ago

Even after updating it seems your commit didn't take place, so I just edited the file myself. Even though bunx nuekit --version says I have 0.3.1 However, it seems that the problem is still here.

tipiirai commented 9 months ago

Okay. Thanks. Need to try something else.

Darth-Ness commented 9 months ago

Okay. Thanks. Need to try something else.

Do you think trying to ignore the 4913 file could work? I tired that on my local machine and then hotreload wouldn't work at all. I guess I have alot to learn about the codebase lol.

Korab-Doroci commented 9 months ago

It kind of works now. The only problem is that I have to save twice, once makes the change to 4913, and the second time the file im editing.

✓ Removed .dist/dev/style/4913
✓ Removed .dist/dev/style/global.css~
Darth-Ness commented 9 months ago

Oh oh. The problem has gotten even weirder. I tried the method above, and at first it didn't work. However, when I realized a difference was I was using Neovim, I tried using just plain VIM (with the same config). After that, the method did work.

Darth-Ness commented 9 months ago

WAIT! After running ls -a in the .dist/dev directory, I noticed that there was a file named .016 (is there a purpose for this file? It's empty.) deleting this file fixed Vim's behavior. All though Neovim isn't working still.

nobkd commented 9 months ago

Could it be, that it is a leftover from v0.1.6?

I think this code part has been changed according to the version: https://github.com/nuejs/nue/blob/994849888e42725d5649a048952eb71e15aec6d1/packages/nuekit/src/init.js#L21

Darth-Ness commented 9 months ago

The files isn't on GitHub either. Maybe, because that line does read .016 on my machine. @tipiirai do you have any idea what this file is here for?

tipiirai commented 9 months ago

That is indeed a leftover from v0.1.6. Nue adds this file to signal the version of the nue-specific files. If there is a new version all the files are replaced with newer ones. Maybe not perfect, but works.

Darth-Ness commented 9 months ago

This might actually be a larger problem than just Vim. Placing a file that is in the IGNORE array defined here in the same directory with index.md breaks hot-reloading entirely.

nobkd commented 2 months ago

Can you check if this still happens with nuekit 1.0.0-beta.1? Thank you