Skip to content

Commit 6c5d2ed

Browse files
committed
fix: Firefox Hot reload
1 parent 0c4191f commit 6c5d2ed

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Uno.Wasm.Bootstrap/Embedded/service-worker.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { config as unoConfig } from "$(REMOTE_WEBAPP_PATH)$(REMOTE_BASE_PATH)/uno-config.js";
1+
// As of Dec 2024, Firefox does not support ES6 modules in service workers, so we need to use importScripts
2+
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker#browser_compatibility
3+
importScripts("$(REMOTE_WEBAPP_PATH)$(REMOTE_BASE_PATH)/uno-config.js");
24

3-
4-
if (unoConfig.environmentVariables["UNO_BOOTSTRAP_DEBUGGER_ENABLED"] !== "True") {
5+
if (config.environmentVariables["UNO_BOOTSTRAP_DEBUGGER_ENABLED"] !== "True") {
56
console.debug("[ServiceWorker] Initializing");
6-
let uno_enable_tracing = unoConfig.uno_enable_tracing;
7+
let uno_enable_tracing = config.uno_enable_tracing;
78

89
self.addEventListener('install', function (e) {
910
console.debug('[ServiceWorker] Installing offline worker');
@@ -13,16 +14,16 @@ if (unoConfig.environmentVariables["UNO_BOOTSTRAP_DEBUGGER_ENABLED"] !== "True")
1314

1415
// Add files one by one to avoid failed downloads to prevent the
1516
// worker to fail installing.
16-
for (var i = 0; i < unoConfig.offline_files.length; i++) {
17+
for (var i = 0; i < config.offline_files.length; i++) {
1718
try {
1819
if (uno_enable_tracing) {
1920
console.debug(`[ServiceWorker] cache ${key}`);
2021
}
2122

22-
await cache.add(unoConfig.offline_files[i]);
23+
await cache.add(config.offline_files[i]);
2324
}
2425
catch (e) {
25-
console.debug(`[ServiceWorker] Failed to fetch ${unoConfig.offline_files[i]}`);
26+
console.debug(`[ServiceWorker] Failed to fetch ${config.offline_files[i]}`);
2627
}
2728
}
2829

0 commit comments

Comments
 (0)