kylebarron / parquet-wasm

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

Cannot import parquet-wasm/bundler #529

Open stefanonardo opened 2 months ago

stefanonardo commented 2 months ago

hello, I'm trying to use the bundler build with CRACO/Webpack. This is my webpack config (inside the CRACO one):

    plugins: {
      add: [new WasmPackPlugin({ crateDirectory: __dirname })],
    },

I get this error from Webpack:

Rust compilation.
ERROR in Rust compilation.

webpack compiled with 1 error

There is no other output about it, but I guess it refers to this error that appears during the compilation:

Error: crate directory is missing a `Cargo.toml` file; is `.` the wrong directory?

Also, import { ParquetFile } from 'parquet-wasm/bundler'; causes Cannot find module 'parquet-wasm/bundler' or its corresponding type declarations.. Instead, if I use the parquet-wasm entrypoint the Typescript server allows me to see the correct types of the library.

kylebarron commented 2 months ago

There is no other output about it, but I guess it refers to this error that appears during the compilation:

That's weird... why is it trying to compile the Rust code from source?

I haven't used craco or webpack myself, so I don't know the configuration to get it to work with them. I usually use the node or esm entry points myself.

Also, import { ParquetFile } from 'parquet-wasm/bundler'; causes Cannot find module 'parquet-wasm/bundler' or its corresponding type declarations.. Instead, if I use the parquet-wasm entrypoint the Typescript server allows me to see the correct types of the library.

Hmm. Perhaps this is an error in how the conditional entry points are defined? I don't know what's wrong with this export though: https://github.com/kylebarron/parquet-wasm/blob/4b7e7e9e076f4f2821de0cc960afe4ed055308ec/templates/package.json#L25-L28