oneduo / laravel-nova-vite-typescript-skeleton

An opinionated and very experimental skeleton for Laravel Nova custom tools based on Vite and Typescript
MIT License
8 stars 0 forks source link

Vite Dev Server #1

Open ralphschindler opened 1 year ago

ralphschindler commented 1 year ago

Hi! Thank you for this repository- I learned a lot from it. This is more of a discussion, but do you know what is entailed in making the Vite dev server (not the vite build --watch) work? That basically means Nova would have to be made to work with modules and/or the hot module server part of Vite would have to output modules that know how to _resolveComponent correctly (which I cannot figure out.

Rezrazi commented 1 year ago

Hi Ralph

Thank you for your feedback.

I actually tried tinkering with Vite to get the actual dev server to work. But unfortunately I do not have in depth knowledge about the inner workings of Vite. I have tried just running the server however the file watcher did not seem to pick up my files, so it was useless. Somehow, with everything set up the way it is in the template, the build --watch works but the vite dev isn't able to watch the files under resources and at some point I just gave up on it as I wasn't able to truly debug the web server and see the files it serves. Another setback was when I was able to load the tool.ts in the server, but I was unable to use it in Nova as it loads all scripts as regular scripts in the layout.blade.php without any modern transpilation capabilities (the stuff behind the cjs umd esm amd and other stuff which are some things I do not fully understand yet, the JS realms are still a mystery to me)

That being said, I would love for someone to pick it up, and I'd be curious to see them go and try to figure out how to get the Vite dev server to work as we'd really benefit from the HMR features in our dev workflows.

All the best, Charaf

ralphschindler commented 1 year ago

I made a repo that demonstrates this problem without Nova so that I could find someone with a deeper knowledge of Vite dev server could help, more notes here: https://github.com/ralphschindler/demo-nova-vite-issue/

Rezrazi commented 1 year ago

This a great in depth dive into this particular behavior. Perhaps opening an issue on the Vite repo can help shed some light into this ? As you already have a demo repo set up, an answer should be given more efficiently over there.