Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hot-loader

Package Overview
Dependencies
Maintainers
6
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hot-loader - npm Package Compare versions

Comparing version 4.8.8 to 4.9.0

16

CHANGELOG.md

@@ -5,2 +5,18 @@ # Change Log

<a name="4.9.0"></a>
# [4.9.0](https://github.com/gaearon/react-hot-loader/compare/v4.8.8...v4.9.0) (2019-06-02)
### Bug Fixes
* false positive hot merge for forwardRef and Memo components, fixes [#1257](https://github.com/gaearon/react-hot-loader/issues/1257) ([dbf1047](https://github.com/gaearon/react-hot-loader/commit/dbf1047))
* improve hot api for production mode - error reporting and babel plugin ([6b29911](https://github.com/gaearon/react-hot-loader/commit/6b29911))
### Features
* support hooks update on HMR, fixes [#1256](https://github.com/gaearon/react-hot-loader/issues/1256) ([7ab076c](https://github.com/gaearon/react-hot-loader/commit/7ab076c))
<a name="4.8.8"></a>

@@ -7,0 +23,0 @@ ## [4.8.8](https://github.com/gaearon/react-hot-loader/compare/v4.8.7...v4.8.8) (2019-05-23)

2

dist/babel.production.min.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RHLPackage="react-hot-loader";function isImportedFromRHL(e,t){var a=e.scope.getBinding(t),r=a&&a.path.node.type;return("ImportSpecifier"===r||"ImportNamespaceSpecifier"===r)&&a.path.parent.source.value===RHLPackage}function getRHLContext(e){for(var t=[],a=e.ast.program.body,r=0;r<a.length;r++){var n=a[r],l=n.source,o=n.specifiers;if("ImportDeclaration"===n.type&&l.value===RHLPackage)for(var i=0;i<o.length;i++){var p=o[i];if("ImportNamespaceSpecifier"===p.type)t.push({kind:"namespace",local:p.local.name});else if("ImportSpecifier"===p.type){var c={kind:"named",local:p.local.name};"hot"===p.imported.name&&t.push(c)}}}return t.length?t:null}function plugin(){return{pre:function(){this.rhlContext=getRHLContext(this.file),this.rhlContext||(this.cancel=!0)},visitor:{CallExpression:function(e){if(!this.cancel)for(var t=0;t<this.rhlContext.length;t++){var a=this.rhlContext[t];if("named"===a.kind){if(e.node.callee.name===a.local&&isImportedFromRHL(e,a.local)&&"CallExpression"===e.parent.type&&e.parent.arguments[0]&&"Identifier"===e.parent.arguments[0].type){e.parentPath.replaceWith(e.parent.arguments[0]);break}}else if("namespace"===a.kind&&e.node.callee.callee&&"MemberExpression"===e.node.callee.callee.type&&"Identifier"===e.node.callee.callee.object.type&&e.node.callee.callee.object.name===a.local&&isImportedFromRHL(e,a.local)&&"Identifier"===e.node.callee.callee.property.type&&"hot"===e.node.callee.callee.property.name&&e.node.arguments[0]&&"Identifier"===e.node.arguments[0].type){e.replaceWith(e.node.arguments[0]);break}}}}}}exports.default=plugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RHLPackage="react-hot-loader",RHLRootPackage="react-hot-loader/root",RHLPackages=[RHLPackage,RHLRootPackage];function isImportedFromRHL(e,a){var t=e.scope.getBinding(a),r=t&&t.path.node.type;if("ImportSpecifier"===r||"ImportNamespaceSpecifier"===r){var n=t.path.parent;return RHLPackages.includes(n.source.value)}return!1}function getRHLContext(e){for(var a=[],t=e.ast.program.body,r=0;r<t.length;r++){var n=t[r],l=n.source,o=n.specifiers;if("ImportDeclaration"===n.type&&RHLPackages.includes(l.value))for(var i=0;i<o.length;i++){var c=o[i];if("ImportNamespaceSpecifier"===c.type)a.push({kind:"namespace",local:c.local.name});else if("ImportSpecifier"===c.type){var p={kind:"named",local:c.local.name};"hot"===c.imported.name&&a.push(p)}}}return a.length?a:null}function plugin(){return{pre:function(){this.rhlContext=getRHLContext(this.file),this.rhlContext||(this.cancel=!0)},visitor:{CallExpression:function(e){if(!this.cancel)for(var a=0;a<this.rhlContext.length;a++){var t=this.rhlContext[a];if("named"===t.kind){if(e.node.callee.name===t.local&&isImportedFromRHL(e,t.local)&&"CallExpression"===e.parent.type&&e.parent.arguments[0]&&"Identifier"===e.parent.arguments[0].type){e.parentPath.replaceWith(e.parent.arguments[0]);break}if(e.node.callee.name===t.local&&isImportedFromRHL(e,t.local)&&"CallExpression"===e.type&&e.node.arguments[0]&&"Identifier"===e.node.arguments[0].type){e.replaceWith(e.node.arguments[0]);break}}else if("namespace"===t.kind&&e.node.callee.callee&&"MemberExpression"===e.node.callee.callee.type&&"Identifier"===e.node.callee.callee.object.type&&e.node.callee.callee.object.name===t.local&&isImportedFromRHL(e,t.local)&&"Identifier"===e.node.callee.callee.property.type&&"hot"===e.node.callee.callee.property.name&&e.node.arguments[0]&&"Identifier"===e.node.arguments[0].type){e.replaceWith(e.node.arguments[0]);break}}}}}}exports.default=plugin;

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react"));function AppContainer(e){return React.Children.only(e.children)}var hot_prod=function(){return function(e){return e}},areComponentsEqual=function(e,n){return e===n},setConfig=function(){},cold=function(e){return e},configureComponent=function(){};exports.AppContainer=AppContainer,exports.hot=hot_prod,exports.areComponentsEqual=areComponentsEqual,exports.setConfig=setConfig,exports.cold=cold,exports.configureComponent=configureComponent;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react"));function AppContainer(e){return AppContainer.warnAboutHMRDisabled&&(AppContainer.warnAboutHMRDisabled=!0,console.error("React-Hot-Loader: misconfiguration detected, using production version in not production environment."),console.error("React-Hot-Loader: Hot Module Replacement is not enabled.")),React.Children.only(e.children)}AppContainer.warnAboutHMRDisabled=!1;var hot=function e(){return e.shouldWrapWithAppContainer?function(e){return function(n){return React.createElement(AppContainer,null,React.createElement(e,n))}}:function(e){return e}};hot.shouldWrapWithAppContainer=!1;var areComponentsEqual=function(e,n){return e===n},setConfig=function(){},cold=function(e){return e},configureComponent=function(){};exports.AppContainer=AppContainer,exports.hot=hot,exports.areComponentsEqual=areComponentsEqual,exports.setConfig=setConfig,exports.cold=cold,exports.configureComponent=configureComponent;

@@ -114,2 +114,7 @@ import * as React from 'react';

/**
* enables or disables hooks treatment
*/
reloadHooks: boolean;
/**
* default value for AppContainer errorOverlay

@@ -116,0 +121,0 @@ */

@@ -11,4 +11,5 @@ 'use strict';

} else if (!module.hot) {
console.error('React-Hot-Loader: Hot Module Replacement is not enabled');
module.exports = require('./dist/react-hot-loader.production.min.js');
module.exports.AppContainer.warnAboutHMRDisabled = true;
module.exports.hot.shouldWrapWithAppContainer = true;
} else {

@@ -15,0 +16,0 @@ var evalAllowed = false;

{
"name": "react-hot-loader",
"version": "4.8.8",
"version": "4.9.0",
"description": "Tweak React components in real time.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -56,2 +56,28 @@ # React Hot Loader

### Hook support
Hooks would be auto updated on HMR if they _should_ be.
There is only one condition for it - a non zero dependencies list.
```js
❄️ useState(initialState); // will never updated (preserve state)
❄️ useEffect(effect); // no need to update, updated on every render
❄️ useEffect(effect, []); // "on mount" hook. "Not changing the past"
🔥 useEffect(effect, [anyDep]); // would be updated
🔥 useEffect(effect, ["hot"]); // the simplest way to make hook reloadable
```
**To disable hooks reloading** - set configuration option:
```js
import { setConfig } from 'react-hot-loader';
setConfig({
reloadHooks: false,
});
```
With this option set **all** `useEffects`, `useCallbacks` and `useMemo` would be updated on Hot Module Replacement.
## React-🔥-Dom

@@ -58,0 +84,0 @@

@@ -1,21 +0,23 @@

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

@@ -25,5 +27,5 @@ exports.hot = hot(parent);

// prod mode
exports.hot = function(a) {
exports.hot = function (a) {
return a;
};
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc