Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Chart' is not exported by node_modules/frappe-charts/dist/frappe-charts.min.iife.js #32

Closed
ChrisWoodsSays opened this issue Mar 27, 2021 · 4 comments

Comments

@ChrisWoodsSays
Copy link

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.

@RP421
Copy link

RP421 commented Mar 29, 2021

I am also seeing this same behavior after upgrading from 1.5.0 to 1.7.0.

@himynameisdave
Copy link
Owner

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).

@jycouet
Copy link

jycouet commented Apr 1, 2021

Thank you for the info @himynameisdave.
Unfortunatly, I can't turn browser: false on my side.

Looking forward to your PR frappe/charts#336

@himynameisdave
Copy link
Owner

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 [email protected]. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants