-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve hot api for production mode - error reporting and babel …
…plugin
- Loading branch information
Showing
9 changed files
with
92 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
if (module.hot) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
var hot = require('./index').hot; | ||
var cache = require.cache; | ||
if (module.hot) { | ||
var cache = require.cache; | ||
|
||
if (!module.parents || module.parents.length === 0) { | ||
throw new Error( | ||
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' + | ||
if (!module.parents || module.parents.length === 0) { | ||
throw new Error( | ||
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' + | ||
'Please use `import {hot} from "react-hot-loader"` instead' | ||
); | ||
} | ||
// access parent | ||
var parent = cache[module.parents[0]]; | ||
if (!parent) { | ||
throw new Error( | ||
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' + | ||
); | ||
} | ||
// access parent | ||
var parent = cache[module.parents[0]]; | ||
if (!parent) { | ||
throw new Error( | ||
'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' + | ||
'Please use `import {hot} from "react-hot-loader"` instead' | ||
); | ||
); | ||
} | ||
// remove self from a cache | ||
delete cache[module.id]; | ||
} | ||
// remove self from a cache | ||
delete cache[module.id]; | ||
// setup hot for caller | ||
exports.hot = hot(parent); | ||
} else { | ||
// prod mode | ||
exports.hot = function(a) { | ||
exports.hot = function (a) { | ||
return a; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
export default () => Component => Component; | ||
import React from 'react'; | ||
import AppContainer from './AppContainer.prod'; | ||
|
||
const hot = () => { | ||
if (hot.shouldWrapWithAppContainer) { | ||
return Component => props => ( | ||
<AppContainer> | ||
<Component {...props} /> | ||
</AppContainer> | ||
); | ||
} | ||
return Component => Component; | ||
}; | ||
|
||
hot.shouldWrapWithAppContainer = false; | ||
|
||
export default hot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters