add service worker - tsconfig is probably wrong
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQT/foVVmI9pK13hPWFohAcXSWbK8wUCZi6kdgAKCRBohAcXSWbK 80VoAQCClbDkKFNmXeSfX0gNyCuGI/GTqZK2VyvY51Rm8uqojgD9GNSFKEIt/s48 FaBaw1kOdtbpdydf194hMkSmA5tUqQ8= =h5zo -----END PGP SIGNATURE-----
5 files changed,
23 insertions(+),
3 deletions(-)
A
ts/serviceWorker.ts
@@ -0,0 +1,9 @@
+/// <reference lib="WebWorker" /> + +// export empty type because of tsc --isolatedModules flag +export type {}; +declare const self: ServiceWorkerGlobalScope; + +self.addEventListener('sync', (e: any) => { + console.log(e); +});
M
tsconfig.json
→
tsconfig.json
@@ -1,6 +1,8 @@
{ "compilerOptions": { - "target": "ES2022", + "target": "es5", + "lib": [ "es2022", "webworker", "dom" ], + "skipLibCheck": true, "module": "preserve", "moduleResolution": "bundler", "noImplicitAny": true,
A
webpack.config.js
@@ -0,0 +1,9 @@
+const path = require('path'); + +module.exports = { + context: path.resolve(__dirname, 'src'), + entry: { + main: './index.js', + serviceWorker: './serviceWorker.js' + } +}