Add Babel plugin "syntax-optional-chaining"


I can’t get to make this Babel plugin to work:

My .babelrc is farily simple:

  "plugins": ["syntax-optional-chaining"]

Tried a lot of different configs based on what I saw in other topics, but I still have this kind of error:

=> Errors prevented startup:                  
   While processing files with ecmascript (for target web.browser):
   client/components/chapter/chapterEdit.js:208:41: Unexpected token (208:41)

Looks like the Meteor ecmascript package can’t parse that new feature even if I’m using a Babel plugin. Am I missing something?


Related but not mine:

Interesting package. Lodash’s _.get and _.result sort of do the same thing if that’s an ok substitute for you.

By the way this package simply follows a stage-1 proposal for ecmascript:

Thanks for pointing that out, but I can’t afford to remove Underscore from my project, so loading Lodash on top of it isn’t a solution…

Looks like .babelrc support for Meteor is meant to do just that, so I think I misunderstood something! :slight_smile:

You could add it as an individual package and even add it to underscore with _.mixin :slight_smile: An option if you don’t figure out the babel issue.

Unfortunately, this plugin is currently only supported in babel 7. I was tripped up by that just last week. I’m indeed looking forward to seeing this available in Meteor or any kind of javascript set up for that matter.

1 Like

Babel 7 is coming in Meteor 1.6, try updating to the release candidate and see if the plugin works there

1 Like

I’ll take another look this week-end, thanks! Is it anything more to do than npm installing the package & editing the .babelrc file?

Just tried with Meteor 1.6-rc3, reinstalled the babel plugin, and I also tried to add this to package.json, but no luck:

"babel": {
  "plugins": ["syntax-optional-chaining"]

Looks like Babel 7 has been shipped wit Meteor 1.6. Can’t upgrade for now, did anyone try it?