aklinker1 / vite-plugin-web-extension

Vite plugin for developing Chrome/Web Extensions
https://vite-plugin-web-extension.aklinker1.io/
MIT License
553 stars 48 forks source link

Vite build sometimes doesn't trigger when saving a file. #61

Closed gorbit99 closed 1 year ago

gorbit99 commented 1 year ago

Hey! For some reason, sometimes when I save a file that's part of the extension, it doesn't trigger a build in vite. The only workaround I've found is to then force save another file. I think this happens only for files set as "additionalInputs". For example right now I have a file that's eventually imported from a file that's in that list, and it refuses to build. But if I go one level up, it for some reason works fine. Is this known, or is there a fix for this?

This is my project: https://github.com/gorbit99/wics-extension

aklinker1 commented 1 year ago

Nice extension! I tried replicating your issue, so let me double check I understand. I only tried a couple of files for one of your additionalInputs.

That said, you're only importing a type from the types.ts file, so I assume Vite is ignoring changes from that file, since it doesn't effect the final bundle. Once esbuild strips out all the types, that import doesn't exist anymore, so Vite probably has no idea that import is even in your source code.

Is there a different set of files I can reproduce it with?

gorbit99 commented 1 year ago

I don't think it's set in stone when and where this happens. Sometimes I just notice, that saving a file doesn't trigger a rebuild, and sadly it's not type-only files that do this. It might even happen after a while, I'm not sure. Right now I can't find a single file that's doing it I don't think, so I'll get back to you once I find something.

aklinker1 commented 1 year ago

I'm gonna close this, let me know if you can reproduce this consistently. And I'll look into this.