diff --git a/.gitignore b/.gitignore index f0db5c7..f75a141 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules/ -dist/main.js +dist/*.js src/ diff --git a/build.sh b/build.sh index 7b4555e..5b3c346 100755 --- a/build.sh +++ b/build.sh @@ -5,4 +5,4 @@ if [ ! -e ./src ]; then fi npx tsc && -npx webpack +npx webpack --config webpack.config.js diff --git a/ts/serviceWorker.ts b/ts/serviceWorker.ts new file mode 100644 index 0000000..208bb94 --- /dev/null +++ b/ts/serviceWorker.ts @@ -0,0 +1,9 @@ +/// + +// export empty type because of tsc --isolatedModules flag +export type {}; +declare const self: ServiceWorkerGlobalScope; + +self.addEventListener('sync', (e: any) => { + console.log(e); +}); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 3b2a1b6..1e49f55 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { - "target": "ES2022", + "target": "es5", + "lib": [ "es2022", "webworker", "dom" ], + "skipLibCheck": true, "module": "preserve", "moduleResolution": "bundler", "noImplicitAny": true, diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..0e13b0f --- /dev/null +++ b/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' + } +} \ No newline at end of file