Closed ChrisWoodsSays closed 3 years ago
I am also seeing this same behavior after upgrading from 1.5.0 to 1.7.0.
TLDR; This issue can be resolved with your bundler (by explicitly not setting the browser
version of frappe-charts
). I'm unsure about how to do this in every bundler, but in rollup this involves setting browser: false
in @rollup/plugin-node-resolve
.
The real issue here is because of how the core frappe-charts
library is doing its iife bundle. It never exports a Chart
constructor, meaning your bundler can't even convert it to ESM/CJS and import it properly.
I am sorry that you are running into this issue. I am open to suggestions about ways we can mitigate this in this library, but this really needs to be dealt with upstream. We are still waiting on this issue, so please go comment over there that this needs to be fixed (or suggest a better way we can handle this here).
Thank you for the info @himynameisdave.
Unfortunatly, I can't turn browser: false
on my side.
Looking forward to your PR https://github.com/frappe/charts/pull/336
Yeah sorry that you're running into this @jycouet. 😢 I'm hoping that fix gets approved + merged upstream so that we can cut a release here soon. In the meantime, you might want to try svelte-frappe-charts@1.6.0
. It's functionally equivalent to 1.7.0
(current as of writing), but imports the cjs
import which should work for you. Again, sorry for the headaches.
Another idea (I personally haven't tested this), but I believe there is a way in the @rollup/plugin-node-resolve
to specify how to resolve specific packages, meaning you could set browser: true
for everything, and then specify browser: false
specifically for svelte-frappe-charts
. Again, not sure this is worth it, but it might take awhile for it to be merged upstream so might be worth looking into.
Again, sorry for the headaches.
Hi there,
I've just added frappe-charts to my previously working Svelte project and its throwing the message below. Is there something I need to do?
'Chart' is not exported by node_modules/frappe-charts/dist/frappe-charts.min.iife.js, imported by node_modules/svelte-frappe-charts/src/components/base.svelte
Many thanks, Chris.