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

separate keep_classnames & keep_fnames #2510

Merged
merged 2 commits into from
Nov 25, 2017
Merged

Conversation

alexlamsl
Copy link
Collaborator

fixes #2418

@kzc
Copy link
Contributor

kzc commented Nov 24, 2017

This one is a bit odd:

$ cat names.js 
class C0 {}
function F0() {}
console.log(class C1{}, class C2{}, function F1(){}, function F2(){});
$ cat names.js | bin/uglifyjs -mc --toplevel
console.log(class c{},class c{},function(){},function(){});

I would have expected the same output as:

$ cat names.js | bin/uglifyjs -mc keep_classnames=0 --toplevel
console.log(class{},class{},function(){},function(){});

lib/compress.js Outdated
@@ -69,6 +69,7 @@ function Compressor(options, false_by_default) {
if_return : !false_by_default,
inline : !false_by_default,
join_vars : !false_by_default,
keep_classnames: !false_by_default,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what's going on - this should default to false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet that extra character is annoying you to no end. :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this - I waited till just before bedtime to make this PR to alleviate my pain.

@kzc
Copy link
Contributor

kzc commented Nov 24, 2017

I'll make a doc PR after this is merged.

@kzc
Copy link
Contributor

kzc commented Nov 24, 2017

In another PR we could have keep_fnames and keep_classnames in mangle, compress and their corresponding top level minify options accept either a regex or an array of valid names as per #2416 (comment). This has been requested a few times over the years.

@kzc
Copy link
Contributor

kzc commented Nov 25, 2017

documented in #2511

@kzc
Copy link
Contributor

kzc commented Nov 25, 2017

Do we want some test/compress/ tests for this?

Using same code for all tests:

class C1 {}
function F1() {}
console.log(class C2{}, function F2(){});

@alexlamsl
Copy link
Collaborator Author

Done in https://github.com/mishoo/UglifyJS2/pull/2510/files#diff-7a02108b11616cdd07d36b9a138a71cbR1578

I use the subtlety of parentheses instead, just to make me feel better 😈

@kzc
Copy link
Contributor

kzc commented Nov 25, 2017

Cool. I don't know how I missed that.

issue_2418_1 can be removed - identical to the more explicit/descriptive issue_2418_2.

@kzc
Copy link
Contributor

kzc commented Nov 25, 2017

I use the subtlety of parentheses instead, just to make me feel better

Yeah - I go overboard with console.log in tests.

@alexlamsl
Copy link
Collaborator Author

issue_2418_1 is testing the default values from Compressor, to cover #2510 (comment)

@alexlamsl alexlamsl merged commit f1e3ef5 into mishoo:harmony Nov 25, 2017
@alexlamsl alexlamsl deleted the issue-2418 branch November 25, 2017 08:31
@kzc
Copy link
Contributor

kzc commented Nov 25, 2017

Compressor default values are not applied in test/compress/ tests.

@alexlamsl
Copy link
Collaborator Author

They are if they are not associated with false_by_default (though that does bring up the question on whether keep_fnames should be false_by_default instead of false)

@kzc
Copy link
Contributor

kzc commented Nov 25, 2017

I see. false_by_default is only useful in testing at the moment?

The next release will be 3.2.0 because of this new option and hoist_props defaulting to true, I'm assuming?

@alexlamsl
Copy link
Collaborator Author

Yes ✖️ 2

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

Successfully merging this pull request may close these issues.

None yet

2 participants