terser/terser

The mangle `reserved` option does not stop labels from being renamed

Aperta

#1465 aperta il 19 ott 2023

 (1 commento) (1 reazione) (0 assegnatari)JavaScript (386 fork)batch import
good first issue

Metriche repository

Star
 (8215 stelle)
Metriche merge PR
 (Merge medio 8g 16h) (1 PR mergiata in 30 g)

Descrizione

Bug report

I'd like the output code to support this use case: https://esbuild.github.io/api/#drop-labels

I'd also like to not set compress to false, but I didn't find another way to keep Terser from removing the label. Related Issue: #1266

Version (complete output of terser -V or specific git commit)

REPL, but I think it's 5.22.0

Complete CLI command or minify() options used

REPL config:

{
  module: true,
  compress: false,
  mangle: { reserved: ["DEV", "example"] },
  output: {},
  parse: {},
  rename: {},
}

terser input

function example() {
  DEV: doAnExpensiveCheck()
  return normalCodePath()
}

terser output

function example(){n:doAnExpensiveCheck();return normalCodePath()}

Expected result

function example(){DEV:doAnExpensiveCheck();return normalCodePath()}

Guida contributor