Skip to content

Commit

Permalink
Drop UNRELIABLE React Hot Loader in favor of Webpack HMR
Browse files Browse the repository at this point in the history
  • Loading branch information
larixer committed Nov 4, 2016
1 parent 30fbc42 commit 4b0431d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"plugins": [
"transform-runtime",
"transform-decorators-legacy",
"transform-class-properties",
"react-hot-loader/babel"
"transform-class-properties"
],
"only": ["*.js", "*.jsx"]
}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Apollo Universal Starter Kit is an boilerplate for [Universal] web app development built on top of [Apollo],
> [GraphQL], [React], [Express] with SQL storage support and [Twitter Bootstrap] integration.
> Hot Code Reload of backend & frontend using [Webpack] and [React Hot Loader 3] to reflect your changes instantly
> Hot Code Reload of backend & frontend using [Webpack] and Hot Module Replacement to reflect your changes instantly
> and help you stay productive.
## Hot Code Reload demo
Expand Down Expand Up @@ -68,7 +68,7 @@ embedding non-js files and CSS stylesheets into the code, hot code reload, etc.
Hot Code Reload for backend is done using [Webpack]. When Webpack prepares hot patches on the filesystem,
SIGUSR2 signal is sent to Node.js app and embedded Webpack Hot Module Runtime reacts to this signal and
applies patches to running modules from filesystem. Hot code reload for frontend is using Webpack Dev Server
and [React Hot Loader 3] to apply patches to frontend code. Hot patches for React components are applied on the
and Hot Module Replacement to apply patches to frontend code. Hot patches for React components are applied on the
frontend and backend at the same time, so React should not complain about differences in client and server code.

- Server Side Rendering with Apollo Redux Store sync
Expand Down Expand Up @@ -117,7 +117,6 @@ Copyright © 2016 [SysGears INC]. This source code is licensed under the [MIT] l
[Twitter Bootstrap]: http://getbootstrap.com
[Webpack]: http://webpack.github.io
[Babel]: http://babeljs.io
[React Hot Loader 3]: https://github.com/gaearon/react-hot-loader
[Aphrodite CSS]: https://github.com/Khan/aphrodite
[Knex]: http://knexjs.org
[Heroku]: https://heroku.com
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"react-apollo": "^0.5.8",
"react-bootstrap": "^0.30.3",
"react-dom": "^15.3.2",
"react-hot-loader": "^3.0.0-beta.5",
"react-router": "^3.0.0",
"source-map-support": "^0.4.2",
"sqlite3": "^3.1.4",
Expand Down
13 changes: 6 additions & 7 deletions src/client/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@ import log from '../log';
const root = document.getElementById('content');

if (__DEV__) {
const AppContainer = require('react-hot-loader').AppContainer;
let frontendReloadCount = 0;

render((
<AppContainer>
<Main router={router}/>
</AppContainer>
<Main key={frontendReloadCount}/>
), root);

if (module.hot) {
module.hot.accept();

module.hot.accept('./main', () => {
try {
log.debug("Reloading front-end");
frontendReloadCount = (frontendReloadCount || 0) + 1;

const Main = require('./main').default;

render((
<AppContainer>
<Main/>
</AppContainer>
<Main key={frontendReloadCount}/>
), root);
} catch (err) {
log(err.stack);
Expand Down
1 change: 0 additions & 1 deletion tools/webpack.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ function startClient() {
if (__DEV__) {
clientConfig.entry.bundle.push('webpack/hot/dev-server',
`webpack-dev-server/client?http://localhost:${process.env.npm_package_app_webpackDevPort}/`);
clientConfig.entry.bundle.unshift('react-hot-loader/patch');
clientConfig.plugins.push(new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin());
Expand Down

0 comments on commit 4b0431d

Please sign in to comment.