Skip to content

Commit

Permalink
fix: ponyfill SharedWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Nov 17, 2023
1 parent ac789b2 commit d22cf6e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"types": "dist/index.d.ts",
"exports": {
"./worker": {
"types": "./dist/common/webpack/worker/web-worker.d.ts",
"default": "./dist/common/webpack/worker/web-worker.js"
"types": "./dist/common/webpack/worker/web-worker.d.mts",
"default": "./dist/common/webpack/worker/web-worker.mjs"
},
".": {
"types": "./dist/index.d.ts",
Expand All @@ -22,7 +22,7 @@
"./dist/index.d.ts"
],
"worker": [
"./dist/common/webpack/worker/web-worker.d.ts"
"./dist/common/webpack/worker/web-worker.d.mts"
]
}
},
Expand Down Expand Up @@ -68,6 +68,7 @@
"@babel/preset-react": "^7.22.0",
"@babel/preset-typescript": "^7.22.0",
"@babel/runtime": "^7.22.0",
"@okikio/sharedworker": "^1.0.4",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
"@sentry/webpack-plugin": "^2.7.1",
"@statoscope/webpack-plugin": "^5.27.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// eslint-disable-next-line camelcase
declare let __webpack_public_path__: string;

// @ts-expect-error ts does not find types in @okikio/sharedworker/@types/index.d.ts
import {SharedWorkerPolyfill} from '@okikio/sharedworker';

class WebWorker extends Worker {
constructor(url: string | URL, options?: WorkerOptions) {
const objectURL = generateWorkerLoader(url);
Expand All @@ -9,7 +12,7 @@ class WebWorker extends Worker {
}
}

class SharedWebWorker extends SharedWorker {
class SharedWebWorker extends SharedWorkerPolyfill {
constructor(url: string | URL, options?: string | WorkerOptions) {
const objectURL = generateWorkerLoader(url);
super(objectURL, options);
Expand Down

0 comments on commit d22cf6e

Please sign in to comment.