Instead of hardcoding options in the miniflare instantiation call this PR makes it so that those are gathered from a wrangler config file if one is present (if one is not present a warning is shown.... I'm not sure if the warning is really something we need/want... I guess it can always easily be removed/tweaked later)
Additionally this PR registers a hotUpdate hook that restarts the vite dev server when the config file is created/updated/deleted.
[!NOTE]
In the vite-runtime-5.1-experimentations we had a more complex implementation where we didn't restart the vite dev server and in order to reflect wrangler config changes we were restarting/reinstantiating miniflare, that also required buffering and replaying requests that were received while miniflare/workerd was restarting (and unable to receive those).
I believe that restarting the vite dev server is preferable as:
if you update the vite config file the vite dev server restarts, keeping the same flow for our config makes sense to me
developers very rarely change the config file (and especially mid development), so restarting the whole dev server in such occasions doesn't seem like a problem to me
buffering/replaying requests might work well right now but it feels to me like a larger surface area for bugs to pop out (and more maintenace costs), the simpler the solution we can have the better IMO (especially if there is no a significant gain in more complex solutions)
I'm of course happy to discuss the above 🙂
(PS: this also feels like a discussion for later on as feasibility of either solution is not in question here)
Instead of hardcoding options in the
miniflare
instantiation call this PR makes it so that those are gathered from a wrangler config file if one is present (if one is not present a warning is shown.... I'm not sure if the warning is really something we need/want... I guess it can always easily be removed/tweaked later)Additionally this PR registers a
hotUpdate
hook that restarts the vite dev server when the config file is created/updated/deleted.resolves #18