babel / babel/minify

Feature request: Convert long repeated strings to `.repeat()` when minifying

Open
#1,015 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Whenever I minify long strings using this minifier, The strings are left untouched. It would be nice if the long strings (Example `'░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░'`) could be changed to `'░'.repeat(35)`, which saves 21 characters

**Describe the solution you'd like**
Replace long enough strings with `.repeat()` when minifying

**Describe alternatives you've considered**
We could do this in the source code itself, but that defeats the purpose of a minifer

**Additional context**
NA

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests. Start by locating the JavaScript minifier's handling of string literals and its existing regression tests; clarify the length threshold and compatibility constraints before proceeding. Done means eligible repeated strings are converted to equivalent `.repeat()` expressions with tests covering the requested example and unchanged behavior for other strings.

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.