Open Nisgrak opened 3 years ago
Maybe you can set this option in vite? https://vitejs.dev/config/#optimizedeps-exclude
Or the rollup options here https://vitejs.dev/config/#build-rollupoptions
I'm trying with this, but happend the same error
optimizeDeps: {
exclude: ["stream"]
},
Any disclosure for that? I'm facing the same issue.
Can you reproduce the issue and upload it as a repo for us to look at?
I found a temporary workaround using umd instead
import { parse } from 'json2csv/dist/json2csv.umd'
Using a resolve.alias
configuration of { "json2csv": "json2csv/dist/json2csv.umd.js" }
works as well and does not break the TypeScript definitions.
The problem happens when packaging the library for frontend since it uses some Node libraries. Like the stream library.
In v6 this, will be changed to minimize the node-specific parts and we should reconsider how we expose the different APIs to clearly separate node APIs from standard JS APIs
I found a temporary workaround using umd instead
import { parse } from 'json2csv/dist/json2csv.umd'
works for me
Another solution could be to import directly the module that you want to use. Something like
import parser from 'json2csv/JSON2CSVParser'
Closing since a workaround has been given.
took long enough....
v6, which has moved to a new repo and broken down into smaller packages is in esm.
Full docs here: https://juanjodiaz.github.io/json2csv/
Still same issue with vite and json2csv@v6 (latest). But the UMD workaround still works.
Hi!
I'm using this lib in 5.0.6 version with Vite (using the ESM build) and have an error when load the Parser:
I'm not using the Streaming API, only the synchronous so don't know if it's possible to disabled.
Thanks!