Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
Terser keep (don't mangle) a specific function name

Is there a way to not mangle only one function name? A comment in the code would be easiest, but I guess this could be done by specifying a custom "nameCache" ? But I don't know how that works.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I couldn't figure this out, but I already had the function name so I stored the function name on the webpage in an attribute that I could find later with JavaScript. e.g.

function bob() {
  console.log('hello');
}

document.querySelector('#myid').setAttribute('data-function-name', bob.name);
<span id="myid">for example make this style="display:none;"</span>

about 4 years ago · Santiago Trujillo Relatório

0

To prevent terser from mangling a particular symbol, you need to add it to terser's reserved list. This can be done in your terser options file:

{
    "mangle":
    { 
        "properties":
        {
            "reserved": ["symbolToNotMangle", "anotherSymbolToPreserve"]
        }
    }
}

If you are not already using a terser options file, you would save that off to (for example) terser_options.json and tell terser to use it like so:

terser ... --config-file terser_options.json

You can also just list the reserved symbols on the command line if you prefer:

terser ... -m reserved=['symbolToNotMangle','anotherSymbolToPreserve']

https://github.com/terser/terser#cli-mangle-options

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda