I’ve lived through this sort of sea change twice now – first with the abandonment of Prototype.js, and now with Sprockets. In both cases, the cusp time was the very worst.
It’s impossible to overstate how confusing it is for me to try to use code that currently works (oh, let’s just name it: bootstrap.js) in a new module-preferring world where jQuery doesn’t exist as a window object. The quantity and severity of code-smells I contributed in just trying to get a modal to be reusable by multiple controllers was quite astounding. And the amount of really bad advice I encountered in the SO-verse and Blog-land made this very difficult to climb as a learning curve. Gems that I have used to inject bits of magic into the front-end and relied on for years just don’t work any more, and their README is no longer authoritative.
Eventually, this will all work itself out, as gems are updated, and Bootstrap 5 brings us a new, modular JS without a jQuery requirement. Rails is a big tent, and it casts a long shadow, and all the sideshow folks will want to come along in whichever direction the train is heading. (Sorry to mangle the metaphor.)
Right now, because I want to ship something this month, I resorted to injecting external script references to jQuery, the Bootstrap CDN, and my tiny little file of extensions to that code (written in what I like to call Ye Olde jQuerie) – all 55 lines of it, including comments and whitespace – into application.html.erb, and called it a night. This resulted in the removal of hundreds of NPM bundles (yay!) and a halving of the size of my application.js (yes, I know it all went in other files, which all load from CDNs, so I’ve just moved the junk drawer).
So much of this tooling is built around the very real needs of front-end developers who don’t have the luxury of a mature framework like Rails, who have to build each thing from scratch. It all feels like so much Astronaut Architecture when you bring it into the context of wanting to handle an Ajax update from a modal form. I use Rails because I don’t build SPAs. I don’t need a whole SPA factory full of custom tools designed around solving a problem that I don’t have.
My two pfennigs, anyway.