Skip to content

Commit

Permalink
fix: handle async loading of patch (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Dec 28, 2017
1 parent 378b677 commit af8bd4b
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 43 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"prebuild": "rm -rf packages/*/lib",
"precommit": "lint-staged",
"test": "yarn test:es2015 && yarn test:modern",
"test:es2015": "BABEL_TARGET=es2015 jest",
"test:modern": "BABEL_TARGET=modern jest"
"test:es2015": "BABEL_TARGET=es2015 jest --no-cache",
"test:modern": "BABEL_TARGET=modern jest --no-cache"
},
"lint-staged": {
"*.{js,md,ts,json}": [
Expand Down
8 changes: 5 additions & 3 deletions packages/react-hot-loader/src/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ module.exports = function plugin(args) {
const buildTagger = template(
`
var UNUSED = (function () {
if (typeof __REACT_HOT_LOADER__ === 'undefined') {
return;
var global = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
var __REACT_HOT_LOADER__ = global.__REACT_HOT_LOADER__ || require('react-hot-loader/patch').default;
if(!__REACT_HOT_LOADER__){
return;
}
REGISTRATIONS
})();
`,
Expand Down
1 change: 1 addition & 0 deletions packages/react-hot-loader/src/patch.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ if (typeof global.__REACT_HOT_LOADER__ === 'undefined') {
React.Children.only = patchedChildOnly
global.__REACT_HOT_LOADER__ = hooks
}
export default hooks
Loading

0 comments on commit af8bd4b

Please sign in to comment.