Paul Krill
Editor at Large

Faster Babel 7 compiler debuts for JavaScript, TypeScript

news
Aug 29, 20182 mins

But TypeScript is not fully supported, and Babel 7 does break some existing code

compiling compiler code
Credit: Deavmi

Babel 7, an upgrade to the JavaScript compiler two years in the making, is now available, with speed improvements and TypeScript support.

The faster Babel should reduce build times. Changes have been made to optimize code. Patches have been accepted from Google’s V8 JavaScript engine team.

Also, Babel now ships with TypeScript support. You parse type syntax using @babel/preset-typescript, similar to how Babel has handled the Flow static type checker. But Babel does not do type-checking on TypeScript code; it only transforms the code and will compile regardless of which type errors might be present. Babel does transform the latest JavaScript features to older runtimes and browsers.

Other capabilities in Babel 7 include:

  • The babel-upgrade tool, for automatically dealing with breaking changes. The tool has dependencies in package.json and babelrc config. The Babel team recommends running it directly on a Git repo with npx babel-upgrade, or you can installed it directly with npm i babel-upgrade –g.
  • For JavaScript configuration files, there is now babel.js.config. These files are common in the JavaScript ecosystem.
  • Selective configurations are enabled via overrides, for specifying different configs per glob.
  • Changes have been made to the loose option of some plugins, while new options have been added to others. But using these options opts the developer into non-spec-compliant behavior. This can become an issue when switching off of compiling to use the syntax natively.
  • Automatic polyfilling is featured, in an experimental fashion. Polyfills are needed for features such as Promise and symbol in environments that do not support them. This is important when differentiating between what Babel does as a compiler vs. a polyfill.
  • The caller option has been added to @babel/core so tools can pass metadata to presets and plugins.

Babel 7 does break several existing capabilities:

  • It drops support for unmaintained Node Versions 0.10, 0.12, 4, 5.
  • It introduces the peerDependency on @babel/core for certain user-facing packages, such as babel-loader and babel-cli.
  • It moves to the @babel namespace by switching to “scoped” packages. This helps differentiate official packages so babel-core becomes @babel/core.
  • JSX Fragment support is available, as it has been since beta 31.

Planned features for future versions include:

  • Plugin ordering.
  • Better validation and error messages.
  • Asynchronous use of Babel.

Where to download Babel 7

You can download Babel 7 from babeljs.io.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author