javascriptuglifyjsuglifyjs2

Is it possible to stop UglifyJS from injecting "_" as a replacement name?


Is there a way to configure Uglify with a blacklist of strings that should not be injected during replacement?

For example, Uglify is currently replacing TypeError with _:

TypeError("Promise can't be resolved") => _("Promise can't be resolved").

But, I'm running static post-processing on the Uglified code to extract strings marked with _:

_("Marked by the developer").

Uglify's injection of _ to replace TypeError is generating false positives during the post-process extraction.

I know it is possible to stop function/class name mangling all together, and to prevent mangling for reserved names.

But, is there a way I can tell Uglify to do regular mangling, just that _ should not be injected during replacement?


Solution

  • Have you tried specifying the reserved option and passing in _ to that? I would expect that it wouldn't replace it knowing that is a special name.