by schneidmaster · 6y ago · 0 comments
- babel transpiles ES6/7+ JavaScript syntax to the least-common-denominator of the browsers you designate as supported by your application
- core-js provides implementations of features that are not supported in older browsers -- things like array methods that cannot simply be transpiled
- caniuse-lite is a database of supported browser features to determine what needs to be transpiled and when
This toolchain allows developers to write code with the latest language features (which usually results in simpler, more elegant code) while seamlessly supporting legacy browsers as needed. If you decide to drop support for an older browser, you can simply remove it from your browserslist instead of going through all your code to figure out which hacks you put in just for that browser. It takes a ton of cycles out of development googling "can I use feature X in browser Y".
Prior to Rails 6, asset precompilation was powered by Sprockets by default. Sprockets still bundled many analogous libraries, just hidden in ruby gems instead of node_modules. For example, if you want to use SASS then you need a library that compiles SASS to CSS -- whether it's node-sass on your list or the sassc gem.
As noted in other comments, very little of this code is actually loaded in the frontend by end users.
Thus, 100MB of JS is astoundingly huge. It's roughly the same size as all the binaries in a full install of Windows 95, with all its features and drivers.
In the spirit of https://prog21.dadgum.com/116.html perhaps we need a list of "Things an empty Rails app is smaller than".
It takes a ton of cycles out of development googling "can I use feature X in browser Y".
...or you could just avoid the trendchasing and use a minimal subset that you are sure will work everywhere, but that's a different discussion.
This doesn't make sense and isn't a relevant comparison.
And as far as languages go, JavaScript is not nearly so far removed from raw machine code as most interpreted languages.
100MB of JavaScript code is not “astoundingly huge” at all , considering the bulk of that is tooling. Compared to the tooling for many other commonly used C/C++ development environments, 100MB is pretty modest.
Storing five million lines of code is cheap, sure, no question. But don't you feel curious about how why you need that much code in the first place?
Click through each test and read through some of the descriptions. They do a lot of advanced techniques that are important for web performance.
Those optimizations are another big part of why modern Javascript build tools are so complicated. There's no other language where we care nearly as much about optimizing for code delivery. On the web, a frontend app should (hopefully) be around 100k of Javascript bytes, and it should have good caching and CDN behavior. Compared to other platforms where 10mb to 100mb binaries are considered just fine.
This was brought to my attention working on a new project. This is the first time I've done rails 6 on heroku. Heroku out of the box with this app gives me a ~360mb buildpack; this exceeds their soft limit of 300mb. Historically not been an issue for me but I guess now with webpack, I need to customize the buildpack to cleanup the node_modules after compilation.
[0]: https://devcenter.heroku.com/articles/slug-compiler#ignoring...