diff --git a/.babelrc b/.babelrc index 16b8d93a..8194dcfa 100644 --- a/.babelrc +++ b/.babelrc @@ -7,6 +7,7 @@ "react" ], "plugins": [ + "react-hot-loader/babel", "transform-class-properties", "transform-object-rest-spread", "transform-flow-strip-types", diff --git a/package.json b/package.json index 28a43a7e..40ee7e19 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "babel-core": "^6.26.3", "color-hash": "^1.0.3", "copy-webpack-plugin": "^4.5.2", + "date-fns": "^1.29.0", "ethereumjs-tx": "^1.3.3", "ethereumjs-units": "^0.2.0", "ethereumjs-util": "^5.1.4", @@ -41,7 +42,7 @@ "react": "^16.2.0", "react-css-transition": "^0.7.4", "react-dom": "^16.2.0", - "react-hot-loader": "4.2.0", + "react-hot-loader": "^4.3.4", "react-qr-svg": "^2.1.0", "react-redux": "^5.0.7", "react-router-dom": "^4.2.2", diff --git a/src/js/components/common/Footer.js b/src/js/components/common/Footer.js index 162e1c93..28e09aae 100644 --- a/src/js/components/common/Footer.js +++ b/src/js/components/common/Footer.js @@ -1,6 +1,7 @@ import styled from 'styled-components'; import PropTypes from 'prop-types'; import React from 'react'; +import { getYear } from 'date-fns'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; @@ -27,7 +28,7 @@ const Copy = styled.div` const Footer = ({ toggle }) => ( - © 2018 + © {getYear(new Date())} SatoshiLabs Terms Show Log diff --git a/src/js/index.js b/src/js/index.js index 83fb3211..ec0ac5c4 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -2,22 +2,17 @@ import React from 'react'; import { render } from 'react-dom'; import store from './store'; -import router from './router'; +import App from './router'; import { onBeforeUnload } from './actions/WalletActions'; import styles from '~/styles/index.less'; const root: ?HTMLElement = document.getElementById('root'); if (root) { - render(router, root); + render(, root); } window.onbeforeunload = () => { store.dispatch(onBeforeUnload()); }; -if (typeof module !== undefined && module.hasOwnProperty('hot')) { - // $FlowIssue - module.hot.accept(); -} - // Application life cycle starts in ./services/WalletService.js \ No newline at end of file diff --git a/src/js/router/index.js b/src/js/router/index.js index 42391876..68ad389c 100644 --- a/src/js/router/index.js +++ b/src/js/router/index.js @@ -1,7 +1,5 @@ -/* @flow */ - - import React from 'react'; +import { hot } from 'react-hot-loader'; import { Route, Switch } from 'react-router-dom'; import { Provider } from 'react-redux'; import { ConnectedRouter } from 'react-router-redux'; @@ -22,7 +20,7 @@ import SignVerifyContainer from '../components/wallet/account/sign/SignVerify'; import DeviceSettingsContainer from '../components/wallet/pages/DeviceSettings'; import WalletSettingsContainer from '../components/wallet/pages/WalletSettings'; -export default ( +const App = () => ( @@ -49,4 +47,6 @@ export default ( -); \ No newline at end of file +); + +export default hot(module)(App); \ No newline at end of file diff --git a/src/js/services/WalletService.js b/src/js/services/WalletService.js index 284eb049..7c08c0a7 100644 --- a/src/js/services/WalletService.js +++ b/src/js/services/WalletService.js @@ -4,7 +4,6 @@ import { DEVICE } from 'trezor-connect'; import { LOCATION_CHANGE } from 'react-router-redux'; import * as WALLET from '../actions/constants/wallet'; -import * as SEND from '../actions/constants/wallet'; import * as WalletActions from '../actions/WalletActions'; import * as LocalStorageActions from '../actions/LocalStorageActions'; @@ -15,11 +14,7 @@ import type { Middleware, MiddlewareAPI, MiddlewareDispatch, - State, - Dispatch, Action, - GetState, - TrezorDevice, } from '~/flowtype'; /** diff --git a/webpack/config.dev.babel.js b/webpack/config.dev.babel.js index 6a79af31..d7bfe2af 100644 --- a/webpack/config.dev.babel.js +++ b/webpack/config.dev.babel.js @@ -9,7 +9,7 @@ module.exports = { mode: 'development', devtool: 'inline-source-map', entry: { - index: ['react-hot-loader/patch', `${SRC}js/index.js`], + index: [`${SRC}js/index.js`], }, output: { filename: '[name].[hash].js', diff --git a/webpack/config.dev.local.babel.js b/webpack/config.dev.local.babel.js index 6ef01e70..e3506e9c 100644 --- a/webpack/config.dev.local.babel.js +++ b/webpack/config.dev.local.babel.js @@ -1,3 +1,7 @@ +import webpack from 'webpack'; +import HtmlWebpackPlugin from 'html-webpack-plugin'; +import CopyWebpackPlugin from 'copy-webpack-plugin'; +import MiniCssExtractPlugin from 'mini-css-extract-plugin'; import { TREZOR_CONNECT_ROOT, TREZOR_CONNECT_HTML, @@ -5,26 +9,20 @@ import { TREZOR_CONNECT, TREZOR_IFRAME, TREZOR_POPUP, TREZOR_WEBUSB, SRC, BUILD, - PORT + PORT, } from './constants'; - -import webpack from 'webpack'; -import HtmlWebpackPlugin from 'html-webpack-plugin'; -import CopyWebpackPlugin from 'copy-webpack-plugin'; -import MiniCssExtractPlugin from 'mini-css-extract-plugin'; - module.exports = { watch: true, mode: 'development', devtool: 'inline-source-map', entry: { - 'index': ['react-hot-loader/patch', `${SRC}js/index.js`], + index: [`${SRC}js/index.js`], 'trezor-connect-npm': `${TREZOR_CONNECT}.js`, // 'extension-permissions': `${TREZOR_CONNECT_ROOT}src/js/extensionPermissions.js`, - 'iframe': TREZOR_IFRAME, - 'popup': TREZOR_POPUP, - 'webusb': TREZOR_WEBUSB, + iframe: TREZOR_IFRAME, + popup: TREZOR_POPUP, + webusb: TREZOR_WEBUSB, }, output: { filename: '[name].[hash].js', @@ -44,18 +42,18 @@ module.exports = { { test: /\.jsx?$/, exclude: /node_modules/, - use: ['babel-loader'] + use: ['babel-loader'], }, { test: /\.less$/, use: [ { loader: MiniCssExtractPlugin.loader, - options: { publicPath: '../' } + options: { publicPath: '../' }, }, 'css-loader', 'less-loader', - ] + ], }, { test: /\.(png|gif|jpg)$/, @@ -63,7 +61,7 @@ module.exports = { query: { outputPath: './images', name: '[name].[ext]', - } + }, }, { test: /\.(ttf|eot|svg|woff|woff2)$/, @@ -96,11 +94,11 @@ module.exports = { resolve: { modules: [SRC, 'node_modules', `${TREZOR_CONNECT_ROOT}/node_modules`], alias: { - 'trezor-connect': `${TREZOR_CONNECT}` - } + 'trezor-connect': `${TREZOR_CONNECT}`, + }, }, performance: { - hints: false + hints: false, }, plugins: [ new MiniCssExtractPlugin({ @@ -112,26 +110,26 @@ module.exports = { chunks: ['index'], template: `${SRC}index.html`, filename: 'index.html', - inject: true + inject: true, }), new HtmlWebpackPlugin({ chunks: ['iframe'], - filename: `iframe.html`, + filename: 'iframe.html', template: `${TREZOR_CONNECT_HTML}iframe.html`, - inject: false + inject: false, }), new HtmlWebpackPlugin({ chunks: ['popup'], filename: 'popup.html', template: `${TREZOR_CONNECT_HTML}popup.html`, - inject: false + inject: false, }), new HtmlWebpackPlugin({ chunks: ['webusb'], - filename: `webusb.html`, + filename: 'webusb.html', template: `${TREZOR_CONNECT_HTML}webusb.html`, - inject: true + inject: true, }), // new HtmlWebpackPlugin({ // chunks: ['extension-permissions'], @@ -158,7 +156,7 @@ module.exports = { ], // ignoring "fs" import in fastxpub node: { - fs: "empty", - path: "empty", + fs: 'empty', + path: 'empty', }, -} \ No newline at end of file +}; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 2bb4b2e3..1bfd2ea9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2794,7 +2794,7 @@ data-urls@^1.0.0: whatwg-mimetype "^2.0.0" whatwg-url "^6.4.0" -date-fns@^1.27.2: +date-fns@^1.27.2, date-fns@^1.29.0: version "1.29.0" resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.29.0.tgz#12e609cdcb935127311d04d33334e2960a2a54e6" @@ -7785,9 +7785,9 @@ react-css-transition@^0.7.4: object-assign "^4.1.1" prop-types "^15.6.0" -react-hot-loader@4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.2.0.tgz#4a2ec79114f872e28ea786e04889d643ad3dfb7c" +react-hot-loader@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.3.4.tgz#4f9bdd55bb20d77a6ae8931fa1c187e5f0ce6279" dependencies: fast-levenshtein "^2.0.6" global "^4.3.0"