What is babel-plugin-transform-member-expression-literals?
The babel-plugin-transform-member-expression-literals package is a Babel plugin that transforms member expression property literals into dot notation. This can be useful for ensuring consistency in code style and potentially improving performance.
What are babel-plugin-transform-member-expression-literals's main functionalities?
Transforming member expression property literals
Transforms member expression property literals into dot notation. For example, `obj['foo']` would be transformed to `obj.foo`.
const obj = { 'foo': 1 }; console.log(obj['foo']);
Other packages similar to babel-plugin-transform-member-expression-literals
babel-plugin-transform-property-literals
This package transforms property literals into dot notation, similar to babel-plugin-transform-member-expression-literals. It focuses on transforming object property keys that are string literals into dot notation.
babel-plugin-transform-object-rest-spread
This package allows the use of the object rest/spread syntax in JavaScript. While it doesn't directly transform member expression literals, it provides similar functionality in terms of transforming and optimizing object manipulation.
babel-plugin-transform-member-expression-literals
Turn valid member expression property literals into plain identifiers
Example
In
obj["foo"] = "isValid";
obj.const = "isKeyword";
obj["var"] = "isKeyword";
Out
obj.foo = "isValid";
obj["const"] = "isKeyword";
obj["var"] = "isKeyword";
Installation
npm install babel-plugin-transform-member-expression-literals --save-dev
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["transform-member-expression-literals"]
}
Via CLI
babel --plugins transform-member-expression-literals script.js
Via Node API
require("@babel/core").transform("code", {
plugins: ["transform-member-expression-literals"]
});