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" ) ;
2
4
3
-
4
- if ( unoConfig . environmentVariables [ "UNO_BOOTSTRAP_DEBUGGER_ENABLED" ] !== "True" ) {
5
+ if ( config . environmentVariables [ "UNO_BOOTSTRAP_DEBUGGER_ENABLED" ] !== "True" ) {
5
6
console . debug ( "[ServiceWorker] Initializing" ) ;
6
- let uno_enable_tracing = unoConfig . uno_enable_tracing ;
7
+ let uno_enable_tracing = config . uno_enable_tracing ;
7
8
8
9
self . addEventListener ( 'install' , function ( e ) {
9
10
console . debug ( '[ServiceWorker] Installing offline worker' ) ;
@@ -13,16 +14,16 @@ if (unoConfig.environmentVariables["UNO_BOOTSTRAP_DEBUGGER_ENABLED"] !== "True")
13
14
14
15
// Add files one by one to avoid failed downloads to prevent the
15
16
// 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 ++ ) {
17
18
try {
18
19
if ( uno_enable_tracing ) {
19
20
console . debug ( `[ServiceWorker] cache ${ key } ` ) ;
20
21
}
21
22
22
- await cache . add ( unoConfig . offline_files [ i ] ) ;
23
+ await cache . add ( config . offline_files [ i ] ) ;
23
24
}
24
25
catch ( e ) {
25
- console . debug ( `[ServiceWorker] Failed to fetch ${ unoConfig . offline_files [ i ] } ` ) ;
26
+ console . debug ( `[ServiceWorker] Failed to fetch ${ config . offline_files [ i ] } ` ) ;
26
27
}
27
28
}
28
29
0 commit comments