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

handle pure_funcs under inline & reduce_vars correctly #3066

Merged
merged 1 commit into from
Apr 9, 2018

Conversation

alexlamsl
Copy link
Collaborator

fixes #3065

@alexlamsl alexlamsl merged commit 183da16 into mishoo:master Apr 9, 2018
@alexlamsl alexlamsl deleted the issue-3065 branch April 9, 2018 18:46
@@ -685,7 +685,8 @@ If you're using the `X-SourceMap` header instead, you can just omit `sourceMap.u
pass `pure_funcs: [ 'Math.floor' ]` to let it know that this
function won't produce any side effect, in which case the whole
statement would get discarded. The current implementation adds some
overhead (compression will be slower).
overhead (compression will be slower). Make sure symbols under `pure_funcs`
are also under `mangle.reserved` to avoid mangling.

Choose a reason for hiding this comment

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

Why not do that automatically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Too much hassle to maintain for a non-default feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually a regression from 2.x. The pure_funcs used to work correctly without mangle.reserved:

#3065 (comment)

Further, unlike mangle.reserved, you will notice in the link that the retained pure_funcs were also mangled after they were processed in 2.x as one would expect.

If you want to correct the comment above just erase the note about using mangle.reserved and say to use --no-rename as a workaround in 3.x when mangling with pure_funcs. Alternatively, the specified pure_funcs could be excluded in the rename pass. Or simpler still the rename pass could just be disabled automatically when pure_funcs is specified.

kzc referenced this pull request in terser/terser May 12, 2018
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.

Function considered pure with call site annotation, but not with pure_funcs
3 participants