flarelabs-net / vite-plugin-cloudflare

12 stars 1 forks source link

Add options to persist state #21

Closed jamesopstad closed 1 month ago

jamesopstad commented 1 month ago

Wrangler defaults to persisting state to .wrangler/state/v3 in the config directory. This can be overridden with the --persist-to CLI flag. We have a few options:

  1. Persist state to.wrangler/state/v3 by default and add a persistTo option to the plugin config to override this.
  2. Make state persistence opt-in (determined by whether the user provides the persistTo option in the plugin config).
  3. Option 1 but also accept false as a value for persistTo in order to opt out.
  4. Option 2 but also accept true as a value for persistTo in order to persist state to .wrangler/state/v3.

I'm most in favour of options 1 or 3 because they mirror the behaviour of wrangler dev. Users will still need to run Wrangler CLI commands when using the Vite plugin and the behaviour would be unexpected if they don't persist state to the same directory. It could be useful to opt out though (as in option 3), particularly for testing.

What do you think @IgorMinar @petebacondarwin @dario-piotrowicz?

petebacondarwin commented 1 month ago

Yes - option 3 works for me