Faster Babel 7 compiler debuts for JavaScript, TypeScript

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.

source computerworld

0 0 votes
Article Rating

Join Our WhatsApp Groups

Lagmen Limited Job Alert 1
Lagmen Limited Job Alert 2

Submit Your Discover News

discovernews@lagmen.net
reachus@lagmen.net

Contact Us Now

Tel: +2348051324267
Tel: +2348094097992
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x