Web worker
Fetch and parse data off the main thread with makeWorkerInstance.
Without makeWorkerInstance, data is fetched and parsed on the main thread. On
Vite 6 and 7 the worker’s chunks need worker: { format: 'es' }. Under webpack,
import @jbrowse/react-linear-genome-view2/esm/makeWorkerInstance instead of
the ?worker entry, and set output.publicPath: 'auto' so the worker finds its
own URL.
Show source · 22 linesHide source · 22 lines
import { LinearGenomeView } from '@jbrowse/react-linear-genome-view2'
import RpcWorker from '@jbrowse/react-linear-genome-view2/esm/rpcWorker?worker'
export default function WebWorker() {
return (
<LinearGenomeView
assembly={{
name: 'volvox',
uri: 'https://jbrowse.org/genomes/volvox/volvox.2bit',
}}
tracks={[
{
trackId: 'volvox_gff3',
name: 'Volvox genes',
uri: 'https://jbrowse.org/code/jb2/main/test_data/volvox/volvox.sort.gff3.gz',
},
]}
view={{ loc: 'ctgA:1105..1221', tracks: ['volvox_gff3'] }}
makeWorkerInstance={() => new RpcWorker()}
/>
)
}