ankane/chartkick

importmap and 6.1.4.1

coder2000 opened this issue · 2 comments

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)

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

if defined?(Importmap)
initializer "chartkick.importmap", after: "importmap" do |app|
app.config.assets.precompile << "chartkick.js"
app.config.assets.precompile << "Chart.bundle.js"
end

Yeah, removing if defined?(Importmap) works.