-
Notifications
You must be signed in to change notification settings - Fork 372
Bundle for the web with workers, pgvector and live? #214
Copy link
Copy link
Closed
Description
Hello,
I'm trying to bundle the library for the web with webworker support and vector and live. I would live to package it into a single JS file that could be hosted on a CDN (or at least a single js that loads the wasm, data and gz).
I can't manage to find the right webpack config for it.
index.js
import { PGliteWorker } from '@electric-sql/pglite/worker'
import { live } from '@electric-sql/pglite/live'
export const createWorker = async (dataDir, meta) => {
try {
return await PGliteWorker.create(
new Worker(new URL('./pgworker.js', import.meta.url), {
type: 'module',
}),
{
extensions: {
live
},
dataDir,
meta,
},
);
} catch (error) {
console.error("Error in createWorker:", error);
throw error;
}
};pgworker.js
import { PGlite } from '@electric-sql/pglite'
import { worker } from '@electric-sql/pglite/worker'
import { live } from '@electric-sql/pglite/live'
import { vector } from '@electric-sql/pglite/vector'
worker({
async init(options) {
console.log('PGlite Worker started');
// const meta = options.meta;
return new PGlite({
dataDir: options.dataDir,
extensions: {
vector,
live
},
})
},
})```Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels