Meteor 1.3 and Babel options

The BabelCompiler constructor in Meteor 1.3 takes options via the extraFeatures parameter. For example, here’s what the ecmascript package does:

Plugin.registerCompiler({
  extensions: ['js'],
}, function () {
  return new BabelCompiler({
    asyncAwait: true,
    modules: true
  });
});

Plugin.registerCompiler({
  extensions: ['jsx'],
}, function () {
  return new BabelCompiler({
    asyncAwait: true,
    modules: true,
    react: true
  });
});

It’d be nice if there were more options, and a way for us to configure them. Maybe they can live in package.json (since that will now be a common thing in Meteor 1.3+). It’d be nice to, for example, enable stage-0 features, etc. It might look like this:

// package.json
{
  // ..
  "ecmascriptOptions": {
    "classProperties": true
  }
}

That would enable class properties on top of the default options that the BabelCompiler already applies based on whether a file is a .js or .jsx file.

Any thoughts on this idea?

(cc: @benjamn)

5 Likes

That would be perfect. It would be really great to be able to enable some extra es7 features like object spreads.

In the current Meteor 1.2.1 you can use the .babelrc file to configure Babel. For example enabling the decorators feature: https://github.com/meteor/meteor/issues/5246#issuecomment-143021509.

1 Like

This would be a great feature to have. I use class properties heavily and really don’t want to refactor my code. It should be easy to turn on simple plugins.

@benjamn

@trusktr can you copy/paste this into a GitHub issue? I definitely want to do this in Meteor 1.3.1.

The Babel 6 plugin system makes configuration much, much easier than it was in Meteor 1.2. In short, I think we can support any configuration as long as it includes the preset babel-preset-meteor, along with any additional plugins you might want. In other words, you won’t be able to remove features that are included in that preset, but you can add as many other features as you like. You might also have to do npm install babel-runtime in your app, but that’s probably not too much to ask :slight_smile:

@sanjo here’s an issue for enabling decorators: https://github.com/meteor/meteor/issues/6057

@jfrolich object ...spread should be enabled currently!

3 Likes

I created an issue in Github.

Once this change is made I’ll be able to jump on to 1.3 and I really can’t wait!

1 Like

@benjamn, @clayne did it. Thanks @clayne!