DRYな備忘録

Don't Repeat Yourself.

【追記】babelのバージョン揃えるのみなさんどうしてるんですか? Unexpected token

% npm install --save-dev babel babel-core babel-loader

こういうの出る

% webpack

ERROR in ./src/js/app/app.jsx
Module parse failed: /app.jsx Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import React, { Component } from 'react';
| import ReactDOM from 'react-dom';

解決

     "react-dom": "^0.14.7"
   },
   "devDependencies": {
-    "babel": "^6.5.2",
-    "babel-core": "^6.5.2",
-    "babel-loader": "^6.2.4",
+    "babel": "^5.8.23",
+    "babel-core": "^5.8.23",
+    "babel-loader": "^5.3.2",
     "webpack": "^1.12.14"
   },

最新でぱこっとnpm installで落ちてくるのが噛み合わないのだるくないですか?

DRY

React+Babel+webpackの最小構成つくってだるかったことメモ - DRYな備忘録

追記

6系でも動きました。

.babelrcに、以下を追加

{
    "presets": ["es2015"]
}

Module build failed: Error: Couldn't find preset "es2015" が出るので、

npm install --save-dev babel-preset-es2015

うーむ、loaderだけじゃなくなったんですね。だるい

babeljs.io