add service worker - tsconfig is probably wrong
This commit is contained in:
parent
d7600f28fc
commit
1c1346e7cd
5 changed files with 23 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/main.js
|
dist/*.js
|
||||||
src/
|
src/
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -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
9
ts/serviceWorker.ts
Normal 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);
|
||||||
|
});
|
|
@ -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
9
webpack.config.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
context: path.resolve(__dirname, 'src'),
|
||||||
|
entry: {
|
||||||
|
main: './index.js',
|
||||||
|
serviceWorker: './serviceWorker.js'
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue