ankane / chartkick

Create beautiful JavaScript charts with one line of Ruby
https://chartkick.com
MIT License
6.33k stars 565 forks source link

importmap and 6.1.4.1 #579

Closed coder2000 closed 2 years ago

coder2000 commented 2 years ago

I am using Rails 6.1.4.1 for this app still and get an AssetNotPrecompiled error for each of the JS files in the gem. I have been able to get it working though by using a CDN import and doing the following:

import Chartkick from "chartkick";
import { Chart, registerables } from "chart.js"

Chart.register(...registerables);
Chartkick.use(Chart)
ankane commented 2 years ago

Hey @coder2000, can you try forking and moving the if defined?(Importmap) inside the initializer block to see if that fixes it?

https://github.com/ankane/chartkick/blob/a953fde8948a600fc8574e32f34863bc2153ce26/lib/chartkick/engine.rb#L6-L10

coder2000 commented 2 years ago

Yeah, removing if defined?(Importmap) works.