Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-react-constant-elements

Package Overview
Dependencies
Maintainers
6
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-react-constant-elements - npm Package Compare versions

Comparing version 7.0.0-beta.42 to 7.0.0-beta.43

72

lib/index.js
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
function _helperPluginUtils() {
const data = require("@babel/helper-plugin-utils");
var _core = require("@babel/core");
_helperPluginUtils = function () {
return data;
};
var _helperAnnotateAsPure = _interopRequireDefault(require("@babel/helper-annotate-as-pure"));
return data;
}
function _core() {
const data = require("@babel/core");
_core = function () {
return data;
};
return data;
}
function _helperAnnotateAsPure() {
const data = _interopRequireDefault(require("@babel/helper-annotate-as-pure"));
_helperAnnotateAsPure = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)(function (api, options) {
var _default = (0, _helperPluginUtils().declare)((api, options) => {
api.assertVersion(7);
var allowMutablePropsOnTags = options.allowMutablePropsOnTags;
const {
allowMutablePropsOnTags
} = options;

@@ -22,6 +50,6 @@ if (allowMutablePropsOnTags != null && !Array.isArray(allowMutablePropsOnTags)) {

var HOISTED = new WeakSet();
var immutabilityVisitor = {
enter: function enter(path, state) {
var stop = function stop() {
const HOISTED = new WeakSet();
const immutabilityVisitor = {
enter(path, state) {
const stop = () => {
state.isImmutable = false;

@@ -50,7 +78,9 @@ path.stop();

if (path.isPure()) {
var expressionResult = path.evaluate();
const expressionResult = path.evaluate();
if (expressionResult.confident) {
var value = expressionResult.value;
var isMutable = !state.mutablePropsAllowed && value && typeof value === "object" || typeof value === "function";
const {
value
} = expressionResult;
const isMutable = !state.mutablePropsAllowed && value && typeof value === "object" || typeof value === "function";

@@ -61,3 +91,3 @@ if (!isMutable) {

}
} else if (_core.types.isIdentifier(expressionResult.deopt)) {
} else if (_core().types.isIdentifier(expressionResult.deopt)) {
return;

@@ -70,9 +100,10 @@ }

}
};
return {
visitor: {
JSXElement: function JSXElement(path) {
JSXElement(path) {
if (HOISTED.has(path.node)) return;
HOISTED.add(path.node);
var state = {
const state = {
isImmutable: true

@@ -82,3 +113,3 @@ };

if (allowMutablePropsOnTags != null) {
var namePath = path.get("openingElement.name");
let namePath = path.get("openingElement.name");

@@ -89,3 +120,3 @@ while (namePath.isJSXMemberExpression()) {

var elementName = namePath.node.name;
const elementName = namePath.node.name;
state.mutablePropsAllowed = allowMutablePropsOnTags.indexOf(elementName) > -1;

@@ -97,9 +128,10 @@ }

if (state.isImmutable) {
var hoisted = path.hoist();
const hoisted = path.hoist();
if (hoisted) {
(0, _helperAnnotateAsPure.default)(hoisted);
(0, _helperAnnotateAsPure().default)(hoisted);
}
}
}
}

@@ -106,0 +138,0 @@ };

{
"name": "@babel/plugin-transform-react-constant-elements",
"version": "7.0.0-beta.42",
"version": "7.0.0-beta.43",
"description": "Treat React JSX elements as value types and hoist them to the highest scope",

@@ -12,12 +12,12 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-constant-elements",

"dependencies": {
"@babel/helper-annotate-as-pure": "7.0.0-beta.42",
"@babel/helper-plugin-utils": "7.0.0-beta.42"
"@babel/helper-annotate-as-pure": "7.0.0-beta.43",
"@babel/helper-plugin-utils": "7.0.0-beta.43"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.42"
"@babel/core": "7.0.0-beta.43"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.42",
"@babel/helper-plugin-test-runner": "7.0.0-beta.42"
"@babel/core": "7.0.0-beta.43",
"@babel/helper-plugin-test-runner": "7.0.0-beta.43"
}
}
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