Skip to content

Commit a909bb2

Browse files
committed
include the worker in the library (inline, instead of separate chunk)
otherwise, it'ss hard for the library clients to get the worker loaded. In vite, it requires to set `optimizeDeps.exclude=["hyperparam"]` in vite.config.ts to get it working in dev mode. And in nextJS, I don't know how to make it work.
1 parent 970ab02 commit a909bb2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/workers/parquetWorkerClient.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { ColumnData } from 'hyparquet'
2+
import ParquetWorker from './parquetWorker?worker&inline'
23
import type { ClientMessage, ParquetQueryWorkerOptions, ParquetReadObjectsWorkerOptions, ParquetReadWorkerOptions, Rows, WorkerMessage } from './types.js'
4+
/// ^ the worker is bundled with the main thread code (inline) which is easier for users to import
5+
/// (no need to copy the worker file to the right place)
36

47
let worker: Worker | undefined
58
let nextQueryId = 0
@@ -17,7 +20,7 @@ const pendingAgents = new Map<number, Agent>()
1720

1821
function getWorker() {
1922
if (!worker) {
20-
worker = new Worker(new URL('./parquetWorker.js', import.meta.url), { type: 'module' })
23+
worker = new ParquetWorker()
2124
worker.onmessage = ({ data }: { data: WorkerMessage }) => {
2225
const pendingAgent = pendingAgents.get(data.queryId)
2326
if (!pendingAgent) {

0 commit comments

Comments
 (0)