Skip to content

Commit 43cd2da

Browse files
committed
fix issue with the worker
1 parent 43a95b2 commit 43cd2da

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ The `hyperparam` package also includes a library that can be used in other appli
7373
```js
7474
import { asyncBufferFrom, AsyncBufferFrom, parquetDataFrame } from "hyperparam";
7575
```
76+
77+
If you encounter any issues with the web worker, you might have to configure your bundler. For example, in Vite, you can use the following configuration:
78+
79+
```js
80+
import { defineConfig } from "vite";
81+
export default defineConfig({
82+
...
83+
optimizeDeps: {
84+
exclude: ["hyperparam"],
85+
},
86+
});
87+
```

src/lib/workers/parquetWorkerClient.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import ParquetWorker from './parquetWorker?worker&inline'
2-
/// ^ the worker is bundled with the main thread code (inline) which is easier for users to import
3-
/// (no need to copy the worker file to the right place)
41
import type { ColumnData } from 'hyparquet'
52
import type { ClientMessage, WorkerMessage, WorkerOptions } from './types.js'
63

@@ -16,7 +13,7 @@ const pending = new Map<number, QueryAgent>()
1613

1714
function getWorker() {
1815
if (!worker) {
19-
worker = new ParquetWorker()
16+
worker = new Worker(new URL('./parquetWorker.js', import.meta.url), { type: 'module' })
2017
worker.onmessage = ({ data }: { data: WorkerMessage }) => {
2118
const pendingQueryAgent = pending.get(data.queryId)
2219
if (!pendingQueryAgent) {

vite.lib.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ export default defineConfig({
2929
},
3030
sourcemap: true,
3131
},
32+
base: './',
3233
})

0 commit comments

Comments
 (0)