Skip to content
Permalink
Browse files

Improved hot-reloading support for hooks

  • Loading branch information...
tannerlinsley committed Apr 22, 2019
1 parent 576bec0 commit 988c741f8c4f477534b20766ad18f1744f9e14e3
@@ -2,6 +2,7 @@

- `react-static-plugin-mdx`: Bump webpack loader version to v1
- `react-static`: Dev server is only required once
- `react-static`: Hot reloading stability has been improved to better support hooks like React.useState and React.useEffect

# 7.0.9

@@ -73,7 +73,6 @@ module.exports = (api, { external, hot, node, modules } = {}) => {
r('babel-plugin-transform-react-remove-prop-types'),
]) ||
[]),
...((hot && [r('react-hot-loader/babel')]) || []),
r('@babel/plugin-transform-runtime'),
r('babel-plugin-macros'),
r('@babel/plugin-transform-destructuring'),
@@ -41,7 +41,6 @@
"@babel/preset-stage-0": "^7.0.0",
"@babel/register": "^7.4.0",
"@babel/runtime": "^7.4.3",
"@hot-loader/react-dom": "^16.8.6",
"@reach/router": "^1.2.1",
"autoprefixer": "^9.5.1",
"axios": "^0.18.0",
@@ -179,7 +179,7 @@ export function buildConfig(state, config = {}) {
inlineCss: config.inlineCss || false,
babelExcludes: config.babelExcludes || [],
devServer: {
host: 'http://localhost',
host: 'localhost',
port: 3000,
...(config.devServer || {}),
},
@@ -52,6 +52,7 @@ export default function({ config, stage }) {
highlightCode: true,
},
},
'react-hot-loader/webpack',
],
}
}
@@ -5,7 +5,6 @@ export default function({ config }) {
test: /\.(js|jsx|mjs)$/,
exclude: [/@babel(?:\/|\\{1,2})runtime/, ...(config.babelExcludes || [])],
use: [
// 'thread-loader',
{
loader: 'babel-loader',
options: {
@@ -17,6 +16,7 @@ export default function({ config }) {
sourceMaps: false,
},
},
'react-hot-loader/webpack',
],
}
}
@@ -72,7 +72,6 @@ async function runExpressServer(state) {
const devCompiler = webpack(devConfig)

const devServerConfig = {
hot: true,
contentBase: [state.config.paths.PUBLIC, state.config.paths.DIST],
publicPath: '/',
historyApiFallback: true,
@@ -82,6 +81,7 @@ async function runExpressServer(state) {
stats: 'errors-only',
noInfo: true,
...state.config.devServer,
hot: true,
watchOptions: {
...(state.config.devServer
? state.config.devServer.watchOptions || {}
@@ -22,6 +22,7 @@ export default function({ config }) {
},
context: path.resolve(__dirname, '../../../node_modules'),
entry: [
'react-hot-loader/patch',
'webpack/hot/only-dev-server',
...(config.disableRuntime
? []
@@ -52,7 +53,7 @@ export default function({ config }) {
extensions: ['.wasm', '.mjs', '.js', '.json', '.jsx'],
alias: {
react: resolveFrom(config.paths.NODE_MODULES, 'react'),
'react-dom': resolveFrom(__dirname, '@hot-loader/react-dom'),
'react-dom': resolveFrom(config.paths.NODE_MODULES, 'react-dom'),
},
},
plugins: [
@@ -65,7 +66,6 @@ export default function({ config }) {
new webpack.NamedModulesPlugin(),
new CaseSensitivePathsPlugin(),
new ExtractCssChunks({ filename: '[name].css' }), // never hash dev code
// new WebpackDashboard(),
],
devtool: 'cheap-module-source-map',
}
@@ -1,5 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'

// Your top level component
import App from './App'
@@ -16,7 +17,12 @@ if (typeof document !== 'undefined') {
: ReactDOM.render

const render = Comp => {
renderMethod(<Comp />, target)
renderMethod(
<AppContainer>
<Comp />
</AppContainer>,
target
)
}

// Render!
@@ -1,5 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'

// Your top level component
import App from './App'
@@ -16,7 +17,12 @@ if (typeof document !== 'undefined') {
: ReactDOM.render

const render = Comp => {
renderMethod(<Comp />, target)
renderMethod(
<AppContainer>
<Comp />
</AppContainer>,
target
)
}

// Render!
@@ -1,5 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'

// Your top level component
import App from './App'
@@ -16,7 +17,12 @@ if (typeof document !== 'undefined') {
: ReactDOM.render

const render = (Comp: Function) => {
renderMethod(<Comp />, target)
renderMethod(
<AppContainer>
<Comp />
</AppContainer>,
target
)
}

// Render!
@@ -1141,16 +1141,6 @@
resolved "https://registry.yarnpkg.com/@emotion/utils/-/utils-0.11.1.tgz#8529b7412a6eb4b48bdf6e720cc1b8e6e1e17628"
integrity sha512-8M3VN0hetwhsJ8dH8VkVy7xo5/1VoBsDOk/T4SJOeXwTO1c4uIqVNx2qyecLFnnUWD5vvUqHQ1gASSeUN6zcTg==

"@hot-loader/react-dom@^16.8.6":
version "16.8.6"
resolved "https://registry.yarnpkg.com/@hot-loader/react-dom/-/react-dom-16.8.6.tgz#7923ba27db1563a7cc48d4e0b2879a140df461ea"
integrity sha512-+JHIYh33FVglJYZAUtRjfT5qZoT2mueJGNzU5weS2CVw26BgbxGKSujlJhO85BaRbg8sqNWyW1hYBILgK3ZCgA==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.13.6"

"@jest/console@^24.7.1":
version "24.7.1"
resolved "https://registry.yarnpkg.com/@jest/console/-/console-24.7.1.tgz#32a9e42535a97aedfe037e725bd67e954b459545"
@@ -11852,7 +11842,7 @@ rgba-regex@^1.0.0:
resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3"
integrity sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=

rimraf@2, rimraf@2.6.3, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@~2.6.2:
rimraf@2, rimraf@2.6.3, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3:
version "2.6.3"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==

0 comments on commit 988c741

Please sign in to comment.
You can’t perform that action at this time.