@babel/plugin-transform-template-literals
Advanced tools
Comparing version 7.21.4-esm.2 to 7.21.4-esm.3
@@ -1,4 +0,10 @@ | ||
import { declare } from "@babel/helper-plugin-utils"; | ||
import { template, 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 _core = require("@babel/core"); | ||
var _default = (0, _helperPluginUtils.declare)((api, options) => { | ||
var _api$assumption, _api$assumption2; | ||
@@ -13,3 +19,3 @@ api.assertVersion(7); | ||
return items.reduce(function (left, right) { | ||
let canBeInserted = t.isLiteral(right); | ||
let canBeInserted = _core.types.isLiteral(right); | ||
if (!canBeInserted && avail) { | ||
@@ -19,7 +25,7 @@ canBeInserted = true; | ||
} | ||
if (canBeInserted && t.isCallExpression(left)) { | ||
if (canBeInserted && _core.types.isCallExpression(left)) { | ||
left.arguments.push(right); | ||
return left; | ||
} | ||
return t.callExpression(t.memberExpression(left, t.identifier("concat")), [right]); | ||
return _core.types.callExpression(_core.types.memberExpression(left, _core.types.identifier("concat")), [right]); | ||
}); | ||
@@ -45,5 +51,5 @@ } | ||
} = elem.value; | ||
const value = cooked == null ? path.scope.buildUndefinedNode() : t.stringLiteral(cooked); | ||
const value = cooked == null ? path.scope.buildUndefinedNode() : _core.types.stringLiteral(cooked); | ||
strings.push(value); | ||
raws.push(t.stringLiteral(raw)); | ||
raws.push(_core.types.stringLiteral(raw)); | ||
if (raw !== cooked) { | ||
@@ -53,12 +59,12 @@ isStringsRawEqual = false; | ||
} | ||
const helperArgs = [t.arrayExpression(strings)]; | ||
const helperArgs = [_core.types.arrayExpression(strings)]; | ||
if (!isStringsRawEqual) { | ||
helperArgs.push(t.arrayExpression(raws)); | ||
helperArgs.push(_core.types.arrayExpression(raws)); | ||
} | ||
const tmp = path.scope.generateUidIdentifier("templateObject"); | ||
path.scope.getProgramParent().push({ | ||
id: t.cloneNode(tmp) | ||
id: _core.types.cloneNode(tmp) | ||
}); | ||
path.replaceWith(t.callExpression(node.tag, [template.expression.ast` | ||
${t.cloneNode(tmp)} || ( | ||
path.replaceWith(_core.types.callExpression(node.tag, [_core.template.expression.ast` | ||
${_core.types.cloneNode(tmp)} || ( | ||
${tmp} = ${this.addHelper(helperName)}(${helperArgs}) | ||
@@ -77,3 +83,3 @@ ) | ||
if (elem.value.cooked) { | ||
nodes.push(t.stringLiteral(elem.value.cooked)); | ||
nodes.push(_core.types.stringLiteral(elem.value.cooked)); | ||
} | ||
@@ -83,3 +89,3 @@ if (index < expressions.length) { | ||
const node = expr.node; | ||
if (!t.isStringLiteral(node, { | ||
if (!_core.types.isStringLiteral(node, { | ||
value: "" | ||
@@ -91,4 +97,4 @@ })) { | ||
} | ||
if (!t.isStringLiteral(nodes[0]) && !(ignoreToPrimitiveHint && t.isStringLiteral(nodes[1]))) { | ||
nodes.unshift(t.stringLiteral("")); | ||
if (!_core.types.isStringLiteral(nodes[0]) && !(ignoreToPrimitiveHint && _core.types.isStringLiteral(nodes[1]))) { | ||
nodes.unshift(_core.types.stringLiteral("")); | ||
} | ||
@@ -98,3 +104,3 @@ let root = nodes[0]; | ||
for (let i = 1; i < nodes.length; i++) { | ||
root = t.binaryExpression("+", root, nodes[i]); | ||
root = _core.types.binaryExpression("+", root, nodes[i]); | ||
} | ||
@@ -109,3 +115,4 @@ } else if (nodes.length > 1) { | ||
}); | ||
exports.default = _default; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/plugin-transform-template-literals", | ||
"version": "7.21.4-esm.2", | ||
"version": "7.21.4-esm.3", | ||
"description": "Compile ES2015 template literals to ES5", | ||
@@ -16,3 +16,3 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "7.21.4-esm.2" | ||
"@babel/helper-plugin-utils": "7.21.4-esm.3" | ||
}, | ||
@@ -26,4 +26,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "7.21.4-esm.2", | ||
"@babel/helper-plugin-test-runner": "7.21.4-esm.2" | ||
"@babel/core": "7.21.4-esm.3", | ||
"@babel/helper-plugin-test-runner": "7.21.4-esm.3" | ||
}, | ||
@@ -30,0 +30,0 @@ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-template-literals", |
Sorry, the diff of this file is not supported yet
15879
107
+ Added@babel/helper-plugin-utils@7.21.4-esm.3(transitive)
- Removed@babel/helper-plugin-utils@7.21.4-esm.2(transitive)