danvk / dygraphs

Interactive visualizations of time series using JavaScript and the HTML canvas tag
http://dygraphs.com
Other
3.17k stars 604 forks source link

Bundling with Webpack fails #847

Open JimiC opened 7 years ago

JimiC commented 7 years ago

I'm using dygraphs on an Angular 2 project via angular-cli. When I try to bundle the project for production (it uses webpack), the bundling fails cause it tries to bundle the es6 version.

I found out that if I change in the package.json the module property to index.es5 everything is fine. I would have submitted a PR with this change but I'm not sure if this will break things for others.

Please advise.

mathisloge commented 7 years ago

+1 same here. After switching module to index.es5 it works

stefan-leye commented 7 years ago

+1 Anything new on this issue?

mleprince commented 7 years ago

:+1: I've set the "module" property in package.json to "index.es5" and it doesn't work. @JimiC : Can you show me you package.json please ?

JimiC commented 7 years ago

@mleprince You need to set this project's package.json module property to index.es5.

opavader commented 7 years ago

In my case webpack is failing on Uglify step as UglifyJS doesn't support es6 syntax. Should be similar reasons for others.

danvk commented 7 years ago

Take a look at the dygraphs-es6 repo. It includes examples of bundling dygraphs with webpack and rollup.

JimiC commented 7 years ago

@danvk Excuse but the topic here isn't the use with webpack directly but the issue we have when using it with Angular which uses webpack (note here that Angular doesn't provide the ability to configure webpack). I would really appreciate if you take the time and examine my proposal.

danvk commented 7 years ago

If you can make that change without breaking the dygraphs-es6 repo, I'd be happy to consider it.

When I was setting up the dygraphs package.json (#815) I used modules like d3-scale as a template. Its module property points at a file which uses ES6 imports. If it works with Angular, I'd be curious to know what the difference between the two is.

JimiC commented 7 years ago

@danvk I know now more about the module property than I wanted. As I suspected changing that property's value is not a viable solution. I'll investigate this further.

JimiC commented 7 years ago

This issue is related to https://github.com/mishoo/UglifyJS2/issues/448

opavader commented 7 years ago

@JimiC I agree. A workaround if anyone wants to use the es6 version.