6 ms·
1. Rails retired Webpacker [that] compiled and bundled JS. Import maps, Turbo and Stimulus [are now the] default options, replacing Webpacker, Turbolinks and UJ
by texxtxxet 4y ago
1. Rails retired Webpacker [that] compiled and bundled JS. Import maps, Turbo and Stimulus [are now the] default options, replacing Webpacker, Turbolinks and UJS.
How do these new tools compare with the old? Versus Webpack, Vite etc?
- marlomajor 4y agoBetter. Much, much better than webpack/vite imo.
- texxtxxet 4y agoA specific example? Genuinely asking (codebase is Typescript/ES6 modules).
- azangru 4y ago> Genuinely asking (codebase is Typescript/ES6 modules) No luck for you then. Rails doesn't seem to love typescript: https://github.com/rails/importmap-rails/issues/124 https://github.com/rails/importmap-rails/issues/124
- fishtoaster 4y agoMy impression is that there are two ways to use rails: 1. Your frontend js needs are pretty minimal and you don't want something approaching a single-page app. In this case, you lean into Turbo and Stimulus to have rails do most things for you that would previously have been done with some a heavy-weight react-based frontend. 2. Your frontend js needs are significant and you do want a single-page app. In this case, ignore/disable turbo + stimulus. Instead, build your rails app as just a json API and then have a separate project for your frontend built using a dedicated frontend build tool like vite/CRA/webpack/etc. On one hand, I feel like the turbo/stimulus stuff is the rails community preferring to pretend that the JS world doesn't exist. On the other hand, maybe it's really just the rails world embracing the above dichotomy: they're tools for doing some light frontend work with no JS, and an acceptance of the fact that if you want an SPA, there are better non-rails tools that you'll wind up using anyway.
- darkandbrooding 4y agoMy employer fits your first criteria precisely. Turbo and Stimulus provide exactly as much interactivity as we need. The appearance is that we're trying to avoid Javascript. The reality is that we are (successfully) minimizing context switching when working on the code base.
- jai_ 4y agoI think your point (1) doesn't really match with what the rails devs expect. 37Signals have both their Basecamp and Hey.com products which act very much like a single page app but only using Turbo and Stimulus. I think the rails devs believe that single page apps are overused and the majority of functionality can be done using just the provided tools.
- fishtoaster 4y agoYeah, the ruby community has a bit of an axe to grind with SPAs. Opinions range from the defensible ("JS is a bit overused, sometimes pure serverside rendering like Rails does is all you need") to the imo-ridiculous ("Pretty much no one needs an SPA and the whole frontend JS world is a passing fad").
- petepete 4y agoWe went with esbuild and regardless of speed (it's way faster) the main reason I like it is because the config is tiny and I actually understand what it's doing. Our Webpacker config was big and fragile by comparison.