mirror of
https://github.com/vitejs/vite.git
synced 2024-11-22 07:09:05 +00:00
32 lines
646 B
JavaScript
32 lines
646 B
JavaScript
import SubWorker from './emit-chunk-sub-worker?worker'
|
|
const subWorker = new SubWorker()
|
|
|
|
subWorker.onmessage = (event) => {
|
|
self.postMessage({
|
|
type: 'emit-chunk-sub-worker',
|
|
data: event.data,
|
|
})
|
|
}
|
|
|
|
const moduleWorker = new Worker(
|
|
new URL('./module-and-worker.js', import.meta.url),
|
|
{ type: 'module' },
|
|
)
|
|
|
|
moduleWorker.onmessage = (event) => {
|
|
self.postMessage({
|
|
type: 'module-and-worker:worker',
|
|
data: event.data,
|
|
})
|
|
}
|
|
|
|
import('./module-and-worker').then((res) => {
|
|
self.postMessage({
|
|
type: 'module-and-worker:module',
|
|
data: res.module,
|
|
})
|
|
})
|
|
|
|
// for sourcemap
|
|
console.log('emit-chunk-nested-worker.js')
|