score:0

fips' answer helped me get on the right track.

i am not using a bundler/compiler, which seems like a the avenue to pursue.

however, for anyone else that this may help:

importscripts('https://storage.googleapis.com/workbox-cdn/releases/6.5.3/workbox-sw.js');

workbox.precaching.precacheandroute(self.__wb_manifest);

fits well to those trying to solve some examples from googles documentation

or more specific to your code, all those modules are accessible as attributes on the workbox object.

importscripts('https://storage.googleapis.com/workbox-cdn/releases/6.5.3/workbox-sw.js');

self.addeventlistener('message', event => {
  if (event.data && event.data.type === 'skip_waiting') {
    self.skipwaiting();
  }
});

workbox.core.clientsclaim();

workbox.routing.registerroute(/* your params here */);

workbox.precaching.precacheandroute(/* your params here */);

// presuming op function is deprecated in current version and changed
// to 'registerroute', but may actually be 'navigationroute' check
// current documentation for more clarity.
workbox.routing.registerroute(/* your params here */); 

score:8

there is no module support in workers yet.

importscripts() could do the job for you, but it can not import modules, meaning anything with an "export" keyword inside.

https://developer.mozilla.org/en-us/docs/web/api/workerglobalscope/importscripts


Related Query

More Query from same tag