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

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

Package Overview
Dependencies
Maintainers
5
Versions
88
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.46 to 7.0.0-beta.47

36

lib/index.js

@@ -9,3 +9,3 @@ "use strict";

function _helperPluginUtils() {
var data = require("@babel/helper-plugin-utils");
const data = require("@babel/helper-plugin-utils");

@@ -20,3 +20,3 @@ _helperPluginUtils = function _helperPluginUtils() {

function _core() {
var data = require("@babel/core");
const data = require("@babel/core");

@@ -31,3 +31,3 @@ _core = function _core() {

function _helperAnnotateAsPure() {
var data = _interopRequireDefault(require("@babel/helper-annotate-as-pure"));
const data = _interopRequireDefault(require("@babel/helper-annotate-as-pure"));

@@ -43,5 +43,5 @@ _helperAnnotateAsPure = function _helperAnnotateAsPure() {

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.allowMutablePropsOnTags;

@@ -52,6 +52,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;

@@ -80,7 +80,7 @@ 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.value;
const isMutable = !state.mutablePropsAllowed && value && typeof value === "object" || typeof value === "function";

@@ -99,9 +99,10 @@ if (!isMutable) {

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

@@ -111,3 +112,3 @@ };

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

@@ -118,3 +119,3 @@ while (namePath.isJSXMemberExpression()) {

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

@@ -126,3 +127,3 @@ }

if (state.isImmutable) {
var hoisted = path.hoist();
const hoisted = path.hoist();

@@ -134,2 +135,3 @@ if (hoisted) {

}
}

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

{
"name": "@babel/plugin-transform-react-constant-elements",
"version": "7.0.0-beta.46",
"version": "7.0.0-beta.47",
"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.46",
"@babel/helper-plugin-utils": "7.0.0-beta.46"
"@babel/helper-annotate-as-pure": "7.0.0-beta.47",
"@babel/helper-plugin-utils": "7.0.0-beta.47"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.46"
"@babel/core": "7.0.0-beta.47"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.46",
"@babel/helper-plugin-test-runner": "7.0.0-beta.46"
"@babel/core": "7.0.0-beta.47",
"@babel/helper-plugin-test-runner": "7.0.0-beta.47"
}
}
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