Merged
Conversation
guybedford
approved these changes
Jun 4, 2018
Contributor
guybedford
left a comment
There was a problem hiding this comment.
Looks great, and nice work on the quick fix. Just the one question, but good to merge.
| const variable = this.traceExport(exportName); | ||
|
|
||
| variable.exportName = exportName; | ||
| variable.reassignPath(UNKNOWN_PATH, NEW_EXECUTION_PATH); |
Contributor
There was a problem hiding this comment.
Just wondering, if we are going to support object truthiness in future like:
var obj = {};
if (!obj || typeof obj !== 'object')
console.log('treeshaken');Then would it make sense to have a form of reassignPath that can treat the object as still an object, but with unknown properties?
So the following optimization could still work:
const obj = {
reassigned() {},
test() {
obj.reassigned();
}
};
export default obj;
if (!obj)
console.log('treeshaken');
Member
Author
There was a problem hiding this comment.
This would be supported by the current approach. UNKNOWN_PATH might be a sub-optimal variable name as it is actually an "unknown path of length one". Thus the object is still recognized as an object but we no longer have any reliable information about the values of its fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #2237
As it turns out, there was nothing to do for objects attached to globals as the global variable handling has always been very conservative here. Added a regression test nonetheless.
External exports are now properly marked as reassigned.