I am upgrading an old project to Rails 7 with importmaps, and I am having trouble understanding how it's supposed to work now. I have some old JavaScript that relies on jQuery and jquery-ui. I've set it up to import jquery and jquery-ui, but the jQuery variable is not recognized in the jquery-ui module.
importmap.rb:
pin "application", preload: true
pin "jquery", to: "https://ga.jspm.io/npm:jquery@3.6.3/dist/jquery.js", preload: true
pin "jquery-ui", to: "https://ga.jspm.io/npm:jquery-ui@1.13.2/ui/widget.js", preload: true
application.js:
import "jquery";
import "jquery-ui";
Here is the error I get:
Uncaught ReferenceError: jQuery is not defined at widget.js? [sm]:20:11
What am I missing?