Grigio:babel deprecated?


#1

According to the package page on Atmosphere, it’s deprecated:

** Please consider to use the official MDG babel package **

But the MDG babel package doesn’t seem to work the same way. Whether I end my JS files in .js or .es6.js, it doesn’t transpile them, and I get errors when I use ES6 syntax. This doesn’t seem like a 1:1 replacement. Am I missing something?


#2

You can add react package and end your files on .jsx


#3

Which cannot really be the proper solution. Not everyone wants to use JSX, it’s a different language to an extent. Pulling in the whole react shebang would also be quite silly since that’s way way more than you actually want.

It seems that the “MDG babel package” is a bit lower-level and targeted at package authors etc than the grigio:babel package. From its readme I couldn’t clearly see how it can easily serve the same purpose as our current beloved babel package.

EDIT: tl;dr Just keep using grigio:babel for now until the official package is just as easy and straightforward to use.


#4

.jsx is a temporal solution. Meteor 1.2 is expected very soon, see RC https://github.com/meteor/meteor/releases
When 1.2 is out all .js become ES2015 compliant.
Here, at some point, grigio:babel fail with a class declaration then just rename es6.js files to .jsx plus react package and everything going back to work.


#5

with Meteor 1.2, ES2015 support is on ecmascript package. You can test it using Release Candidate. MDG go really fast with this version. Just take a deep breath :smile: and wait.


#6

Yes deprecated. Another alternative, if you what a premium ES2015 experience, is to use Meteor a a data synchronization layer inside a NPM project.


#7

That’s what I thought, until I came unstuck trying to clone an object with:

let clone = Object.assign({}, someObject)

Per: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

Exception while invoking method 'addTime' TypeError: Object function Object() { [native code] } has no method 'assign'

My files are .jsx as I’m using React, but it seems there are holes on the ES6 polyfill…


#8

I don´t use React my self but ES2015 stuff all the time, include Object.assign. I think you can migrate your project to 1.2 RC.
First create a 1.2 project with:

 meteor --release 1.2-rc.17 create projectName

Then copy all your code folders.
Then add your needed packages, react´s, third party. ES2015 is supported on all .JS files cause ecmascript package.

NOTE: Object can be cloned too with spread operator (…)

let clone = { ...someObject }

#9

Thanks for the swift reply! I’ll definately look into that, especially as 1.2 is getting close to relese. In the meantime I discovered jQuery.extend. I really don’t like poluting my code with jQuery (!) but since it’s built in as a Meteor dependency, it’s essentially free.

Good call too on the spread operator - much more concise.

Edit: as an aside - being a new JS developer I can’t help wondering, how did anyone manage before? Object cloning seems like such a fundamental capability to have left out of core JS for so long!