add service worker - tsconfig is probably wrong

This commit is contained in:
Iris Lightshard 2024-04-28 13:33:10 -06:00
parent d7600f28fc
commit 1c1346e7cd
Signed by: Iris Lightshard
GPG key ID: 688407174966CAF3
5 changed files with 23 additions and 3 deletions

2
.gitignore vendored
View file

@ -1,3 +1,3 @@
node_modules/ node_modules/
dist/main.js dist/*.js
src/ src/

View file

@ -5,4 +5,4 @@ if [ ! -e ./src ]; then
fi fi
npx tsc && npx tsc &&
npx webpack npx webpack --config webpack.config.js

9
ts/serviceWorker.ts Normal file
View file

@ -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);
});

View file

@ -1,6 +1,8 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2022", "target": "es5",
"lib": [ "es2022", "webworker", "dom" ],
"skipLibCheck": true,
"module": "preserve", "module": "preserve",
"moduleResolution": "bundler", "moduleResolution": "bundler",
"noImplicitAny": true, "noImplicitAny": true,

9
webpack.config.js Normal file
View file

@ -0,0 +1,9 @@
const path = require('path');
module.exports = {
context: path.resolve(__dirname, 'src'),
entry: {
main: './index.js',
serviceWorker: './serviceWorker.js'
}
}