@babel/plugin-transform-spread
Advanced tools
Comparing version 7.21.4-esm.4 to 7.22.5
@@ -1,5 +0,11 @@ | ||
import { declare } from "@babel/helper-plugin-utils"; | ||
import { skipTransparentExprWrappers } from "@babel/helper-skip-transparent-expression-wrappers"; | ||
import { types as t } from "@babel/core"; | ||
export default declare((api, options) => { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); | ||
var _helperSkipTransparentExpressionWrappers = require("@babel/helper-skip-transparent-expression-wrappers"); | ||
var _core = require("@babel/core"); | ||
var _default = (0, _helperPluginUtils.declare)((api, options) => { | ||
var _api$assumption, _options$allowArrayLi; | ||
@@ -10,3 +16,3 @@ api.assertVersion(7); | ||
function getSpreadLiteral(spread, scope) { | ||
if (iterableIsArray && !t.isIdentifier(spread.argument, { | ||
if (iterableIsArray && !_core.types.isIdentifier(spread.argument, { | ||
name: "arguments" | ||
@@ -24,3 +30,3 @@ })) { | ||
for (let i = 0; i < nodes.length; i++) { | ||
if (t.isSpreadElement(nodes[i])) { | ||
if (_core.types.isSpreadElement(nodes[i])) { | ||
return true; | ||
@@ -33,3 +39,3 @@ } | ||
if (!_props.length) return _props; | ||
nodes.push(t.arrayExpression(_props)); | ||
nodes.push(_core.types.arrayExpression(_props)); | ||
return []; | ||
@@ -41,7 +47,7 @@ } | ||
for (const prop of props) { | ||
if (t.isSpreadElement(prop)) { | ||
if (_core.types.isSpreadElement(prop)) { | ||
_props = push(_props, nodes); | ||
let spreadLiteral = getSpreadLiteral(prop, scope); | ||
if (t.isArrayExpression(spreadLiteral) && hasHole(spreadLiteral)) { | ||
spreadLiteral = t.callExpression(file.addHelper("arrayWithoutHoles"), [spreadLiteral]); | ||
if (_core.types.isArrayExpression(spreadLiteral) && hasHole(spreadLiteral)) { | ||
spreadLiteral = _core.types.callExpression(file.addHelper("arrayWithoutHoles"), [spreadLiteral]); | ||
} | ||
@@ -72,8 +78,8 @@ nodes.push(spreadLiteral); | ||
} | ||
if (!t.isArrayExpression(first)) { | ||
first = t.arrayExpression([]); | ||
if (!_core.types.isArrayExpression(first)) { | ||
first = _core.types.arrayExpression([]); | ||
} else { | ||
nodes.shift(); | ||
} | ||
path.replaceWith(t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes)); | ||
path.replaceWith(_core.types.callExpression(_core.types.memberExpression(first, _core.types.identifier("concat")), nodes)); | ||
}, | ||
@@ -87,3 +93,3 @@ CallExpression(path) { | ||
if (!hasSpread(args)) return; | ||
const calleePath = skipTransparentExprWrappers(path.get("callee")); | ||
const calleePath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(path.get("callee")); | ||
if (calleePath.isSuper()) { | ||
@@ -95,3 +101,3 @@ throw path.buildCodeFrameError("It's not possible to compile spread arguments in `super()` without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration."); | ||
let nodes; | ||
if (args.length === 1 && t.isIdentifier(args[0].argument, { | ||
if (args.length === 1 && _core.types.isIdentifier(args[0].argument, { | ||
name: "arguments" | ||
@@ -105,3 +111,3 @@ })) { | ||
if (nodes.length) { | ||
node.arguments.push(t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes)); | ||
node.arguments.push(_core.types.callExpression(_core.types.memberExpression(first, _core.types.identifier("concat")), nodes)); | ||
} else { | ||
@@ -111,16 +117,16 @@ node.arguments.push(first); | ||
const callee = calleePath.node; | ||
if (t.isMemberExpression(callee)) { | ||
if (_core.types.isMemberExpression(callee)) { | ||
const temp = scope.maybeGenerateMemoised(callee.object); | ||
if (temp) { | ||
callee.object = t.assignmentExpression("=", temp, callee.object); | ||
callee.object = _core.types.assignmentExpression("=", temp, callee.object); | ||
contextLiteral = temp; | ||
} else { | ||
contextLiteral = t.cloneNode(callee.object); | ||
contextLiteral = _core.types.cloneNode(callee.object); | ||
} | ||
} | ||
node.callee = t.memberExpression(node.callee, t.identifier("apply")); | ||
if (t.isSuper(contextLiteral)) { | ||
contextLiteral = t.thisExpression(); | ||
node.callee = _core.types.memberExpression(node.callee, _core.types.identifier("apply")); | ||
if (_core.types.isSuper(contextLiteral)) { | ||
contextLiteral = _core.types.thisExpression(); | ||
} | ||
node.arguments.unshift(t.cloneNode(contextLiteral)); | ||
node.arguments.unshift(_core.types.cloneNode(contextLiteral)); | ||
}, | ||
@@ -137,7 +143,7 @@ NewExpression(path) { | ||
if (nodes.length) { | ||
args = t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes); | ||
args = _core.types.callExpression(_core.types.memberExpression(first, _core.types.identifier("concat")), nodes); | ||
} else { | ||
args = first; | ||
} | ||
path.replaceWith(t.callExpression(path.hub.addHelper("construct"), [node.callee, args])); | ||
path.replaceWith(_core.types.callExpression(path.hub.addHelper("construct"), [node.callee, args])); | ||
} | ||
@@ -147,3 +153,4 @@ } | ||
}); | ||
exports.default = _default; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/plugin-transform-spread", | ||
"version": "7.21.4-esm.4", | ||
"version": "7.22.5", | ||
"description": "Compile ES2015 spread to ES5", | ||
@@ -19,11 +19,11 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "7.21.4-esm.4", | ||
"@babel/helper-skip-transparent-expression-wrappers": "7.21.4-esm.4" | ||
"@babel/helper-plugin-utils": "^7.22.5", | ||
"@babel/helper-skip-transparent-expression-wrappers": "^7.22.5" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^7.0.0-0 || ^7.21.4-esm.2" | ||
"@babel/core": "^7.0.0-0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.21.4-esm.4", | ||
"@babel/helper-plugin-test-runner": "7.21.4-esm.4" | ||
"@babel/core": "^7.22.5", | ||
"@babel/helper-plugin-test-runner": "^7.22.5" | ||
}, | ||
@@ -35,3 +35,3 @@ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-spread", | ||
"author": "The Babel Team (https://babel.dev/team)", | ||
"type": "module" | ||
"type": "commonjs" | ||
} |
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
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
21178
143
0
5
No
+ Added@babel/helper-plugin-utils@7.25.9(transitive)
+ Added@babel/helper-skip-transparent-expression-wrappers@7.25.9(transitive)
- Removed@babel/helper-plugin-utils@7.21.4-esm.4(transitive)
- Removed@babel/helper-skip-transparent-expression-wrappers@7.21.4-esm.4(transitive)
- Removed@babel/helper-string-parser@7.21.4-esm.4(transitive)
- Removed@babel/helper-validator-identifier@7.21.4-esm.4(transitive)
- Removed@babel/types@7.21.4-esm.4(transitive)
- Removedto-fast-properties@2.0.0(transitive)
Updated@babel/helper-skip-transparent-expression-wrappers@^7.22.5