-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Description
I have been trying to figure out how I can use this package as a dependency in a library I am building. The web worker from @sqlite.org/sqlite-wasm creates a second web worker using sqlite3-opfs-async-proxy.js and this is presenting problems when I attempt to bundle my library. I have tried to use Vite, Tsup, Parcel, and Rollup to bundle my library, but I encounter similar issues in each that all stem from the way that this package is structured with that inner worker:
- When the first worker attempts to construct the inner worker in the app, it tries to fetch
sqlite3-opfs-async-proxy.js, but this 404s since it would require the app consuming the library to servesqlite3-opfs-async-proxy.jsthemselves. - So, if I try to inline the inner worker in the library bundle by converting it to a data URL (
new Worker("data:application/javascript;base64,...")), OPFS is not available because the origin in that context is the data URL that my library's worker is inlined as, not the app's origin, and obviously a data URL cannot have the required HTTP headers.
As it stands, I can use @sqlite.org/sqlite-wasm as the direct dependency of an app, but I have been struggling to use it as a dependency of a library. I would really appreciate some guidance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels