From 29b2eb1a6b25ab4421e4b15a1012cdcc38effc59 Mon Sep 17 00:00:00 2001 From: Steven Langbroek Date: Fri, 29 May 2015 14:35:58 +0200 Subject: [PATCH] Update babel, use stage=0, move static props into classes --- karma.config.js | 4 ++-- package.json | 4 ++-- src/main.jsx | 2 +- src/pages/home/page.jsx | 9 ++++----- src/pages/landing/page.jsx | 8 ++++---- src/routers/logged_in.jsx | 20 ++++++++++---------- src/routers/logged_out.jsx | 19 +++++++++---------- webpack.local.config.js | 8 ++++++-- webpack.production.config.js | 4 ++-- 9 files changed, 40 insertions(+), 38 deletions(-) diff --git a/karma.config.js b/karma.config.js index 80d122d..7e285cc 100644 --- a/karma.config.js +++ b/karma.config.js @@ -69,7 +69,7 @@ module.exports = function(config) { webpack: { module: { loaders: [ - { test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader"} + { test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader?stage=0"} ], postLoaders: [{ test: /\.jsx?$/, @@ -105,4 +105,4 @@ module.exports = function(config) { 'karma-phantomjs-launcher' ], }); -} \ No newline at end of file +} diff --git a/package.json b/package.json index 41352cf..496ce7a 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "webpack-dev-server": "^1.7.0" }, "dependencies": { - "babel-core": "^5.4.3", - "babel-loader": "^5.1.2", + "babel-core": "^5.4.7", + "babel-loader": "^5.1.3", "express": "^4.12.3", "react": "^0.13.3", "react-router": "^0.13.3", diff --git a/src/main.jsx b/src/main.jsx index 5ced73d..0e5cf2b 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -79,4 +79,4 @@ Router.run(routes, Router.HistoryLocation, function(Handler, state) { fetchData(state.routes, state.params).then((data) => { React.render(, document.getElementById(DOM_APP_EL_ID)); }); -}); \ No newline at end of file +}); diff --git a/src/pages/home/page.jsx b/src/pages/home/page.jsx index fa7d188..275fe14 100644 --- a/src/pages/home/page.jsx +++ b/src/pages/home/page.jsx @@ -1,7 +1,6 @@ import React from "react"; import { getData } from "../../common/request"; - export default class HomePage extends React.Component { componentWillMount() { console.log("[HomePage] will mount with server response: ", this.props.data.home); @@ -16,8 +15,8 @@ export default class HomePage extends React.Component { ); } -} -HomePage.fetchData = function(params) { - return getData("/home"); -} \ No newline at end of file + static fetchData = function(params) { + return getData("/home"); + } +} diff --git a/src/pages/landing/page.jsx b/src/pages/landing/page.jsx index 83b3447..3055c19 100644 --- a/src/pages/landing/page.jsx +++ b/src/pages/landing/page.jsx @@ -16,8 +16,8 @@ export default class LandingPage extends React.Component { ); } -} -LandingPage.fetchData = function(params) { - return getData("/landing"); -} \ No newline at end of file + static fetchData = function(params) { + return getData("/landing"); + } +} diff --git a/src/routers/logged_in.jsx b/src/routers/logged_in.jsx index 60e3c54..84709dc 100644 --- a/src/routers/logged_in.jsx +++ b/src/routers/logged_in.jsx @@ -1,6 +1,5 @@ import React from "react"; -import Router from "react-router"; -let { Route, DefaultRoute, RouteHandler, Link } = Router; +import { Route, DefaultRoute, RouteHandler, Link } from "react-router"; import HomePage from "../pages/home/page"; @@ -23,12 +22,13 @@ export default class LoggedInRouter extends React.Component { ); } -} -LoggedInRouter.getRoutes = function() { - return ( - - - - ); -} \ No newline at end of file + static getRoutes = function() { + return ( + + + + ); + } + +} diff --git a/src/routers/logged_out.jsx b/src/routers/logged_out.jsx index a9d7b3c..1789ee4 100644 --- a/src/routers/logged_out.jsx +++ b/src/routers/logged_out.jsx @@ -1,6 +1,5 @@ import React from "react"; -import Router from "react-router"; -let { Route, DefaultRoute, RouteHandler } = Router; +import { Route, DefaultRoute, RouteHandler } from "react-router"; import LandingPage from "../pages/landing/page"; @@ -15,12 +14,12 @@ export default class LoggedOutRouter extends React.Component { ); } -} -LoggedOutRouter.getRoutes = function() { - return ( - - - - ); -} \ No newline at end of file + static getRoutes = function() { + return ( + + + + ); + } +} diff --git a/webpack.local.config.js b/webpack.local.config.js index 9e74fa4..6abde47 100644 --- a/webpack.local.config.js +++ b/webpack.local.config.js @@ -39,7 +39,11 @@ module.exports = { // Transform source code using Babel and React Hot Loader module: { loaders: [ - { test: /\.jsx?$/, exclude: /node_modules/, loaders: ["react-hot", "babel-loader"]} + { + test: /\.jsx?$/, + exclude: /node_modules/, + loaders: ["react-hot", "babel-loader?stage=0"], + } ] }, @@ -47,4 +51,4 @@ module.exports = { resolve: { extensions: ['', '.js', '.jsx'] } -} \ No newline at end of file +} diff --git a/webpack.production.config.js b/webpack.production.config.js index 4c39fc1..56ff3e9 100644 --- a/webpack.production.config.js +++ b/webpack.production.config.js @@ -13,11 +13,11 @@ module.exports = { module: { loaders: [ - { test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader" } + { test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader?stage=0" } ] }, resolve: { extensions: ['', '.js', '.jsx'] } -} \ No newline at end of file +}