Uno.Wasm.Bootstrap icon indicating copy to clipboard operation
Uno.Wasm.Bootstrap copied to clipboard

fix: Firefox Hot reload

Open ajpinedam opened this issue 11 months ago • 18 comments
trafficstars

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.

ajpinedam avatar Dec 04 '24 16:12 ajpinedam

@jeromelaban is there a way to use this fix locally?

ajpinedam avatar Dec 04 '24 16:12 ajpinedam

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Dec 04 '24 16:12 github-actions[bot]

Marking as draft, did some local test and I believe there's more to do

ajpinedam avatar Dec 04 '24 20:12 ajpinedam

@ajpinedam it's testable using the staging site. It shows this:

image

jeromelaban avatar Dec 04 '24 21:12 jeromelaban

@ajpinedam it's testable using the staging site. It shows this:

image

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.

ajpinedam avatar Dec 04 '24 21:12 ajpinedam

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Dec 05 '24 23:12 github-actions[bot]

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.

ajpinedam avatar Dec 06 '24 00:12 ajpinedam

It seems to be working. At least the Service Worker registration is happening. I will test other browsers and PWA in a moment.

##Firefox

image

ajpinedam avatar Dec 06 '24 00:12 ajpinedam

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Dec 06 '24 04:12 github-actions[bot]

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Dec 06 '24 05:12 github-actions[bot]

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
image image

ajpinedam avatar Dec 06 '24 05:12 ajpinedam

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Dec 15 '24 01:12 github-actions[bot]

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Dec 16 '24 13:12 github-actions[bot]

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Apr 26 '25 15:04 github-actions[bot]

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar Apr 28 '25 21:04 github-actions[bot]

/azp run

ajpinedam avatar Apr 29 '25 04:04 ajpinedam

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Apr 29 '25 04:04 azure-pipelines[bot]

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-934.eastus2.1.azurestaticapps.net

github-actions[bot] avatar May 15 '25 13:05 github-actions[bot]