Uno.Wasm.Bootstrap
Uno.Wasm.Bootstrap copied to clipboard
fix: Firefox Hot reload
closes https://github.com/unoplatform/private/issues/511
This PR fixes Hot Reload on Firefox by replacing the ES6 module import on the service-worker.js file. This functionality is not supported on Firefox yet.
@jeromelaban is there a way to use this fix locally?
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
Marking as draft, did some local test and I believe there's more to do
@ajpinedam it's testable using the staging site. It shows this:
@ajpinedam it's testable using the staging site. It shows this:
Thanks. Yes that's the error I saw while testing using a demo local script.
We will need to add a build rule so that the unoConfig.ts also creates a non-module version of the file.
importScripts() does not support modules.
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
To avoid making crazy changes that could break other things, I pushed a change to create a duplicate uno-config js using traditional JS instead of a module, removing the need to use import. This file is used solely on the service-worker.js when registering for the Service Worker.
It seems to be working. At least the Service Worker registration is happening. I will test other browsers and PWA in a moment.
##Firefox
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
Firefox was working, but Edge and Chrome stopped.
This new change separates the logic between module and classic registration using a fallback since the browser API does not provide a way to know if the module registration is available (https://github.com/w3c/ServiceWorker/issues/1582).
So we will try to register with module, edge, and chrome will pass, and if that fails, we will fall back to register with classic; this is the case for Firefox. With this only Firefox will see a little performance hit since we will try register twice.
| Firefox | Edge |
|---|---|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
/azp run
Azure Pipelines successfully started running 1 pipeline(s).
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net
