-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document bundling with esbuild #478
Comments
Hi @skyqrose, thank you for the issue report!
Do you know of an approach that esbuild supports but doesn't break other bundlers? |
unfortunately no, I don't know much about how bundlers work, so can't be helpful in finding a solution there. |
Thank you @skyqrose for sharing and workaround. You've saved my day. For anyone needing a workaround without a self-hosted web service, public CDNs like jsDeliver or unpkg can be used. For example: const cdn = 'https://cdn.jsdelivr.net/npm/@electric-sql/pglite@0.2.15';
const [wasmModule, fsBundle] = await Promise.all([
WebAssembly.compileStreaming(fetch(`${cdn}/dist/postgres.wasm`)),
fetch(`${cdn}/dist/postgres.data`).then((response) => response.blob()),
]);
const db = await PGlite.create({
wasmModule,
fsBundle,
}); |
Unfortunately it seems that esbuild doesn't follow the pattern that other bundlers have settled on interpreting I looks like there are a few options linked above. We should add docs to the bundlers page showing how to enable this |
the problem
I'm setting up PGLite on a project that uses esbuild to bundle. I tried to start it like this:
But I get this error about
new URL("./postgres.wasm")
at this line in startWasmDownload:And two of these errors about
new URL("./postgres.data")
at this line in getFsBundle:My esbuild process is dead simple, just
esbuild src/index.tsx --bundle --outfile=build/index.js
.I'm using pglite version 0.2.15
what to do
I think this is either a bug or missing feature in esbuild, not this project.
But I'm posting this issue here because:
workaround
My workaround was to pass in the files manually
I also had to copy those two files from
node_modules/@electric-sql/pglite/dist/
to my build directory so my webserver would serve them.Alternatively, there are also workarounds and plugins based around helping esbuild handle this case, but I haven't tried them.
The text was updated successfully, but these errors were encountered: