Skip to content

Commit

Permalink
Remove explicit react-hot-loader logic
Browse files Browse the repository at this point in the history
We should not support it since by default it's an aggressive and flaky
HMR handler. Where it says it can handle more file changes than it
actually can. Developers usually learn not to trust it and refresh
manually.

It also breaks JS error handling in arrow functions:

gaearon/react-proxy#76

After this change, HMR is still properly configured, including the
module.hot api and client/server communications. By default JS changes
refresh and CSS changes appear without refresh.

For the future, we should monitor the progress of this PR:

facebook/create-react-app#2304
  • Loading branch information
eirikurn committed Nov 16, 2017
1 parent 6586f61 commit 7fce554
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
5 changes: 0 additions & 5 deletions examples/admin/src/middleware/hot.js

This file was deleted.

5 changes: 0 additions & 5 deletions shared/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ const babel = target =>
'react',
['es2015', { modules: target === 'es2015' ? false : 'commonjs' }],
],
env: {
development: {
plugins: [require.resolve('react-hot-loader/babel')],
},
},
}).on('error', function(error) {
// only log babel errors once.
if (target === 'es2015') {
Expand Down
1 change: 1 addition & 0 deletions utilities/neutrino-preset-tux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"neutrino-middleware-banner": "^6.1.5",
"neutrino-middleware-compile-loader": "^6.1.5",
"neutrino-middleware-env": "^6.1.5",
"neutrino-middleware-hot": "^6.1.5",
"neutrino-preset-react": "6.1.5",
"react-dev-utils": "~4.0.1",
"react-error-overlay": "~2.0.1",
Expand Down
8 changes: 7 additions & 1 deletion utilities/neutrino-preset-tux/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Neutrino } from 'neutrino'
import merge from 'deepmerge'
import react from 'neutrino-preset-react'
import hot from 'neutrino-middleware-hot'
import {
env,
ssr,
Expand Down Expand Up @@ -46,7 +47,12 @@ export default (neutrino: Neutrino, opts: Partial<Options> = {}) => {
: neutrino.options.browserEntry

// Build on top of the offical react preset (overriding open functionality).
neutrino.use(react, merge<any>(options, { devServer: { open: false } }))
// Skip react-hot-loader for now while enabling other HMR functionality.
neutrino.use(
react,
merge<any>(options, { devServer: { open: false }, hot: false })
)
neutrino.use(hot)

// Switch to custom html plugin.
neutrino.use(html, options.html)
Expand Down

0 comments on commit 7fce554

Please sign in to comment.