What is @babel/plugin-transform-template-literals?
The @babel/plugin-transform-template-literals package is a Babel plugin that transforms ES2015 template literals into the equivalent ES5 string concatenation syntax. This is particularly useful for ensuring compatibility with older browsers or environments that do not support template literals.
What are @babel/plugin-transform-template-literals's main functionalities?
Template Literal Transformation
Converts template literals into string concatenation to ensure ES5 compatibility.
`Hello, ${name}!` // Transforms into 'Hello, ' + name + '!'
Tagged Template Literal Transformation
Transforms tagged template literals into a function call with an array of string literals and the template substitutions.
tagFunction`Hello, ${name}!` // Transforms into tagFunction(['Hello, ', '!'], name)
Other packages similar to @babel/plugin-transform-template-literals
@babel/plugin-transform-destructuring
Transforms ES2015 destructuring assignments into equivalent ES5 syntax. It provides similar functionality in terms of transforming modern JavaScript features to be compatible with older environments.
@babel/plugin-transform-spread
Transforms ES2015 spread syntax into equivalent ES5 syntax. Like the template literal plugin, it ensures that code using modern JavaScript features can run in environments that only support ES5.
@babel/plugin-transform-template-literals
Compile ES2015 template literals to ES5
See our website @babel/plugin-transform-template-literals for more information.
Install
Using npm:
npm install --save-dev @babel/plugin-transform-template-literals
or using yarn:
yarn add @babel/plugin-transform-template-literals --dev