@babel/helper-builder-react-jsx
Advanced tools
Comparing version 7.22.5 to 8.0.0-alpha.0
@@ -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 |
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
24803
164
1
+ Added@babel/helper-annotate-as-pure@8.0.0-alpha.12(transitive)
+ Added@babel/helper-string-parser@8.0.0-alpha.12(transitive)
+ Added@babel/helper-validator-identifier@8.0.0-alpha.12(transitive)
+ Added@babel/types@8.0.0-alpha.12(transitive)
+ Addedto-fast-properties@3.0.1(transitive)
- Removed@babel/helper-annotate-as-pure@7.24.7(transitive)
- Removed@babel/helper-string-parser@7.24.8(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/types@7.25.6(transitive)
- Removedto-fast-properties@2.0.0(transitive)
Updated@babel/types@^8.0.0-alpha.0