@babel/plugin-transform-shorthand-properties

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

Example

In

  1. var o = { a, b, c };

Out

  1. var o = { a: a, b: b, c: c };

In

  1. var cat = {
  2. getName() {
  3. return name;
  4. },
  5. };

Out

  1. var cat = {
  2. getName: function() {
  3. return name;
  4. },
  5. };

Installation

  1. npm install --save-dev @babel/plugin-transform-shorthand-properties

Usage

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

Via CLI

  1. babel --plugins @babel/plugin-transform-shorthand-properties script.js

Via Node API

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