3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-08-27

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

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/ で試す方がもっと簡単です。
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?