rails-templates
rails-templates copied to clipboard
Remove Node as dependency
Why
The new rails way removes any dependency from NodeJS
Steps
- Use dart-sass for SCSS and configure Bootstrap SCSS.
- #523
- Setup JS dependencies using CDN and import maps
- #524
- Configure code lint without Node.js (ESLint and Stylelint)
- #525
- Configure autoprefixer without Node or check for any alternative.
- #526
Who Benefits?
Anyone using our template as we won't have to deal with the rabbit hole of dependencies and tools
I have some concerns about the Node linter tools that we use in the development environment like
These tools help to keep the CSS and JS files consistent in code format and rule; without Node, we won't have that, so it's the trade-off here.
Another issue is, as we will rely on the CDN (Rails default uses https://jspm.org/) for the third-party package, for example, Bootstrap, it's rare, but the CDN could be down, and for that, our app won't work as expected. That is another trade-off as well.
➡️ This could be solved by downloading the ESM module and keeping it in our `public/` folder.
While there are indeed some big concerns to tackle, it could be interesting to create an Engineering Showcase about it. This way we can better experiment with the ways to handle that.
Looking at the Signup page of hey.com
(which applies the "No Build" approach), all the JS/CSS files are not built, yet loaded from the assets
folder (no CDN).
As for code lint, 80% of the conventions can be applied with Prettier (even if this is NOT a linter!). It is a big topic, but worth exploring too 👍
I'll see this after noon if there are people interested in exploring this topic a bit more :)
There are two topics:
- No build tool, such as WebPack or Esbuild. That removes the need to have Node.JS to deploy an application, i.e., Node.JS does not need to installed in Docker images or CD servers. With Rails 7 (namely with rails/importmap-rails), it is achievable. Likely, the Web is moving in that direction too, as a whole.
- Not having Node.JS for development: It would remove lots of tooling (including Prettier) that improves DX for Web development. That friction point is minimal at Nimble thanks to the laptop script standardizing the dev environment. It could be further improved by using containerized dev environments (https://containers.dev/).
I would split 1. and 2. as they have very different scope and goals.
FYI I'm drafting an Engineering Initiative so we can work on each dependency with good follow up. This will be done on an internal project first (for fast feedback) and step by step be included in the Rails Template.