diff --git a/README.md b/README.md index 1e735224..b1ec5de2 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,15 @@ The `hyperparam` package also includes a library that can be used in other appli ```js import { asyncBufferFrom, AsyncBufferFrom, parquetDataFrame } from "hyperparam"; ``` + +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: + +```js +import { defineConfig } from "vite"; +export default defineConfig({ + ... + optimizeDeps: { + exclude: ["hyperparam"], + }, +}); +``` diff --git a/src/lib/workers/parquetWorkerClient.ts b/src/lib/workers/parquetWorkerClient.ts index c2968512..f9702308 100644 --- a/src/lib/workers/parquetWorkerClient.ts +++ b/src/lib/workers/parquetWorkerClient.ts @@ -1,6 +1,3 @@ -import ParquetWorker from './parquetWorker?worker&inline' -/// ^ the worker is bundled with the main thread code (inline) which is easier for users to import -/// (no need to copy the worker file to the right place) import type { ColumnData } from 'hyparquet' import type { ClientMessage, WorkerMessage, WorkerOptions } from './types.js' @@ -16,7 +13,7 @@ const pending = new Map() function getWorker() { if (!worker) { - worker = new ParquetWorker() + worker = new Worker(new URL('./parquetWorker.js', import.meta.url), { type: 'module' }) worker.onmessage = ({ data }: { data: WorkerMessage }) => { const pendingQueryAgent = pending.get(data.queryId) if (!pendingQueryAgent) { diff --git a/vite.lib.config.ts b/vite.lib.config.ts index df487447..7ad8065c 100644 --- a/vite.lib.config.ts +++ b/vite.lib.config.ts @@ -29,4 +29,5 @@ export default defineConfig({ }, sourcemap: true, }, + base: './', })