meteor / babel

Babel wrapper package for use with Meteor
Other
46 stars 20 forks source link

Make it easy to get default Babel options for Node 8+. #18

Closed benjamn closed 7 years ago

benjamn commented 7 years ago

Meteor 1.6 will ship with Node 8, which has native support for virtually every standard ECMAScript feature, including async/await (but notably excluding import/export, which we will continue to compile using Reify).

This pull request makes it simpler to get default options with Babel plugins appropriate for Node 8 (and later) by calling

require("meteor-babel").getDefaultOptions({
  nodeMajorVersion: 8 // or 9, 10, ...
});

Note that this API is backwards-compatible with older versions of meteor-babel, because they will simply ignore the features.nodeMajorVersion property and continue returning options appropriate for Node 4.

Since these new options contain many fewer Babel plugins, we hope compilation times will be faster for server code (even though there is constant overhead from parsing &c. that hasn't changed), or at least that the generated code is easier to read and debug.

It was tempting to use babel-preset-env to help with this, but the fact that Meteor ships with one version of Node, together with the need for custom plugins, made that somewhat less appealing. I'm still open to it, though, if it really simplifies things.