diff --git a/src/components/frame/XImgWorker.ts b/src/components/frame/XImgWorker.ts index ed2db2d8..6b5d3f33 100644 --- a/src/components/frame/XImgWorker.ts +++ b/src/components/frame/XImgWorker.ts @@ -1,6 +1,8 @@ import { CacheExpiration } from 'workbox-expiration'; import { workerExport } from '../../worker'; +declare var self: ServiceWorkerGlobalScope; + interface BlobCallback { resolve: (blob: Blob) => void; reject: (err: Error) => void; diff --git a/src/service-worker.js b/src/service-worker.ts similarity index 97% rename from src/service-worker.js rename to src/service-worker.ts index f3bcfad5..bfafb885 100644 --- a/src/service-worker.js +++ b/src/service-worker.ts @@ -3,6 +3,8 @@ import { NetworkFirst, CacheFirst } from 'workbox-strategies'; import { registerRoute } from 'workbox-routing'; import { ExpirationPlugin } from 'workbox-expiration'; +declare var self: ServiceWorkerGlobalScope; + precacheAndRoute(self.__WB_MANIFEST); cleanupOutdatedCaches(); diff --git a/tsconfig.json b/tsconfig.json index ea8055d2..5fd8843c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "lib": [ "dom", + "WebWorker", "es2017" ], "target": "ES2017", diff --git a/webpack.config.ts b/webpack.config.ts index 0462c561..42c91fc2 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -109,7 +109,7 @@ module.exports = { // Bundle service worker new WorkboxPlugin.InjectManifest({ - swSrc: path.resolve(path.join('src', 'service-worker.js')), + swSrc: path.resolve(path.join('src', 'service-worker.ts')), swDest: 'memories-service-worker.js', maximumFileSizeToCacheInBytes: (isDev ? 10 : 4) * 1024 * 1024, }),