Reputation: 2470
The recent Meteor tutorials use the import
aspect of ES6 a lot, and I'd like to know if there's an es6 wrapper or other simple way to experiment with this specific feature without having to create a new package.json
, npm install babel --save
, npm start
, etc...
Ideally, something like this:
> echo 'import "./importme.js";' > new.js
> echo 'console.log('hi');' > import.js
> es6 new.js
hi
>
I did notice babel-node, but it's complaining that import is not a valid token, and apparently it doesn't support import
from the REPL.
Is there a REPL or node wrapper that supports import
?
Thanks
Upvotes: 2
Views: 173
Reputation: 53929
babel-node
will work fine, but babel
doesn't do anything out of the box since version 6. You have to install presets to opt-in to the new features.
npm install babel-node
npm install babel-preset-es2015
Installs the preset for ES2015 syntax.touch .babelrc
Create a .babelrc file to tell babel
which presets you are usingInside your .babelrc
file, add the following code:
{
"presets": ["es2015"]
}
Now, running babel-node
will work.
Upvotes: 1
Reputation: 6377
I believe that there is not, in fact, a simpler and more maintainable way than what is presented in the Babel 6 manual. It is not too hard. See https://babeljs.io/docs/setup/#installation
Upvotes: 0