-
Hi! I have an app that duckdb-wasm would be perfect for, I saw your blog post, and I'm failing to figure out how to use it. I've kept a detailed log of what I've done here, and if anybody would be so kind as to help me figure out how to get it installed I'd love to contribute some good getting started documentation back to the project. The app is my NBA statistics viewer; right now it loads json files into js objects and allows users to eval javascript statements against a javascript object as a poor man's query, but it would be much nicer to have a database such as duckdb-wasm. Currently, the app is just a single javascript file run directly by the browser, so I figured I'd also need to start compiling the file; I wanted to use esbuild because who in their right mind would choose to use webpack, and searching this repository seemed to suggest esbuild was usable with duckdb-wasm. I started by just adding an import to my javascript file: import * as duckdb from '@duckdb/duckdb-wasm/dist/duckdb-esm.js'; Then I npm installed it and esbuild: npm i @duckdb/duckdb-wasm esbuild And added a dist/viewer_duckdb.js: duckdb.js
./node_modules/.bin/esbuild viewer.js --bundle --outfile=dist/viewer_duckdb.js
wasm: dist/viewer_duckdb.js Unfortunately, this failed with what looked like a dependency error: ./node_modules/.bin/esbuild duckdb.js --bundle --outfile=out.js
> node_modules/@duckdb/duckdb-wasm/dist/duckdb-esm.js:1:75: error: Could not resolve "apache-arrow" (mark it as external to exclude it from the bundle)
1 │ ...mWriter as ee,Table as U}from"apache-arrow";import{AsyncByteQueue as Z}f...
╵ ~~~~~~~~~~~~~~
1 error
make: *** [out.js] Error 1 So I tried installing all the dependencies: npm i apache-arrow crypto os fs path fast-glob wasm-feature-detect stream Now the file builds! 🎉 However, when I import the resulting file into my HTML file, it throws an error:
I don't have a good guess as to what to do here, so I'm pretty stuck. Does anybody have suggestions about what I'm doing wrong? I've published the branch where I am trying to get this to build - edit 1: this build script works for compiling my script. I have a working database but I am having a heck of a time figuring out how to actually load data into or use the result objects that come back out of the database |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 12 replies
-
There is an issue with the 6.0 release of arrow that I fixed in master and I'm waiting for a release. You can try the esm version or wait for the fix to be released. Hopefully that fixes things for your app. |
Beta Was this translation helpful? Give feedback.
-
Thanks for trying it out, Bill! duckdb-wasm depends on apache-arrow 6 that has a broken default bundle at the moment. The bundle is already fixed in the arrow master. (thanks @domoritz )
instead of Let us know how this is going! |
Beta Was this translation helpful? Give feedback.
-
Btw. make sure to link your project in "Show and tell" when it is ready! |
Beta Was this translation helpful? Give feedback.
-
On a similar topic, so tagging along with a build-related problem. I think my question boils down to--do you have a recommended way to install the latest arrow version manually? Like a commit number or something? For my bundler setup (svelte-kit package, so vite for dev and rollup for production) I couldn't get it to work using "@apache-arrow/esnext-esm": "^6.0.0" ("No matching export in "browser-external:stream" for import "Duplex"") so I just built the latest version of arrow-js from apache/arrow main branch. (package.json calls it ("version": "7.0.0-SNAPSHOT")) and dumped it into my node_modules by hand. That almost works--in some cases I can run queries--but I run into various weird errors. (In dev, 64-bit ints are showing up as an array of two 32-bit ints in the arrow tables; building with svelte's adapter-static, some problems where it's calling node modules that can't exist). |
Beta Was this translation helpful? Give feedback.
There is an issue with the 6.0 release of arrow that I fixed in master and I'm waiting for a release. You can try the esm version or wait for the fix to be released. Hopefully that fixes things for your app.