kylebarron / parquet-wasm

Rust-based WebAssembly bindings to read and write Apache Parquet data
https://kylebarron.dev/parquet-wasm/
Apache License 2.0
482 stars 19 forks source link

reading wbindgen issue with webpack #486

Closed kbatchu closed 2 months ago

kbatchu commented 3 months ago

I am getting an error message "Uncaught TypeError TypeError: Cannot read properties of undefined (reading '__wbindgen_add_to_stack_pointer') at readParquet (c:\PROJECTS\DataVizSandbox\DuckDBWasm\node_modules\parquet-wasm\esm\parquet_wasm.js:300:1).

I am using webpack 5.89.0. I get this same error message with both "parquet-wasm "^0.6.0-beta.2" and '"@geoarrow/geoparquet-wasm": "^0.2.0-beta.2".

Any idea on how to fix this?

Thanks

kylebarron commented 3 months ago

esm\parquet_wasm

You should usually be using the bundler entry point with webpack.

Alternatively, if you're using the esm entry point, you need to await the default export. Your error is happening because you're not awaiting the wasm from the esm entry point.

I don't use webpack myself but there's an example template here: https://github.com/rustwasm/rust-webpack-template/blob/master/template/webpack.config.js

kylebarron commented 3 months ago

I made the existing text in the README bold: https://github.com/kylebarron/parquet-wasm/pull/487

kbatchu commented 3 months ago

I tried using - import * as Parquet from "parquet-wasm"; and Parquet.readParquet() but I am still getting the same error.

kylebarron commented 3 months ago

You're probably getting the esm import by default. In that case, you need to do

await Parquet.default();
Parquet.readParquet()
kylebarron commented 2 months ago

I think this issue is resolved, but feel free to comment again if not