Socket
Socket
Sign inDemoInstall

@babel/helper-builder-react-jsx

Package Overview
Dependencies
Maintainers
4
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-builder-react-jsx - npm Package Compare versions

Comparing version 7.22.5 to 8.0.0-alpha.0

68

lib/index.js

@@ -1,9 +0,4 @@

"use strict";
import * as _t from '@babel/types';
import annotateAsPure from '@babel/helper-annotate-as-pure';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _t = require("@babel/types");
var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure");
const {

@@ -33,3 +28,3 @@ booleanLiteral,

} = _t;
function _default(opts) {
function index (opts) {
const visitor = {};

@@ -95,5 +90,4 @@ visitor.JSXNamespacedName = function (path) {

if (isStringLiteral(value) && !isJSXExpressionContainer(node.value)) {
var _value$extra;
value.value = value.value.replace(/\n\s+/g, " ");
(_value$extra = value.extra) == null ? true : delete _value$extra.raw;
delete value.extra?.raw;
}

@@ -134,3 +128,3 @@ if (isJSXNamespacedName(node.name)) {

{
convertedAttributes = buildOpeningElementAttributes(attribs, pass);
convertedAttributes = objectExpression(attribs.map(convertAttribute));
}

@@ -145,52 +139,5 @@ } else {

const call = state.call || callExpression(state.callee, args);
if (state.pure) (0, _helperAnnotateAsPure.default)(call);
if (state.pure) annotateAsPure(call);
return call;
}
function pushProps(_props, objs) {
if (!_props.length) return _props;
objs.push(objectExpression(_props));
return [];
}
function buildOpeningElementAttributes(attribs, pass) {
let _props = [];
const objs = [];
const {
useSpread = false
} = pass.opts;
if (typeof useSpread !== "boolean") {
throw new Error("transform-react-jsx currently only accepts a boolean option for " + "useSpread (defaults to false)");
}
const useBuiltIns = pass.opts.useBuiltIns || false;
if (typeof useBuiltIns !== "boolean") {
throw new Error("transform-react-jsx currently only accepts a boolean option for " + "useBuiltIns (defaults to false)");
}
if (useSpread && useBuiltIns) {
throw new Error("transform-react-jsx currently only accepts useBuiltIns or useSpread " + "but not both");
}
if (useSpread) {
const props = attribs.map(convertAttribute);
return objectExpression(props);
}
while (attribs.length) {
const prop = attribs.shift();
if (isJSXSpreadAttribute(prop)) {
_props = pushProps(_props, objs);
objs.push(prop.argument);
} else {
_props.push(convertAttribute(prop));
}
}
pushProps(_props, objs);
let convertedAttribs;
if (objs.length === 1) {
convertedAttribs = objs[0];
} else {
if (!isObjectExpression(objs[0])) {
objs.unshift(objectExpression([]));
}
const helper = useBuiltIns ? memberExpression(identifier("Object"), identifier("assign")) : pass.addHelper("extends");
convertedAttribs = callExpression(helper, objs);
}
return convertedAttribs;
}
function buildFragmentCall(path, pass) {

@@ -217,3 +164,3 @@ if (opts.filter && !opts.filter(path.node, pass)) return;

const call = state.call || callExpression(state.callee, args);
if (state.pure) (0, _helperAnnotateAsPure.default)(call);
if (state.pure) annotateAsPure(call);
return call;

@@ -223,2 +170,3 @@ }

export { index as default };
//# sourceMappingURL=index.js.map

18

package.json
{
"name": "@babel/helper-builder-react-jsx",
"version": "7.22.5",
"version": "8.0.0-alpha.0",
"description": "Helper function to build react jsx",

@@ -17,14 +17,18 @@ "repository": {

"dependencies": {
"@babel/helper-annotate-as-pure": "^7.22.5",
"@babel/types": "^7.22.5"
"@babel/helper-annotate-as-pure": "^8.0.0-alpha.0",
"@babel/types": "^8.0.0-alpha.0"
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/traverse": "^7.22.5"
"@babel/core": "^8.0.0-alpha.0",
"@babel/traverse": "^8.0.0-alpha.0"
},
"engines": {
"node": ">=6.9.0"
"node": "^16.20.0 || ^18.16.0 || >=20.0.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
},
"type": "module"
}

@@ -5,3 +5,3 @@ # @babel/helper-builder-react-jsx

See our website [@babel/helper-builder-react-jsx](https://babeljs.io/docs/en/babel-helper-builder-react-jsx) for more information.
See our website [@babel/helper-builder-react-jsx](https://babeljs.io/docs/babel-helper-builder-react-jsx) for more information.

@@ -8,0 +8,0 @@ ## Install

Sorry, the diff of this file is not supported yet

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