Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide 'magic comments' to preserve classnames/function names #3263

Open
devdoomari3 opened this issue Sep 21, 2018 · 5 comments
Open

provide 'magic comments' to preserve classnames/function names #3263

devdoomari3 opened this issue Sep 21, 2018 · 5 comments

Comments

@devdoomari3
Copy link

devdoomari3 commented Sep 21, 2018

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: webpack/webpack#1659 (comment)

@devdoomari3 devdoomari3 changed the title provide 'magic comments' to keep classnames/function names provide 'magic comments' to preserve classnames/function names Sep 21, 2018
@kzc
Copy link
Contributor

kzc commented Oct 2, 2018

  • keep_classnames (default: undefined) - pass true to prevent discarding or mangling
    of class names.

  • keep_fnames (default: false) - pass true to prevent discarding or mangling
    of function names. Useful for code relying on Function.prototype.name. If the
    top level minify option keep_classnames is undefined it will be overridden with
    the value of the top level minify option keep_fnames.

@devdoomari3
Copy link
Author

@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.

@kzc
Copy link
Contributor

kzc commented Oct 4, 2018

@devdoomari3
Copy link
Author

devdoomari3 commented Oct 4, 2018

@kzc I like how you searched for such an apt song 👍

but...
please-cat

please...?

@llehn
Copy link

llehn commented Oct 30, 2018

Having such an option would be absolutely awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants