{"id":11974,"date":"2020-10-09T11:51:02","date_gmt":"2020-10-09T02:51:02","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=11974"},"modified":"2023-05-27T20:55:17","modified_gmt":"2023-05-27T11:55:17","slug":"%e3%80%90babel%e3%80%91%e3%80%8cpresets%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=11974","title":{"rendered":"\u3010Babel\u3011Babel\u306e\u57fa\u672c\u3001\u300cpresets(\u30d7\u30ea\u30bb\u30c3\u30c8)\u300d\u3001\u300c\u30d7\u30e9\u30b0\u30a4\u30f3\u300d\u306b\u3064\u3044\u3066"},"content":{"rendered":"<div>\n<h2>Babel\u3068\u306f\uff1f<\/h2>\n<p>JavaScript\u3092\u53e4\u3044\u30b3\u30fc\u30c9\u304b\u3089\u65b0\u3057\u3044\u30b3\u30fc\u30c9\u3078\u5909\u63db\u3059\u308b\u30c4\u30fc\u30eb(ES6\u2192ES5\uff09\u3001\u307e\u305fReact\u306eJSX\u3092\u30d6\u30e9\u30a6\u30b6\u3067\u5b9f\u884c\u3067\u304d\u308b\u30b3\u30fc\u30c9\u306b\u5909\u63db\u3059\u308b\u5f79\u5272\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u5c0e\u5165\u65b9\u6cd5<\/h2>\n<p>\u57fa\u672c\u7684\u306b\u306fwebpack\u3068\u540c\u6642\u306b\u5c0e\u5165\u304c\u5fc5\u8981\u3067\u3057\u3087\u3046\u3002\u307e\u305a\u306f\u4ee5\u4e0b2\u3064\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>babel-core<\/li>\n<li>babel-loader<\/li>\n<\/ul>\n<h3>babel-core<\/h3>\n<p>Babel\u306e\u30b3\u30a2\u3067\u3059\u3002<\/p>\n<h3>babel-loader<\/h3>\n<p>\u3053\u308c\u304c\u3042\u308c\u3070<span style=\"color: #ff0000;\"><strong>webpack\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u30d0\u30f3\u30c9\u30eb\u3059\u308b\u524d\u306bbabel\u5909\u63db<\/strong><\/span>\u3092\u5b9f\u884c\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u4ee5\u4e0b\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>plugin<\/li>\n<li>presets<\/li>\n<\/ul>\n<h3>plugin<\/h3>\n<p>babel\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002<\/p>\n<h3>presets(\u30d7\u30ea\u30bb\u30c3\u30c8)<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>Babel\u304c\u5909\u63db\u51e6\u7406\u3092\u884c\u3046\u969b\u306b\u5229\u7528\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/strong><\/span>\u3067\u3059\u3002\u8a2d\u5b9a\u60c5\u5831\u3092\u57fa\u306b\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u306b\u5fc5\u8981\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30ea\u30b9\u30c8\u3092Babel\u672c\u4f53\u306b\u6e21\u3059\u5f79\u5272\u3092\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<h2>Babel REPL\u304c\u4fbf\u5229<\/h2>\n<p>\u4e0b\u8a18\u306e\u30da\u30fc\u30b8\u306b\u3044\u304f\u3068Babel\u3067\u5b9f\u969b\u306b\u5b9f\u884c\u3055\u308c\u308b\u30b3\u30fc\u30c9\u306b\u5909\u63db\u3055\u305b\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>https:\/\/bvaughn.github.io\/babel-repl\/<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306aJSX\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3059\u308b\u3068<\/p>\n<pre class=\"lang:default decode:true\">&lt;div&gt;\r\n  \"Hello world\"\r\n&lt;\/div&gt;<\/pre>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30d6\u30e9\u30a6\u30b6\u3067\u5b9f\u884c\u3055\u308c\u308b\u30b3\u30fc\u30c9\u306b\u81ea\u52d5\u5909\u63db\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">\"use strict\";\r\n\r\nReact.createElement(\r\n  \"div\",\r\n  null,\r\n  \"\\\"Hello world\\\"\"\r\n);<\/pre>\n<h2>presets(\u30d7\u30ea\u30bb\u30c3\u30c8\uff09\u3068\u306f\uff1f<\/h2>\n<p class=\"p1\"><span style=\"color: #ff0000;\"><span class=\"s1\"><b>Babel<\/b><\/span><b>\u304c\u5909\u63db\u51e6\u7406\u3092\u884c\u3046\u969b\u306b\u5229\u7528\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/b><\/span>\u3067\u3059\u3002\u8a2d\u5b9a\u60c5\u5831\u3092\u57fa\u306b\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u306b\u5fc5\u8981\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30ea\u30b9\u30c8\u3092<span class=\"s1\">Babel<\/span>\u672c\u4f53\u306b\u6e21\u3059\u5f79\u5272\u3092\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<h2>presets(\u30d7\u30ea\u30bb\u30c3\u30c8\uff09\u306e\u7a2e\u985e<\/h2>\n<div>\n<h3>next\/babel<\/h3>\n<p>Next.js\u7528\u306e\u30d7\u30ea\u30bb\u30c3\u30c8\u3001preset-env\u3084preset-react\u306a\u3069\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u96c6\u5408\u4f53\u3002Next.js\u3067jest\u3092\u52d5\u304b\u3057\u305f\u3044\u5834\u5408\u306b\u5229\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/div>\n<h3>@babel\/preset-typescript<\/h3>\n<p>Babel\u306b\u3088\u3063\u3066<span style=\"color: #ff0000;\"><strong>TypeScript<\/strong><\/span>\u3067\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u3092JavaScript\u306b\u5909\u63db\u3067\u304d\u308b\u30d7\u30ea\u30bb\u30c3\u30c8\u3067\u3059\u3002<\/p>\n<\/div>\n<div>\n<div>\n<h3>@babel\/preset-env<\/h3>\n<p>Babel\u306b\u3088\u3063\u3066<span style=\"color: #ff0000;\"><strong>ECMAScript<\/strong><\/span>\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30d7\u30ea\u30bb\u30c3\u30c8\u3067\u3059\u3002\u57fa\u672c\u7684\u306b\u306f\u30b5\u30dd\u30fc\u30c8\u3057\u305f\u3044\u30d6\u30e9\u30a6\u30b6\u306e\u7bc4\u56f2\u7b49\u3092\u6307\u5b9a\u3057\u305f\u308a\u3057\u307e\u3059\u3002\u6307\u5b9a\u3057\u305f\u5185\u5bb9\u306b\u5fdc\u3058\u3066\u9069\u5207\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u306eJavaScript\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u7279\u306b\u4f55\u3082\u6307\u5b9a\u3057\u306a\u3044\u5834\u5408\u306fES5\u306b\u4e00\u5f8b\u5909\u63db\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/strong><\/span><\/p>\n<div>\n<div>\n<h3>@babel\/preset-react<\/h3>\n<div>Babel\u306b\u3088\u3063\u3066<span style=\"color: #ff0000;\"><strong>React<\/strong><\/span>\u3067\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u3092JavaScript\u306b\u5909\u63db\u3067\u304d\u308b\u30d7\u30ea\u30bb\u30c3\u30c8\u3067\u3059\u3002<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div>\n<h3>babel-preset-power-assert<\/h3>\n<div>babel\u5909\u63db\u6642\u306bpower-assert(JavaScript\u306e\u69cb\u6587\u30c1\u30a7\u30c3\u30af)\u3092\u884c\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u57fa\u672c\u7684\u306b\u306f\u30c6\u30b9\u30c8\u74b0\u5883\u306e\u307f\u3067\u4f7f\u7528\u3057\u307e\u3059\u3002<\/div>\n<\/div>\n<div><\/div>\n<h2>\u30d7\u30e9\u30b0\u30a4\u30f3\u3068\u306f\uff1f<\/h2>\n<div>\n<div>\n<p class=\"p1\"><span class=\"s1\">babel<\/span>\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002<\/p>\n<h3>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u7a2e\u985e<\/h3>\n<h3>@babel\/plugin-proposal-class-properties<\/h3>\n<\/div>\n<div>\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5b9a\u7fa9\u3092\u30af\u30e9\u30b9\u5185\u306b\u76f4\u63a5\u66f8\u3044\u3066\u3057\u307e\u3048\u308b\u6587\u6cd5\u306e\u5909\u63db\u7528\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002React\u3067\u3088\u304f\u898b\u304b\u3051\u307e\u3059\u3002<\/div>\n<h3>@babel\/plugin-transform-modules-commonjs<\/h3>\n<div>\n<div>import\u3092require\u306b\u5909\u63db\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002<\/div>\n<\/div>\n<\/div>\n<div>\n<div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Babel\u3068\u306f\uff1f JavaScript\u3092\u53e4\u3044\u30b3\u30fc\u30c9\u304b\u3089\u65b0\u3057\u3044\u30b3\u30fc\u30c9\u3078\u5909\u63db\u3059\u308b\u30c4\u30fc\u30eb(ES6\u2192ES5\uff09\u3001\u307e\u305fReact\u306eJSX\u3092\u30d6\u30e9\u30a6\u30b6\u3067\u5b9f\u884c\u3067\u304d\u308b\u30b3\u30fc\u30c9\u306b\u5909\u63db\u3059\u308b\u5f79\u5272\u3082\u3042\u308a\u307e\u3059\u3002 \u5c0e\u5165\u65b9\u6cd5 \u57fa\u672c\u7684\u306b\u306fwebpack\u3068\u540c\u6642 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11974"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11974"}],"version-history":[{"count":11,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11974\/revisions"}],"predecessor-version":[{"id":20280,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11974\/revisions\/20280"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11974"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}