@babel/plugin-transform-property-literals

NOTE: This plugin is included in @babel/preset-env

Example

In

  1. var foo = {
  2. // changed
  3. const: function() {},
  4. var: function() {},
  5. // not changed
  6. default: 1,
  7. [a]: 2,
  8. foo: 1,
  9. };

Out

  1. var foo = {
  2. const: function() {},
  3. var: function() {},
  4. default: 1,
  5. [a]: 2,
  6. foo: 1,
  7. };

Installation

  1. npm install @babel/plugin-transform-property-literals --save-dev

Usage

  1. {
  2. "plugins": ["@babel/plugin-transform-property-literals"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-transform-property-literals script.js

Via Node API

  1. require("@babel/core").transformSync("code", {
  2. plugins: ["@babel/plugin-transform-property-literals"],
  3. });