GOD i am such a javascript noob. Stimulus is helping, but it took me way too long to get this working π«
tho, to be fair to myself, a lot of the difficulty stemmed from sticking with Railsβ newer importmap pattern because i really really do not want to have to deal with building javascript dependencies
Did you like this post, repost it, or respond to it? Let me know by sending a webmention!
π¬ Replies (4)
@davidcelis Really curious what tripped you up because I feel like the same happened to me.
The JS Rails story may be less involved than the modern JS toolchain but it's really rough around the edges in a very not flattering pre-Rails 3 way IMO.
It kinda reeks of assumptions made by insiders who didn't really consider that all their choices are far from self-evident.
@olivierlacan mainly two things. the first thing is that 2 out of 3 times, Rails will "guess" the wrong URL when i try to use `bin/importmap pin`. it'll grab a non-distribution file, non-minimized file, a file that doesn't actually have any exports, etc. the other thing is that, when that happens, it's hard for me to correct it myself. i'll go to jsdelivr and it won't be obvious which file (or files) i need to choose out of 20-30 options to finally get things imported and working
@olivierlacan not being able to `import` the CSS files that are sometimes bundled with JS libraries was also a tiny bit painful, but mostly only because that's frequently how their documentation tells you to set up the library. at least with those, though, it's obvious that i can find the referenced file and include it in a `<link>` tag
@davidcelis Oof, that seems like such a PITA but also a vulnerability vector.
The CSS import bit seems like something that could be detected and trigger at least a heads-up notice if those files are part of a dist/ directory?