aklinker1 / vite-plugin-web-extension

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

Extension double reloads in watch mode #13

Closed aklinker1 closed 2 years ago

aklinker1 commented 2 years ago

When an extension with both HTML pages and scripts is ran in watch mode, if the scripts take more than about half a second to bundle, the extension will reload twice. First because the html pages were output (and web-ext reloads on file change by default), and second because we reload after the scripts are output:

https://github.com/aklinker1/vite-plugin-web-extension/blob/58a38b4ee6cb0d25babb9fc6daf0929c65bd271d/lib/index.ts#L497

It should only reload once after everything has finished updating.

aklinker1 commented 2 years ago

This isn't really possible to fix because web-ext reloads whenever a bundled file changes.

Couple of possible options:

  1. This isn't a problem anymore because of HMR support in v1.2.0
  2. If we can pause the actual write of the files until the library builds have finished, then they would write their output at the same time and only reload the extension once
  3. Submit a PR to web-ext that allows for disabling the file watcher so it only reloads when we tell it to

Until I see a need for this to be fixed, I'm going to leave it as "wontfix"

aklinker1 commented 1 year ago

This is fixed in V2 (#44) after re-writing the build process.