Skip to content

Commit 9b2fdb4

Browse files
author
Markus Dethlefsen
committed
refactor and fix hot reloading
1 parent 9319f46 commit 9b2fdb4

27 files changed

+170
-149
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"production" : {
44
"presets": ["es2015-webpack", "stage-0", "react"],
55
"plugins": [
6+
"transform-promise-to-bluebird",
67
"transform-react-constant-elements",
78
"transform-react-inline-elements"
89
]
910
},
1011
"development": {
1112
"presets": ["es2015-loose", "stage-0", "react"],
1213
"plugins": [
14+
["transform-promise-to-bluebird"],
1315
["babel-plugin-espower", {
1416
"embedAst": true
1517
}],
@@ -23,6 +25,7 @@
2325
"test": {
2426
"presets": ["es2015-loose", "stage-0", "react"],
2527
"plugins": [
28+
["transform-promise-to-bluebird"],
2629
["babel-plugin-espower", {
2730
"embedAst": true
2831
}],

.eslintrc

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
{
22
"extends": "airbnb",
3-
"plugins": [
4-
"react"
5-
],
63
"parser": "babel-eslint",
7-
"parserOptions": {
8-
"ecmaVersion": 6,
9-
"sourceType": "module",
10-
"ecmaFeatures": {
11-
"jsx": true,
12-
"experimentalObjectRestSpread": true
13-
}
14-
},
154
"globals": {
165
"sinon": false,
176
"expect": false,
@@ -54,6 +43,7 @@
5443
"react/forbid-prop-types": [1, {
5544
"forbid": ["any"]
5645
}],
46+
"react/jsx-filename-extension": 0,
5747
"react/jsx-first-prop-new-line": 0,
5848
"react/jsx-boolean-value": 0,
5949
"react/jsx-closing-bracket-location": 0,
@@ -66,8 +56,6 @@
6656
"react/jsx-no-literals": 0,
6757
"react/jsx-no-undef": 1,
6858
"react/jsx-pascal-case": 1,
69-
"react/jsx-sort-prop-types": 0,
70-
"react/jsx-sort-props": 0,
7159
"react/jsx-uses-react": 1,
7260
"react/jsx-uses-vars": 1,
7361
"react/no-danger": 1,
@@ -80,9 +68,8 @@
8068
"react/prefer-es6-class": 1,
8169
"react/prop-types": 1,
8270
"react/react-in-jsx-scope": 1,
83-
"react/require-extension": 1,
8471
"react/self-closing-comp": 1,
8572
"react/sort-comp": 1,
86-
"react/wrap-multilines": 1
73+
"react/jsx-wrap-multilines": 1
8774
}
8875
}

.sass-lint.yml

-14
This file was deleted.

package.json

+64-61
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"scripts": {
66
"start": "cross-env NODE_ENV=production node dist/index.js",
77
"prestart:dev": "rimraf ./i18n",
8+
"dev": "npm run start:dev",
89
"start:dev": "run-p -c --silent test:watch build:dev translation:watchpot translation:watchpo",
910
"test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 mocha --reporter mocha-junit-reporter",
10-
"test:watch": "npm run test -- --watch --reporter min",
11+
"test:spec": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 mocha --reporter spec",
12+
"test:watch": "npm run test -- --watch --reporter spec",
1113
"test:coverage": "nyc --cache npm run test -- --reporter spec",
1214
"test:lint": "eslint ./src",
1315
"build": "cross-env NODE_ENV=production webpack --config webpack/webpack.config.js",
@@ -48,73 +50,44 @@
4850
"npm": ">=3.8.3"
4951
},
5052
"dependencies": {
51-
"bluebird": "^3.4.0",
52-
"cors": "^2.7.1",
53-
"dotenv-safe": "^2.3.1",
54-
"express": "^4.13.4",
55-
"express-jwt": "^3.4.0",
56-
"isomorphic-fetch": "^2.2.1",
57-
"lodash": "^4.13.1",
58-
"react": "^15.2.0",
59-
"react-addons-css-transition-group": "^15.2.0",
60-
"react-body-classname": "^1.0.1",
61-
"react-bootstrap": "^0.29.4",
62-
"react-dom": "^15.2.0",
63-
"react-helmet": "^3.1.0",
64-
"react-hot-loader": "^3.0.0-beta.2",
65-
"react-intl": "^2.1.3",
66-
"react-intl-redux": "0.0.11",
67-
"react-redux": "^4.4.5",
68-
"react-router": "^2.5.2",
69-
"react-router-redux": "^4.0.5",
70-
"redux": "^3.3.1",
71-
"redux-promise": "^0.5.3",
72-
"redux-thunk": "^2.1.0"
73-
},
74-
"devDependencies": {
75-
"autoprefixer": "^6.3.7",
76-
"babel-cli": "^6.10.1",
77-
"babel-core": "^6.10.4",
78-
"babel-eslint": "^6.1.0",
53+
"autoprefixer": "^6.4.0",
54+
"babel-cli": "^6.11.4",
55+
"babel-core": "^6.11.4",
56+
"babel-eslint": "^6.1.2",
7957
"babel-loader": "^6.2.4",
8058
"babel-plugin-__coverage__": "^11.0.0",
8159
"babel-plugin-espower": "^2.3.1",
8260
"babel-plugin-react-intl": "^2.1.3",
83-
"babel-plugin-system-import-transformer": "^2.2.0",
61+
"babel-plugin-system-import-transformer": "^2.2.1",
8462
"babel-plugin-transform-decorators-legacy": "^1.3.4",
63+
"babel-plugin-transform-promise-to-bluebird": "^1.1.0",
8564
"babel-plugin-transform-react-constant-elements": "^6.9.1",
8665
"babel-plugin-transform-react-inline-elements": "^6.6.5",
87-
"babel-plugin-webpack-aliases": "^1.0.2",
88-
"babel-plugin-webpack-loaders": "^0.7.0",
66+
"babel-plugin-webpack-aliases": "^1.0.3",
67+
"babel-plugin-webpack-loaders": "^0.7.1",
8968
"babel-polyfill": "^6.9.1",
9069
"babel-preset-es2015": "^6.9.0",
9170
"babel-preset-es2015-loose": "^7.0.0",
92-
"babel-preset-es2015-webpack": "^6.4.1",
71+
"babel-preset-es2015-webpack": "^6.4.2",
9372
"babel-preset-react": "^6.11.1",
9473
"babel-preset-stage-0": "^6.5.0",
95-
"bcrypt": "^0.8.7",
96-
"carte-blanche": "^0.2.3",
97-
"chai": "^3.5.0",
74+
"babel-runtime": "^6.11.6",
75+
"bluebird": "^3.4.0",
76+
"chalk": "^1.1.3",
9877
"chokidar-cli": "^1.2.0",
9978
"cookie": "^0.3.1",
10079
"cookie-parser": "^1.4.3",
101-
"cross-env": "^1.0.8",
80+
"cors": "^2.7.1",
81+
"cross-env": "^2.0.0",
10282
"css-loader": "^0.23.1",
10383
"debug": "^2.2.0",
10484
"deep-freeze": "0.0.1",
105-
"dirty-chai": "^1.2.2",
106-
"enzyme": "^2.3.0",
107-
"esformatter": "^0.9.5",
108-
"esformatter-quotes": "^1.1.0",
109-
"eslint": "^3.0.1",
110-
"eslint-config-airbnb": "^9.0.1",
111-
"eslint-import-resolver-webpack": "^0.3.2",
112-
"eslint-plugin-import": "^1.10.2",
113-
"eslint-plugin-jsx-a11y": "^1.5.5",
114-
"eslint-plugin-react": "^5.1.1",
85+
"dotenv-safe": "^2.3.1",
11586
"exports-loader": "^0.6.3",
11687
"expose-loader": "^0.7.1",
117-
"extract-text-webpack-plugin": "^1.0.1",
88+
"express": "^4.13.4",
89+
"express-jwt": "^3.4.0",
90+
"extract-text-webpack-plugin": "^2.0.0-beta.3",
11891
"file-loader": "^0.9.0",
11992
"glob": "^7.0.5",
12093
"google-fonts-downloader": "0.0.3",
@@ -125,40 +98,70 @@
12598
"inject-loader": "^2.0.1",
12699
"intl": "^1.2.4",
127100
"intl-locales-supported": "^1.0.0",
128-
"isparta": "^4.0.0",
129-
"istanbul": "^0.4.4",
130-
"js-beautify": "^1.6.3",
131-
"jsdom": "^9.4.1",
101+
"isomorphic-fetch": "^2.2.1",
132102
"json-loader": "^0.5.4",
133103
"jsonwebtoken": "^7.0.1",
104+
"lodash": "^4.13.1",
134105
"mkdirp": "^0.5.1",
135-
"mocha": "^2.5.3",
136-
"mocha-junit-reporter": "^1.11.1",
137106
"npm-run-all": "^2.3.0",
138-
"nyc": "^6.6.1",
139107
"postcss-import": "^8.1.2",
140108
"postcss-loader": "^0.9.1",
141109
"postcss-modules-values": "^1.1.3",
142-
"power-assert": "^1.4.1",
143110
"precss": "^1.4.0",
144111
"pretty-error": "^2.0.0",
145112
"proxy-middleware": "^0.15.0",
113+
"react": "^15.2.0",
114+
"react-addons-css-transition-group": "^15.2.0",
146115
"react-addons-test-utils": "^15.2.0",
116+
"react-body-classname": "^1.0.1",
117+
"react-bootstrap": "^0.30.1",
118+
"react-dom": "^15.2.0",
147119
"react-gettext-parser": "^1.0.1",
120+
"react-helmet": "^3.1.0",
121+
"react-hot-loader": "^3.0.0-beta.2",
122+
"react-intl": "^2.1.3",
148123
"react-intl-loader": "^1.0.2",
149124
"react-intl-po": "^1.0.5",
125+
"react-intl-redux": "^0.1.0",
126+
"react-redux": "^4.4.5",
127+
"react-router": "^2.6.1",
128+
"react-router-bootstrap": "^0.23.1",
129+
"react-router-redux": "^4.0.5",
130+
"redux": "^3.3.1",
150131
"redux-mock-store": "^1.1.2",
132+
"redux-promise": "^0.5.3",
133+
"redux-thunk": "^2.1.0",
151134
"rucksack-css": "^0.8.6",
152-
"sinon": "^1.17.3",
153-
"sinon-chai": "^2.8.0",
154135
"style-loader": "^0.13.1",
155136
"to-object-by": "^1.0.3",
156137
"url-loader": "^0.5.7",
138+
"webpack-validator": "^2.2.2"
139+
},
140+
"devDependencies": {
141+
"chai": "^3.5.0",
142+
"dirty-chai": "^1.2.2",
143+
"enzyme": "^2.4.1",
144+
"esformatter": "^0.9.6",
145+
"esformatter-quotes": "^1.1.0",
146+
"eslint": "^3.2.2",
147+
"eslint-config-airbnb": "^10.0.0",
148+
"eslint-import-resolver-webpack": "^0.4.0",
149+
"eslint-plugin-import": "^1.10.2",
150+
"eslint-plugin-react": "^6.0.0",
151+
"power-assert": "^1.4.1",
152+
"isparta": "^4.0.0",
153+
"istanbul": "^0.4.4",
154+
"js-beautify": "^1.6.3",
155+
"jsdom": "^9.4.1",
156+
"mocha": "^2.5.3",
157+
"mocha-junit-reporter": "^1.11.1",
158+
"nyc": "^6.6.1",
159+
"sinon": "^1.17.3",
160+
"sinon-chai": "^2.8.0",
157161
"wallaby-webpack": "0.0.22",
158-
"webpack": "^2.1.0-beta.15",
162+
"webpack": "^2.1.0-beta.20",
159163
"webpack-cleanup-plugin": "^0.2.0",
160164
"webpack-dev-server": "^2.1.0-beta.0",
161-
"webpack-shell-plugin": "^0.4.2",
162-
"webpack-validator": "^2.2.2"
165+
"webpack-shell-plugin": "^0.4.2"
163166
}
164167
}

server/mocks/route.api.product.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const express = require('express')
2+
23
const router = express.Router()
34

45
router.get('/product', (req, res) => {

server/mocks/route.api.user.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const express = require('express')
22
const jwt = require('jsonwebtoken')
3-
const bcrypt = require('bcrypt')
3+
// const bcrypt = require('bcrypt')
44
const cookie = require('cookie')
5+
56
const router = express.Router()
67

78
/*
@@ -43,7 +44,8 @@ router.get('/users/signup', (req, res) => {
4344
}
4445

4546
const body = Object.assign({}, { name: 'markus', username: 'drathal', email: '[email protected]', password: 'p' }, req.body)
46-
const hash = bcrypt.hashSync(body.password.trim(), 10)
47+
// const hash = bcrypt.hashSync(body.password.trim(), 10)
48+
const hash = '1234'
4749
const user = {
4850
id: 1,
4951
name: body.name.trim(),

src/app/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './layout/theme.css'
44
const app = ({ children }) => React.Children.only(children)
55

66
app.propTypes = {
7-
children: PropTypes.element
7+
children: PropTypes.element.isRequired
88
}
99

1010
export default app

src/app/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import component from './app'
2+
23
export default component

src/app/layout/layout_dashboard/layout_dashboard.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const component = ({ children, params, intl: { formatMessage: fm } }) => <BodyCl
3131
<div className={`${style.layout} layout layout-dashboard`}>
3232
<Helmet title={fm(m.brandNameTwo)} />
3333
<TopNavBar style={style} brand={<Link to="/main">{fm(m.brandNameTwo)}</Link>}>
34-
<LanguageSelectorContainer key={'menuitem-1'} />
35-
<NavLogin key={'menuitem-2'} messages={{ login: fm(m.login), logout: fm(m.logout) }} />
34+
<LanguageSelectorContainer />
35+
<NavLogin messages={{ login: fm(m.login), logout: fm(m.logout) }} />
3636
</TopNavBar>
3737
<aside className={`${style.sidemenu} app-aside`}>
3838
<div className={`${style.sidemenuBody}`}>

src/app/layout/layout_dashboard/layout_dashboard.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import LayoutDashboard from './layout_dashboard'
66

77
const store = configureStore()({ intl: { locale: 'en' } })
88

9-
describe('component <LayoutMain />', () => {
9+
describe('component <LayoutDashboard />', () => {
1010
it('can render childs', () => {
1111
const wrapper = mount(<Provider store={store}><LayoutDashboard children="childs" /></Provider>)
1212
expect(wrapper.html().includes('childs')).to.equal(true)

src/app/layout/layout_main/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import layout_main from './layout_main'
22
import './favicon.ico'
3+
34
export default layout_main

src/app/layout/layout_main/layout_main.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ const m = defineMessages({
2626
}
2727
})
2828

29-
const component = ({ children, params, intl: { formatMessage: fm } }) => <div
30-
className={`${style.layout} layout layout-main`}>
29+
const component = ({ children, params, intl: { formatMessage: fm } }) => <div className={`${style.layout} layout layout-main`}>
3130
<Helmet title={fm(m.brandName)} />
3231
<TopNavBar brand={<Link to="/dashboard">{fm(m.brandName)}</Link>}>
3332
<NavLinks linkList={top_navigation_links(params)} />
34-
<LanguageSelectorContainer key={'menuitem-1'} />
35-
<NavLogin key={'menuitem-2'} messages={{ login: fm(m.login), logout: fm(m.logout) }} />
33+
<LanguageSelectorContainer />
34+
<NavLogin messages={{ login: fm(m.login), logout: fm(m.logout) }} />
3635
</TopNavBar>
3736
<div className={`${style.container} app-content`}>
3837
<div className={`${style.containerBody} app-content-body`}>

src/app/layout/route.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1+
import ProductRoute from '../products/route'
2+
import NotFoundRoute from '../notFound/route'
3+
4+
// this will fix hot reloading - on a dynamic route (only development)
5+
if (process.env.NODE_ENV === 'development') {
6+
require('./layout_main/index.js').default // eslint-disable-line
7+
require('./layout_dashboard/index.js').default // eslint-disable-line
8+
}
9+
110
export default {
211
path: ':layout',
312
getComponent(location, cb) {
413
require.ensure([], (require) => cb(null, require(`./layout_${location.params.layout}/index.js`).default), 'layout')
5-
// this will fix hot reloading - on a dynamic route (only development)
6-
if (process.env.NODE_ENV === 'development') {
7-
require('./layout_main/index.js').default // eslint-disable-line
8-
require('./layout_dashboard/index.js').default // eslint-disable-line
9-
}
1014
},
1115
indexRoute: {
1216
onEnter: (nextState, replace) => {
1317
replace(`/${nextState.params.layout}/products`)
1418
}
1519
},
20+
childRoutes: [
21+
ProductRoute,
22+
NotFoundRoute
23+
]
24+
}
25+
26+
/*
1627
getChildRoutes(location, cb) {
1728
require.ensure([], (require) => cb(null, [
1829
require('../products/route').default,
1930
require('../notFound/route').default]
2031
), 'products-notFound-route')
2132
}
22-
}
33+
*/

src/app/products/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import products from './products'
2+
23
export default products

0 commit comments

Comments
 (0)