Babel 7 Released
babeljs.io
babeljs.io
We're looking into using 6to5 [what Babel was called at the time] for a project at Facebook -- and although we make the library -- the project is stuck for some time on React v0.11 which used a different transform.
https://github.com/babel/babel/pull/410
Was so impressed by the turnaround time on that PR and the overall quality of the project that I contacted @sebmck to see if we can recruit him to work with us. He was interested and so I referred him to a recruiter. A day later she comes back to me: "did you know this is a 17-year-old kid in the middle-of-nowhere in Australia?" (I didn't). We had to wait until he was 18 before we made him an offer and he joined our team :)
(eventually we got all of Facebook.com to run on Babel and not just React Native https://twitter.com/amasad/status/631251607422787584)
Like Henry mentions: working on 6.0 was hard and really controversial -- our vision for Babel was to serve as compiler infrastructure for JavaScript (which we've achieved to some extent since so many tools build on top of it and most users use it as part of a bigger toolchain like webpack) but many of our users disagreed with the direction and we were at the receiving end of much vitriol from the community (including here on HN). We're now vindicated (many times over) but goes to show how OSS maintainership can not only be a thankless job, but quite a stressful one too.
Thank you Henry and the rest of the team for you dedication.
Out of curiosity, why was that?
He's a smart, nice person who plays a large part in software that many of us use on a daily basis. Support open source if you can :)
But...
While Babel-core isn't overwhelming, the full set of transitive dependencies you get in normal use (with "env") is a lot of code, spread across numerous packages. Many projects care about the provenance of their dependencies, and having a very large number makes such provenance more to think about, more to track down, etc. The voluminous transitive dependencies also make for a slow "npm i" and so on.
I've been able to avoid Babel for some use cases: Even when not using types, the TypeScript compiler can handle a broad swath of typical ES-newish to ES-6-or-5 compilation use cases, with a total of 1 dependency (+0 transitive dependencies), quickly. The main downside of this approach is that people look at you funny when you use "tsc" on a non-TypeScript project.
Ex: anyone using facebook's jest, vue-cli, etc will get v7 whenever those packages upgrade.
The typescript support seems interesting for people with large babel pipelines, but I'm not sure what the other use cases are since it doesn't do any of the typechecking tsc does. Would be interested in hearing what people plan to use it for.
https://blogs.msdn.microsoft.com/typescript/2018/08/27/types...
I don't mind setting up a build tool and configuring everything if the project will be actively maintained or if there's a real need for it, but for smaller projects I think it's better to keep things as simple as possible. It's a huge drag when you later revisit a project and a bunch of dependencies are outdated or broken.
One of the holdouts which kept me coming back to babel was JSX, but eventually I learned to love preact and its hyperscript-inspired template function. The code ends up being a bit more verbose but you drastically cut down on dependencies.
Babel is still superb if you're targeting a broad range of browsers. Although during development I usually disable babel-loader from Webpack for the improved performance and debugging experience.
It seems to be more common now to see library-specific Babel plugins that optimize performance or improve developer ux. These plugins are usually optional, but I use them to enhance css-in-js and i18n performance/development.
With good editor support and ts-lint, the dev experience is solid and as-expected. Setting up an explicit tsc command as a pre-commit hook or CI task should provide that extra bit of confidence.
For myself, not being a TS purist, it feels like a good option.
This change might a bit painful for some, but it had to happen. People shouldn't be relying on such early proposals in production.
I've been using @babel/preset-env since early on and it's superb. You just pick what platforms you're going to target, and you're pretty much good to go.
I'd suggest being a bit weary with automatic polyfills. It's very easy to start using every new feature out there only to have your resulting bundle balloon in size. Depending on the type of project, it might sometimes be better to be explicit about which features can be used, and manually importing those polyfills so you fully understand the price that you're paying.
There will probably be some people complaining about complexity and how certain things are still confusing. Although I would agree that there's still room for improvement, targeting multiple independent platforms just seems like it's a challenging problem to solve well. My experiences with cross-compiling native apps have been fairly limited, but when I've tried it I found it far more overwhelming when compared to setting up babel. Perhaps it's just my limited experience in the native space. Am I the only one, or have others shared similar experiences? If you disagree, I'd be very interested in reading about which tools you've used, and examples of ways in which you believe babel could be simplified or improved.
The polyfill for async, converts those calls to generator functions - however i'm not aware of any browsers which support generator functions, but DO NOT support async/await
If it supports async, it stays on modern.html, otherwise it redirects to legacy.html. There's also the ability to do some server detection for what payload to deliver. It's just async support is the only feature I test for.
client test;
try {
eval('(function() { async _ => _; })();');
} catch (e) {
window.location.replace('/legacy.html');
}
server test: import * as capabilities from 'browser-capabilities';
export default userAgent =>
capabilities
.browserCapabilities(userAgent)
.has('es2017');Congratulations to the @babel team, this release is hard earned
At my former company, the migration to Babel 6 was such a disaster we jokingly renamed it to «Babel Vista».