File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -37,9 +37,17 @@ export function registerSW(options: RegisterSWOptions = {}) {
37
37
38
38
async function register ( ) {
39
39
if ( 'serviceWorker' in navigator ) {
40
- const { Workbox } = await import ( 'workbox-window' )
41
- // __SW__, __SCOPE__ and __TYPE__ will be replaced by virtual module
42
- wb = new Workbox ( '__SW__' , { scope : '__SCOPE__' , type : '__TYPE__' } )
40
+ wb = await import ( 'workbox-window' ) . then ( ( { Workbox } ) => {
41
+ // __SW__, __SCOPE__ and __TYPE__ will be replaced by virtual module
42
+ return new Workbox ( '__SW__' , { scope : '__SCOPE__' , type : '__TYPE__' } )
43
+ } ) . catch ( ( e ) => {
44
+ onRegisterError ?.( e )
45
+ return undefined
46
+ } )
47
+
48
+ if ( ! wb )
49
+ return
50
+
43
51
sendSkipWaitingMessage = async ( ) => {
44
52
// Send a message to the waiting service worker,
45
53
// instructing it to activate.
You can’t perform that action at this time.
0 commit comments