Repository navigation
Conversation
Bundlers using unwasm (such as Nitro 3) resolve the `unwasm` condition to a new entry that imports pglite.wasm and initdb.wasm via `?module`, and the FS bundle as pglite.data.wasm (pglite.data wrapped in a Wasm custom section), so they are included in the bundle instead of loaded from files at runtime. Resolves electric-sql#1120
|
@tdrz kindly please LMK if you might be worried about size. we can support special handling for .wasm.gz for example in unwasm. |
Contributor
|
Two alternatives to try out:
See our docs: https://pglite.dev/docs/bundler-support#esbuild
Artifact created here: #1131 |
Contributor
|
Closing as this is not the right solution for us. There are workarounds for custom bundlers that are documented here, we could add another section for Nitro/Nuxt. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1120
This PR adds an
unwasmexport condition so PGlite works out of the box with Nitro.Today, a Nitro build bundles PGlite but not its runtime files, so the first query fails:
How it works
unwasmcondition resolves to a newdist/unwasm.jsentry. It importspglite.wasmandinitdb.wasmas Wasm modules (?module), so the bundler includes them in its output.pglite.dataisn't a Wasm file, so at build time we also write it topglite.data.wasm, a Wasm module with no code that holds the data in a custom section. The entry reads it back withWebAssembly.Module.customSections().Testing
unwasmexport condition) #1120 (Nitro 3, Node preset): fails onmain, returns[{"one":1}]with this branch.cloudflare-modulepreset: all three.wasmfiles are written to the output and loaded as native Wasm imports.unwasmandexportConditions: ['unwasm']: the bundle runs from a separate directory.tests/unwasm.test.tschecks the data round-trip and runs a query through the new entry.🤖 Generated with AI assistant