frappe / charts

Simple, responsive, modern SVG Charts with zero dependencies
https://frappe.io/charts
MIT License
14.94k stars 718 forks source link

feat: use UMD instead of IIFE for browser target #336

Closed himynameisdave closed 3 years ago

himynameisdave commented 3 years ago
Explanation About What Code Achieves:

This is an attempt to fix https://github.com/frappe/charts/issues/199 (as well as downstream issues in my svelte-frappe-charts wrapper library).

I tried to explain why this is happening here. Allow me to summarize:

Users can probably get around this issue in their bundler with some Regex gymastics / explicitly telling frappe-charts to resolve to not the browser version. Or they can do what the README says and manually specify the path to the .esm.js.

The user shouldn't have to do either of these. Also, how are libraries which consume frappe-charts meant to import it? (we believe they should be agnostic and let the bundler decide).

This PR tells Rollup to produce a UMD-style bundle, and sets that as the browser entry point.

📄 You can read more about IIFE vs UMD here.

Screenshots/GIFs:
Steps To Test:
TODOs:
scmmishra commented 3 years ago

Thanks a lot @himynameisdave I really appreciate your help on this. I'll test this PR over the weekend and release it if all works fine

scmmishra commented 3 years ago

This looks great! I've merged this and made a release. Thanks a lot for your contribution!

GrosSacASac commented 3 years ago

Nice

barredterra commented 3 years ago

@himynameisdave this is one of the best PR descriptions i've ever seen. Thanks for making the effort and let's hope others will take it as an example.