Skip to content

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

Open
@snapwich

Description

@snapwich

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions