fix: Unregister preact-cli's service worker if active #802
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #800
It's come up a few times now in our tracker as well as the Slack that Preact-CLI's debug service worker will cause issues if still active when using WMR. As there's going to be a fair bit of overlap between Preact-CLI and WMR's users, I think this is a common enough situation to justify handling. Even for those that recognize this issue and know how to handle it, this should save opening the dev tools and unregistering manually.
Hopefully this approach isn't too naive, though I'm not sure if there's any better way to target it.
Preact-CLI also uses
sw.js
andsw-esm.js
, though no one has brought up issues with them yet as far as I'm aware (they'd only attach when running the prod-like server with CLI's built output) so I'm thinking they're safe to ignore for now.