4
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

babel-transpiler gem でES6がES5にどう変換されるのか簡単に確認する方法

() => {} って一体何なんだよみたいなときにこんな感じで気軽に確認できます。

require "babel/transpiler"
puts Babel::Transpiler.transform(<<EOT)["code"]
() => {};
() => { 1 };
() => { return 1 };
() => 1;
let v = 1;
`v = ${v}`;
EOT
# >> "use strict";
# >> 
# >> (function () {});
# >> (function () {
# >>   1;
# >> });
# >> (function () {
# >>   return 1;
# >> });
# >> (function () {
# >>   return 1;
# >> });
# >> var v = 1;
# >> "v = " + v;
  • babel/transpilergem i babel-transpiler すると使えるようになります。
  • オンラインであれば https://babeljs.io/ で試す方がもっと簡単です。

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
4
Help us understand the problem. What are the problem?