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: nilix
GPG Key ID: 688407174966CAF3
5 changed files with 23 additions and 3 deletions

2
.gitignore vendored
View File

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

View File

@ -5,4 +5,4 @@ if [ ! -e ./src ]; then
fi
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": {
"target": "ES2022",
"target": "es5",
"lib": [ "es2022", "webworker", "dom" ],
"skipLibCheck": true,
"module": "preserve",
"moduleResolution": "bundler",
"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'
}
}