I've always been skeptical of the JS community's mania for Babel plugins and compile-to-JS languages, and honestly, working with the Mastodon codebase and trying to shrink a 2.6MB JS bundle, I feel like my worst fears have been realized.

I've decomposed all of Mastodon's Babel presets into these plugins. If I remove a single one, I get some inscrutable error apparently caused by some other plugin in the pipeline. Feels like a big Jenga tower. 😞 #MastodonPerf

In my ideal world, we'd have two bundles:

1. ES6 without polyfills (for modern browsers)
2. ES5 fallback (using a "cut the mustard" test like fetch+Object.assign+etc.)

At this point I can't even figure out what the savings would be for #1 vs #2 because I can't get the codebase to compile *without* the Babel transforms. I wanted to try Rollup and/or Bublé too but those just feel off the table given all the JSX/spread/rest/decorators fanciness. Feeling like a JS curmudgeon here. #MastodonPerf

Like, in 99.9% of my JS projects I use vanilla ES5 and *maybe* ES6 modules, but only because then I can use Rollup to compile down to the smallest possible JS, which I then ship to consumers.

Performance is a top priority for me, and I just don't feel like syntactic sugar like arrow functions, template strings, const/let, etc. are so important that it's worth shipping a bunch of polyfills and transpiler bloat to my consumers. But I feel like I'm in the tiny minority on this one. #MastodonPerf

Anyway enough complaining. The goal here is to help make things better and not just tell these kids to get off my damned lawn. Back to reading about how Babel plugin order works and how to debug which plugin needs which other plugin. 😅 #MastodonPerf
OK, I take back what I said. I am a moron. The source of the error was Uglify, which of course doesn't support ES6. 🤦 I'm back on track, working on my "slimmer JS bundle for modern browsers" PR. #MastodonPerf
Actually I take back my take-back. Trying to string together Rollup and Browserify and Babel with about 20 different plugins to handle JSX correctly and I'm starting to get a taste of why backend folks smack-talk modern JS practices so much. Some of these things are configured in 3 different places and it's hard to tell which config is actually winning. I get an error message and it's impossible to tell which plugin/transform/package caused it. We've ruined JavaScript, folks. #MastodonPerf
So unfortunately I haven't managed to trim a single byte from the Mastodon JS bundle yet, but on the bright side I am drinking again, so there's that. #MastodonPerf
All right, I wanted to accomplish at least one thing this weekend, so here's a PR to simplify the Babel configuration to make it less confusing: https://github.com/tootsuite/mastodon/pull/2377 #MastodonPerf
Seriously though I am just trying to configure Rollup to do ES6 module-inlining on the codebase and this error has a cutesy little emoji, but I have no idea what's causing it or how to fix it. I literally can't even tell if it's rollup, rollup-plugin-babel, babel, or some babel plugin that is causing the error. I just want Rollup/Babel/whatever to ignore jQuery since it's defined globally anyway. #MastodonPerf
@nolan Possibly ridiculous idea that I'm just throwing out there: Would it be worth looking into whether TypeScript could replace Babel in this case? In theory it supports almost all ES6 syntax as well as annotations/decorators, and can be run of JS files without porting them to full TypeScript.
@dpogue I feel hesitant to add yet another abstraction… :/ Also despite working at MSFT, I actually haven't used TypeScript yet. 😅