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

Default export of apexcharts.esm.js is SVG.js, not ApexCharts #1760

Open
snapwich opened this issue Jul 10, 2020 · 5 comments
Open

Default export of apexcharts.esm.js is SVG.js, not ApexCharts #1760

snapwich opened this issue Jul 10, 2020 · 5 comments
Labels
bug Something isn't working high-priority

Comments

@snapwich
Copy link

Bug report

Codepen

I think most of the examples that use webpack are broken, but I was looking specifically at this one: https://codesandbox.io/s/o7339qql3z

Explanation

This results in TypeError: this.chart.render is not a function

If you debug vue-apexcharts you'll see it breaks on this code

        var config = this.extend(this.options, newOptions);
        this.chart = new ApexCharts(this.$el, config);
        return this.chart.render();

and if you step into ApexCharts you'll see you end up in the SVG constructor function here: https://github.com/apexcharts/apexcharts.js/blob/master/src/svgjs/svg.js#L24
rather than in the ApexCharts class constructor.

If I had to guess I'd say the UMD wrapper around SVGJS is confusing the module output from rollup and switching the default export. I think the latest versions of webpack uses the package.json#module field to determine the bundle, so I think this bug breaks builds using apexcharts inside a webpack build (I used parcel to test, which is also broken) while projects that use the other bundles seem unaffected.

I think this is related to the same issue here:
apexcharts/vue-apexcharts#64

@junedchhipa junedchhipa added bug Something isn't working high-priority labels Jul 10, 2020
@junedchhipa
Copy link
Contributor

That's very interesting. I was wondering why all of the code-sandboxes stopped working without any reason recently.
I am not very good with bundlers, so if anyone has ideas about how to solve it, please suggest.

@kinekt4
Copy link

kinekt4 commented Apr 12, 2021

@junedchhipa Can you clarify your previous comment. Are you saying that ApexCharts doesn't support bundlers such as webpack atm? Because that seems to be my understanding based on this issue and another issue I've raised: #2315

@TotallyInformation
Copy link

I think this may be also related to the reason you cannot use the esm module directly in a modern browser.

image

It is the 21st Century, could we please have a nice chart library that can be used with an ECMA module without having to run a build process? That would be fantastic!

@pmario
Copy link

pmario commented Aug 3, 2023

Hi foks. Nice project. I'm just curious. Is this still a problem, or just forgotten to be closed?

@rtpHarry
Copy link

rtpHarry commented Apr 9, 2024

I'm not totally clued up here, but looking at the source code for the latest version of the library, i'm not seeing the module code at the start:

https://cdnjs.cloudflare.com/ajax/libs/svg.js/3.2.0/svg.js

vs the one that's included in this repo:

https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.js

However, there are breaking changes between v2 and v3 which are documented in the changelog:

https://github.com/svgdotjs/svg.js/blob/master/CHANGELOG.md

So it would take a bit of work to update it in this project, and then test reverting the change that disabled the ESM module to fix apexcharts/ng-apexcharts#92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high-priority
Projects
None yet
Development

No branches or pull requests

6 participants