vite/playground/worker/my-inline-shared-worker.ts
Wei 79a500726f
fix(worker): using data URLs for inline shared worker (#12014)
Co-authored-by: 翠 / green <green@sapphi.red>
2023-03-18 07:29:54 +00:00

14 lines
301 B
TypeScript

let inlineSharedWorkerCount = 0
// @ts-expect-error onconnect exists in worker
self.onconnect = (event) => {
inlineSharedWorkerCount++
const port = event.ports[0]
if (inlineSharedWorkerCount >= 2) {
port.postMessage('pong')
}
}
// for sourcemap
console.log('my-inline-shared-worker.js')