11ty / eleventy-plugin-vite

A plugin to use Vite with Eleventy
134 stars 10 forks source link

Updating JavaScript with Incremental Kills Dev Server #30

Closed khalidabuhakmeh closed 1 week ago

khalidabuhakmeh commented 1 year ago

I've noticed that the server dies when running the dev server with Vite and incremental, specifically when changing JavaScript files. I think it has to do with a ~ at the end of the file name, which I'm not exactly sure where it's coming from. Here's the Error.

errno = -2
code = "ENOENT"
syscall = "stat"
path = "../../public/assets/js/video.js~"
stack = "Error: ENOENT: no such file or directory, stat '../../public/assets/js/video.js~'"
message = "ENOENT: no such file or directory, stat '../../public/assets/js/video.js~'"

When the error is throw, I get the following from running 11ty in debug mode.

[11ty] Eleventy fatal watch error:
[11ty] EACCES: permission denied, scandir '/var/agentx' (via Error)
  Eleventy:EleventyErrorHandler (error stack): Error: EACCES: permission denied, scandir '/var/agentx' +0ms
  Eleventy Cleaning up chokidar and server instances, if they exist. +23ms

I am using Node v19.6.0 and NPM 9.4.0

zachleat commented 1 year ago

well, this is curious! https://github.com/vitejs/vite/pull/9509

zachleat commented 1 year ago

And just to be clear, the file name you’re using there is video.js~? Or do you have more context as to where the ~ is coming from?

khalidabuhakmeh commented 1 year ago

The file name is video.js on disk. I am assuming that since asset changes are stored and served from memory, they have a ~ added to denote any changes I've made have not yet been written to the output directory of _site.

Screenshot 2023-03-17 at 11 04 35

Update: FYI, I tried updating Vite to the latest release of 4.2.0 but still have the same issue.

zachleat commented 1 year ago

Ah hmm, my confusion here is that the only usage of ~ in Vite projects I know of is for alias prefixing, I’ve never heard of ~ being appended in that manner. This might be worth asking on the Vite repo?

I don’t think that URL transformation is coming from the Eleventy piece of the Eleventy Vite plugin, and I’m struggling to think of any util in the larger Eleventy org that would do this either.

khalidabuhakmeh commented 1 year ago

OK, I'll ask about it in the Vite project.

As a sanity check to ensure it's not a "my environment" thing, I spun up a remote development environment and ran into the same issue.

Screenshot 2023-03-17 at 11 16 35
KiwiKilian commented 2 weeks ago

Are you still experiencing this problem? Did you file anything in the vite repository? I'm also wondering if it's a problem due to beeing inside the public directory. If you still need help on this a reproduction repository would be nice.

khalidabuhakmeh commented 1 week ago

I'm not currently working on this at the moment, so I'm happy to close it to reduce the cognitive load. Thank you for your help.