UglifyJS
UglifyJS copied to clipboard
provide 'magic comments' to preserve classnames/function names
Feature request: magic-comments to keep classnames/function names. eg).
// UGLIFYJS:KEEP_FUNCTION_NAME
class User extends Typegoose {
...
}
Why: I had problems with Webpack's uglifyjs mangling class names, when some libraries depended on constructor.name property to work.
specifically, when using Typegoose:
class User extends Typegoose { // 'User' becomes aqw, so it's stored as 'aqw' on mongodb
// ..
related: https://github.com/webpack/webpack/issues/1659#issuecomment-415651353
-
keep_classnames(default:undefined) - passtrueto prevent discarding or mangling of class names. -
keep_fnames(default:false) - passtrueto prevent discarding or mangling of function names. Useful for code relying onFunction.prototype.name. If the top level minify optionkeep_classnamesisundefinedit will be overridden with the value of the top level minify optionkeep_fnames.
@kzc but that means I have to edit the webpack build config, which is impossible for Create-React-App
Moreover, I don't want ALL the class names to be kept - only a few.
https://www.youtube.com/watch?v=oqMl5CRoFdk
@kzc I like how you searched for such an apt song 👍
but...

please...?
Having such an option would be absolutely awesome.