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

Bundle and expose as ES module #221

Closed
komasoftware opened this issue Dec 4, 2018 · 6 comments
Closed

Bundle and expose as ES module #221

komasoftware opened this issue Dec 4, 2018 · 6 comments
Labels
feature-request New feature or request

Comments

@komasoftware
Copy link

Is your feature request related to a problem? Please describe.
I would like to use Polymer 3 with ApexCharts but Polymer 3 only works with ES Bundles. I would need Webpack bundling to get ApexCharts to work,.

Describe the solution you'd like
I would like to import this way :

import { ApexCharts } from 'apexcharts'

@komasoftware
Copy link
Author

@junedchhipa junedchhipa added the feature-request New feature or request label Dec 6, 2018
@junedchhipa
Copy link
Contributor

I have used your same code of rollup as webpack didn't have very good support for exporting as ES.
Released a pre-patch version apexcharts@2.3.1-0 which you can test before the next minor release

@gullerya
Copy link

gullerya commented May 26, 2019

Maybe I should open a new issue for this, but it is really related to the present one: I'm not able to perform a very simple native ES6 import of the library:
import ApexCharts from '<correct_url>'
Failure is: Uncaught SyntaxError: The requested module '/libs/charts/apexcharts.min.js' does not provide an export named 'default'.
Looking into your source I see that you are checking and using NodeJS syntax module.exports, while in ES6 it should be export [default] something.

Do you plan to add ES6 support?

FYI: it is not possible to do dynamic/conditional export in ES6; my own solution for such a cases was/is to publish 2 distros - one would looks like the one you already have and the second one for ES6 only - all IIF may be removed, all the functions would become top level in your module (they still be private and inaccessible for anyone else) and only export exposes the main function.

WDYT?

@junedchhipa
Copy link
Contributor

Have you tried importing from apexcharts/dist/apexcharts.esm.js ?
I have tried exporting all possible formats - https://unpkg.com/apexcharts@3.7.0/dist/

@gullerya
Copy link

Works great, thanks!
Missed it, probably worthy to add this as the loading variant in your getting started section, explicitly mentioning the 'esm'!

@gullerya
Copy link

Just last suggestion - please consider to provide minified version of the esm bundle in addition to the basic one (it is about 400+K now).
Thanks and well done!

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

No branches or pull requests

3 participants