chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
64.36k stars 11.89k forks source link

Chart.js does not work without transpilations as an ES / JS module due to non-relative @kurkle/color imports #11889

Open tobiu opened 2 weeks ago

tobiu commented 2 weeks ago

Expected behavior

i was looking at your lib again and i am actually very impressed that you are using relative import paths in a way that browsers can understand.

now i wanted to import your lib inside a JS module based canvas worker without transpilations to provide you with an example of having multi window charts which can directly communicate.

i made this work with changing the 3 "broken" (non relative) kurkle imports: https://github.com/neomjs/chartjs-demo/commit/0b7d7c1f3761fb5bccfa9279de847ea280634659

Screenshot 2024-08-31 at 13 32 43

while the hotfix candidate has (needs) the assumption, that the chart.js and kurkle node_modules are at the same level, it does work now. so it would be very much appreciated in case you can apply it to your code base.

Current behavior

without the fix inside the 3 spots, we get: Screenshot 2024-08-31 at 13 34 43

Reproducible sample

https://github.com/neomjs/chartjs-demo

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

current repo to create the multi-window demo with your lib: https://github.com/neomjs/chartjs-demo

based on: https://github.com/neomjs/neo

chart.js version

v4.4.4

Browser name and version

Chrome, FF, Safari

Link to your project

https://github.com/neomjs/chartjs-demo

tobiu commented 2 weeks ago

(another option would be to import the CDN version of your lib, but it would be a lot better if it would work with using the npm package directly.)