Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

resugar

> 编程语言
Open source

Rewrite your JavaScript & TypeScript source code with sweet new features.

692 stars0 likes1 views
WebsiteGitHub

About

Rewrite your JavaScript & TypeScript source code with sweet new features.

resugar

Rewrite your JavaScript & TypeScript source code with sweet new features.

TODO: Below is the README for esnext, the project this one came from. It will be replaced in time.


Installation

$ yarn global add esnext
# or, with `npm`:
$ npm install -g esnext

Usage

After installing, run esnext -h for comprehensive usage instructions.

Features

Functions

Translate some regular functions to arrow functions:

javascript
list.map(function(item) {
  return item.name;
});

// ↑ becomes ↓

list.map(item => item.name);

Declarations

Convert var declarations to let or const as appropriate:

javascript
var arr = [];
for (var i = 0; i < 5; i++) {
  arr.push(i);
}

// ↑ becomes ↓

const arr = [];
for (let i = 0; i < 5; i++) {
  arr.push(i);
}

Objects

Use shorthand syntax for various object constructs:

javascript
let person = {
  first: first,
  last: last,

  fullName: function() {
    return `${first} ${last}`;
  }
};

// ↑ becomes ↓

let person = {
  first,
  last,

  fullName() {
    return `${first} ${last}`;
  }
};

Strings

Convert string concatenation to string or template literals:

javascript
let name = 'Brian' + ' ' + 'Donovan';
let greeting = 'Hello, ' + name;

// ↑ becomes ↓

let name = 'Brian Donovan';
let greeting = `Hello, ${name}`;

Destructuring

Convert assignments and declarations to use object destructuring syntax:

javascript
let a = obj.a,
  b = obj.b;
(a = obj2.a), (b = obj2.b);

// ↑ becomes ↓

let { a, b } = obj;
({ a, b } = obj2);

Modules

Translate CommonJS modules into ES6 modules:

javascript
var readFile = require('fs').readFile;
const MagicString = require('magic-string');
let { ok, strictEqual: eq } = require('assert');

exports.doSomething = function() {
  ok(1);
};

// ↑ becomes ↓

import { readFile } from 'fs';
import MagicString from 'magic-string';
import { ok, strictEqual as eq } from 'assert';

export function doSomething() {
  ok(1);
}

Options

javascript
{
  'declarations.block-scope': {
    /**
     * Set this to `true` to only turn `var` into `let`, never `const`.
     */
    disableConst: boolean
  }
}

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言