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.12.2 to 4.12.3

13

CHANGELOG.md

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

<a name="4.12.3"></a>
## [4.12.3](https://github.com/gaearon/react-hot-loader/compare/v4.12.2...v4.12.3) (2019-07-04)
### Bug Fixes
* babel plugin should use only extrernals hooks, fixes [#1285](https://github.com/gaearon/react-hot-loader/issues/1285) ([c435eaa](https://github.com/gaearon/react-hot-loader/commit/c435eaa))
* make type comparison stronger ([1b9f2da](https://github.com/gaearon/react-hot-loader/commit/1b9f2da))
* prevent different typeof of components to be merged ([357249c](https://github.com/gaearon/react-hot-loader/commit/357249c))
* regression of registered type comparison, fixes [#1284](https://github.com/gaearon/react-hot-loader/issues/1284) ([49851be](https://github.com/gaearon/react-hot-loader/commit/49851be))
<a name="4.12.2"></a>

@@ -7,0 +20,0 @@ ## [4.12.2](https://github.com/gaearon/react-hot-loader/compare/v4.12.1...v4.12.2) (2019-07-03)

93

dist/babel.development.js

@@ -23,2 +23,3 @@ 'use strict';

var registrationsByProgramPath = new Map();
function createRegistration(programPath, persistentID) {

@@ -201,3 +202,11 @@ var handle = programPath.scope.generateUidIdentifier('c');

function getHookCallsSignature(functionNode) {
function getCalleeName(callee) {
if (callee.type === 'MemberExpression' && callee.object.type === 'Identifier') {
return callee.object.name;
}
return callee.name;
}
function getHookCallsSignature(functionNode, scope) {
var fnHookCalls = hookCalls.get(functionNode);

@@ -219,3 +228,3 @@ if (fnHookCalls === undefined) {

function createArgumentsForSignature(node, signature) {
function createArgumentsForSignature(node, signature, scope) {
var key = signature.key,

@@ -225,4 +234,7 @@ customHooks = signature.customHooks;

var args = [node, t.stringLiteral(key)];
if (customHooks.length > 0) {
args.push(t.arrowFunctionExpression([], t.arrayExpression(customHooks)));
var hooksInScope = customHooks.filter(function (call) {
return scope.hasBinding(getCalleeName(call));
});
if (hooksInScope.length > 0) {
args.push(t.arrowFunctionExpression([], t.arrayExpression(hooksInScope)));
}

@@ -257,2 +269,3 @@ return args;

var fnScope = path.scope.getFunctionParent();
if (fnScope === null) {

@@ -267,2 +280,3 @@ return;

}
var hookCallsForFn = hookCalls.get(fnNode);

@@ -390,3 +404,3 @@ var key = '';

}
var signature = getHookCallsSignature(node);
var signature = getHookCallsSignature(node, path.scope);
if (signature === null) {

@@ -417,3 +431,3 @@ return;

insertAfterPath.insertAfter(t.expressionStatement(t.callExpression(t.identifier(SIGNATURE), createArgumentsForSignature(id, signature))));
insertAfterPath.insertAfter(t.expressionStatement(t.callExpression(t.identifier(SIGNATURE), createArgumentsForSignature(id, signature, insertAfterPath.scope))));
}

@@ -424,3 +438,3 @@ },

var node = path.node;
var signature = getHookCallsSignature(node);
var signature = getHookCallsSignature(node, path.scope);
if (signature === null) {

@@ -454,7 +468,7 @@ return;

// we don't mess up the inferred 'Foo' function name.
insertAfterPath.insertAfter(t.expressionStatement(t.callExpression(t.identifier(SIGNATURE), createArgumentsForSignature(path.parent.id, signature))));
insertAfterPath.insertAfter(t.expressionStatement(t.callExpression(t.identifier(SIGNATURE), createArgumentsForSignature(path.parent.id, signature, insertAfterPath.scope))));
// Result: let Foo = () => {}; __signature(Foo, ...);
} else {
// let Foo = hoc(() => {})
path.replaceWith(t.callExpression(t.identifier(SIGNATURE), createArgumentsForSignature(node, signature)));
path.replaceWith(t.callExpression(t.identifier(SIGNATURE), createArgumentsForSignature(node, signature, path.scope)));
// Result: let Foo = hoc(__signature(() => {}, ...))

@@ -464,63 +478,2 @@ }

},
VariableDeclaration: function VariableDeclaration(path) {
return;
var node = path.node;
var programPath = void 0;
var insertAfterPath = void 0;
switch (path.parent.type) {
case 'Program':
insertAfterPath = path;
programPath = path.parentPath;
break;
case 'ExportNamedDeclaration':
insertAfterPath = path.parentPath;
programPath = insertAfterPath.parentPath;
break;
case 'ExportDefaultDeclaration':
insertAfterPath = path.parentPath;
programPath = insertAfterPath.parentPath;
break;
default:
return;
}
// Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
if (seenForRegistration.has(node)) {
return;
}
seenForRegistration.add(node);
// Don't mutate the tree above this point.
var declPaths = path.get('declarations');
if (declPaths.length !== 1) {
return;
}
var declPath = declPaths[0];
var inferredName = declPath.node.id.name;
findInnerComponents(inferredName, declPath, function (persistentID, targetExpr, targetPath) {
if (targetPath === null) {
// For case like:
// export const Something = hoc(Foo)
// we don't want to wrap Foo inside the call.
// Instead we assume it's registered at definition.
return;
}
var handle = createRegistration(programPath, persistentID);
if ((targetExpr.type === 'ArrowFunctionExpression' || targetExpr.type === 'FunctionExpression') && targetPath.parent.type === 'VariableDeclarator') {
// Special case when a function would get an inferred name:
// let Foo = () => {}
// let Foo = function() {}
// We'll register it on next line so that
// we don't mess up the inferred 'Foo' function name.
insertAfterPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', handle, declPath.node.id)));
// Result: let Foo = () => {}; _c1 = Foo;
} else {
// let Foo = hoc(() => {})
targetPath.replaceWith(t.assignmentExpression('=', handle, targetExpr));
// Result: let Foo = _c1 = hoc(() => {})
}
});
},
Program: {

@@ -527,0 +480,0 @@ enter: function enter(path) {

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

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

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