babel / babel/minify

[feature request] Convert functions to arrow functions

Open
#354 8 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

I think Babili could save a lot of bytes with a plugin that converts functions that do not make use of `this` to arrow functions:

Input (34):
```
function foo() {
return 'bar';
}
```

Output(18):
```
let foo=()=>'bar';
// or 20 with `const`
```

Current result:
https://babeljs.io/repl/#?babili=true&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&code=function%20foo()%20%7B%0A%20%20return%20'bar'%3B%0A%7D

Contributor guide

Open the contributing guide

Research direction

Start with the Babel REPL linked in the issue and reproduce the shown function-to-arrow-function size comparison. The payload names no source file or test, so identify the minifier plugin entry point and existing coverage; done means the requested safe conversions are supported without changing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.