vite/playground/worker/my-worker.ts
Jay Wang 570e0f1852
fix(worker): support UTF-8 encoding in inline workers (fixes #12117) (#15866)
Signed-off-by: Jay Wang <jay@zijie.wang>
Co-authored-by: 翠 / green <green@sapphi.red>
2024-02-12 08:34:51 +01:00

34 lines
698 B
TypeScript

import { msg as msgFromDep } from '@vitejs/test-dep-to-optimize'
import { mode, msg } from './modules/workerImport.js'
import { bundleWithPlugin } from './modules/test-plugin'
import viteSvg from './vite.svg'
const metaUrl = import.meta.url
self.onmessage = (e) => {
if (e.data === 'ping') {
self.postMessage({ msg, mode, bundleWithPlugin, viteSvg, metaUrl, name })
}
if (e.data === 'ping-unicode') {
self.postMessage({
msg: '•pong•',
mode,
bundleWithPlugin,
viteSvg,
metaUrl,
name,
})
}
}
self.postMessage({
msg,
mode,
bundleWithPlugin,
msgFromDep,
viteSvg,
metaUrl,
name,
})
// for sourcemap
console.log('my-worker.js')