@babel/plugin-transform-template-literals
Advanced tools
Comparing version 7.12.1 to 7.12.13
@@ -67,20 +67,17 @@ "use strict"; | ||
const scope = path.scope.getProgramParent(); | ||
const templateObject = scope.generateUidIdentifier("templateObject"); | ||
const helperId = this.addHelper(helperName); | ||
const callExpressionInput = [_core.types.arrayExpression(strings)]; | ||
const helperArgs = [_core.types.arrayExpression(strings)]; | ||
if (!isStringsRawEqual) { | ||
callExpressionInput.push(_core.types.arrayExpression(raws)); | ||
helperArgs.push(_core.types.arrayExpression(raws)); | ||
} | ||
const lazyLoad = _core.template.ast` | ||
function ${templateObject}() { | ||
const data = ${_core.types.callExpression(helperId, callExpressionInput)}; | ||
${_core.types.cloneNode(templateObject)} = function() { return data }; | ||
return data; | ||
} | ||
`; | ||
scope.path.unshiftContainer("body", lazyLoad); | ||
path.replaceWith(_core.types.callExpression(node.tag, [_core.types.callExpression(_core.types.cloneNode(templateObject), []), ...quasi.expressions])); | ||
const tmp = path.scope.generateUidIdentifier("templateObject"); | ||
path.scope.getProgramParent().push({ | ||
id: _core.types.cloneNode(tmp) | ||
}); | ||
path.replaceWith(_core.types.callExpression(node.tag, [_core.template.expression.ast` | ||
${_core.types.cloneNode(tmp)} || ( | ||
${tmp} = ${this.addHelper(helperName)}(${helperArgs}) | ||
) | ||
`, ...quasi.expressions])); | ||
}, | ||
@@ -87,0 +84,0 @@ |
{ | ||
"name": "@babel/plugin-transform-template-literals", | ||
"version": "7.12.1", | ||
"version": "7.12.13", | ||
"description": "Compile ES2015 template literals to ES5", | ||
@@ -16,3 +16,3 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^7.10.4" | ||
"@babel/helper-plugin-utils": "^7.12.13" | ||
}, | ||
@@ -26,5 +26,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "^7.12.1", | ||
"@babel/helper-plugin-test-runner": "7.10.4" | ||
} | ||
"@babel/core": "7.12.13", | ||
"@babel/helper-plugin-test-runner": "7.12.13" | ||
}, | ||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-template-literals" | ||
} |
@@ -5,3 +5,3 @@ # @babel/plugin-transform-template-literals | ||
See our website [@babel/plugin-transform-template-literals](https://babeljs.io/docs/en/next/babel-plugin-transform-template-literals.html) for more information. | ||
See our website [@babel/plugin-transform-template-literals](https://babeljs.io/docs/en/babel-plugin-transform-template-literals) for more information. | ||
@@ -8,0 +8,0 @@ ## Install |
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 website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
5767
103