Closed dkniffin closed 1 year ago
I am trying to use this library via importmap, without global imports:
import Chartkick from "chartkick"
That way, I can avoid polluting the global namespace.
When I define my import as pin "chartkick", to: "chartkick", it gives me the following error:
pin "chartkick", to: "chartkick"
Failed to autoload controller: xyz SyntaxError: The requested module 'chartkick' does not provide an export named 'default
However, if I define my import as pin "chartkick", to: "https://ga.jspm.io/npm:chartkick@5.0.1/dist/chartkick.esm.js", it works properly. I believe this is due to JSPM doing some steps to produce a file that is compatible with ES modules (specifically, it defines an export default ..., based on the wrapper already defined here: https://github.com/ankane/chartkick/blob/1da54f89a0b00d2b2870bf63a155025a427acf05/vendor/assets/javascripts/chartkick.js#L8-L12
pin "chartkick", to: "https://ga.jspm.io/npm:chartkick@5.0.1/dist/chartkick.esm.js"
export default ...
I think ideally, that precompiled version would be made available through the gem, so we can use it that way.
Hi @dkniffin, see #611.
I am trying to use this library via importmap, without global imports:
That way, I can avoid polluting the global namespace.
When I define my import as
pin "chartkick", to: "chartkick"
, it gives me the following error:However, if I define my import as
pin "chartkick", to: "https://ga.jspm.io/npm:chartkick@5.0.1/dist/chartkick.esm.js"
, it works properly. I believe this is due to JSPM doing some steps to produce a file that is compatible with ES modules (specifically, it defines anexport default ...
, based on the wrapper already defined here: https://github.com/ankane/chartkick/blob/1da54f89a0b00d2b2870bf63a155025a427acf05/vendor/assets/javascripts/chartkick.js#L8-L12I think ideally, that precompiled version would be made available through the gem, so we can use it that way.