How can I install PixiJS with importmap?

Hello everyone,

This is the first time I use importmap in a Rails project and I am trying to install the PixiJS package. I already did something like that before but it was using yarn and it worked without any headache, just a simple yarn add. However, this time, I cannot for the life of me figure out how to properly install it and import it in a controller. I followed the rails documentation on how to pin packages with importmap but it doesn’t seem to work. Steps I did:

  • bin/importmap pin pixi.js
  • checked my importmap.rb and the vendor/javascript folder, all seems in order
  • added ‘import * as PIXI from “pixi.js”’ in my stimulus controller I get a few error messages in the console when I load the page with the stimulus controller but this is the one that seem to explain the problem best: Failed to register controller: deck (controllers/deck_controller) TypeError: Failed to fetch dynamically imported module: http://localhost:3000/assets/controllers/deck_controller-403ef6c14cadfd78dec718ad1a35e9d6ad8f5b1eef0425e2248fad4391a4ec2f.js

I don’t know if I missed a step or what… but it’s driving me crazy and I’m really close to switching to npm or yarn again… The odd thing is that I can import the helper packages from PixiJs like the math library and such.