JBrowse 2 · Circular Genome View examples

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-circular-genome-view2/esm/makeWorkerInstance instead of the ?worker entry, and set output.publicPath: 'auto' so the worker finds its own URL.

Show source · 26 linesHide source · 26 lines
import { CircularGenomeView } from '@jbrowse/react-circular-genome-view2'
import RpcWorker from '@jbrowse/react-circular-genome-view2/esm/rpcWorker?worker'

const assembly = {
  name: 'volvox',
  uri: 'https://jbrowse.org/genomes/volvox/volvox.2bit',
}

const tracks = [
  {
    trackId: 'volvox_sv',
    name: 'Volvox duplications',
    uri: 'https://jbrowse.org/code/jb2/main/test_data/volvox/volvox.dup.vcf.gz',
  },
]

export default function WebWorker() {
  return (
    <CircularGenomeView
      assembly={assembly}
      tracks={tracks}
      view={{ tracks: ['volvox_sv'] }}
      makeWorkerInstance={() => new RpcWorker()}
    />
  )
}