Use React Hot Loader 3 instead of React Transform

This commit is contained in:
Ken-Håvard Lieng 2017-04-12 00:00:59 +02:00
parent ee42e5300a
commit ee43d2fe27
5 changed files with 48 additions and 47 deletions

View File

@ -1,23 +1,12 @@
{
"presets": [
["es2015", { "modules": false }],
["es2015", { "modules": false, "loose": true }],
"react",
"stage-0"
],
"env": {
"development": {
"plugins": [
["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}, {
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}]
]
"plugins": ["react-hot-loader/babel"]
},
"production": {
"plugins": [

View File

@ -7,7 +7,6 @@
"babel-core": "^6.23.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.3.1",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-react-constant-elements": "^6.23.0",
"babel-plugin-transform-react-inline-elements": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
@ -30,9 +29,6 @@
"gulp-gzip": "1.4.0",
"gulp-util": "^3.0.8",
"ify-loader": "^1.0.3",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.4",
"redbox-react": "^1.3.3",
"style-loader": "^0.16.0",
"webpack": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
@ -48,6 +44,7 @@
"lodash": "^4.17.4",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-hot-loader": "next",
"react-redux": "^5.0.2",
"react-router": "^3.0.2",
"react-router-redux": "^4.0.8",

View File

@ -2,6 +2,7 @@ import React from 'react';
import { render } from 'react-dom';
import { browserHistory } from 'react-router';
import { syncHistoryWithStore, replace } from 'react-router-redux';
import { AppContainer } from 'react-hot-loader';
import 'react-virtualized/styles.css';
import configureStore from './store';
@ -50,7 +51,17 @@ handleSocket(socket, store);
const routes = createRoutes();
const history = syncHistoryWithStore(browserHistory, store);
render(
<Root store={store} routes={routes} history={history} />,
document.getElementById('root')
);
const renderRoot = () => {
render(
<AppContainer>
<Root store={store} routes={routes} history={history} />
</AppContainer>,
document.getElementById('root')
);
};
renderRoot();
if (module.hot) {
module.hot.accept('./routes', () => renderRoot());
}

View File

@ -4,6 +4,7 @@ var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'react-hot-loader/patch',
'webpack-hot-middleware/client',
'./src/js/index'
],

View File

@ -60,6 +60,10 @@ alphanum-sort@^1.0.1, alphanum-sort@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3"
amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
ansi-escapes@^1.1.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e"
@ -437,12 +441,6 @@ babel-plugin-check-es2015-constants@^6.22.0:
dependencies:
babel-runtime "^6.22.0"
babel-plugin-react-transform@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/babel-plugin-react-transform/-/babel-plugin-react-transform-2.0.2.tgz#515bbfa996893981142d90b1f9b1635de2995109"
dependencies:
lodash "^4.6.1"
babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
@ -906,7 +904,7 @@ babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.22.0:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-template@^6.24.1:
babel-template@^6.24.1, babel-template@^6.7.0:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333"
dependencies:
@ -4401,9 +4399,9 @@ rc@^1.1.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
react-deep-force-update@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.0.1.tgz#f911b5be1d2a6fe387507dd6e9a767aa2924b4c7"
react-deep-force-update@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-2.0.1.tgz#4f7f6c12c3e7de42f345992a3c518236fa1ecad3"
react-dom@^15.4.2:
version "15.5.3"
@ -4414,12 +4412,22 @@ react-dom@^15.4.2:
object-assign "^4.1.0"
prop-types "~15.5.0"
react-proxy@^1.1.7:
version "1.1.8"
resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-1.1.8.tgz#9dbfd9d927528c3aa9f444e4558c37830ab8c26a"
react-hot-loader@next:
version "3.0.0-beta.6"
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-3.0.0-beta.6.tgz#463fac0bfc8b63a8385258af20c91636abce75f4"
dependencies:
babel-template "^6.7.0"
global "^4.3.0"
react-deep-force-update "^2.0.1"
react-proxy "^3.0.0-alpha.0"
redbox-react "^1.2.5"
source-map "^0.4.4"
react-proxy@^3.0.0-alpha.0:
version "3.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-3.0.0-alpha.1.tgz#4400426bcfa80caa6724c7755695315209fa4b07"
dependencies:
lodash "^4.6.1"
react-deep-force-update "^1.0.0"
react-redux@^5.0.2:
version "5.0.4"
@ -4449,17 +4457,6 @@ react-router@^3.0.2:
prop-types "^15.5.6"
warning "^3.0.0"
react-transform-catch-errors@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/react-transform-catch-errors/-/react-transform-catch-errors-1.0.2.tgz#1b4d4a76e97271896fc16fe3086c793ec88a9eeb"
react-transform-hmr@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/react-transform-hmr/-/react-transform-hmr-1.0.4.tgz#e1a40bd0aaefc72e8dfd7a7cda09af85066397bb"
dependencies:
global "^4.3.0"
react-proxy "^1.1.7"
react-virtualized@^9.3.0:
version "9.7.2"
resolved "https://registry.yarnpkg.com/react-virtualized/-/react-virtualized-9.7.2.tgz#860d2438e3fa464e9d021ce2984d484c4d98a1ae"
@ -4557,7 +4554,7 @@ rechoir@^0.6.2:
dependencies:
resolve "^1.1.6"
redbox-react@^1.3.3:
redbox-react@^1.2.5:
version "1.3.6"
resolved "https://registry.yarnpkg.com/redbox-react/-/redbox-react-1.3.6.tgz#70314c57c066257eb70b0a24dc794b5cef4f1c4e"
dependencies:
@ -4893,6 +4890,12 @@ source-map-support@^0.4.2:
dependencies:
source-map "^0.5.6"
source-map@^0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
dependencies:
amdefine ">=0.0.4"
source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.3:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"