Ensure generated global MemberExpressions
are not shared
#116
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.
The original fix in b63bb6e attempted to cache the generated member expressions, so that we didn't do duplicated work for each reference to a given global. Unfortunately, this optimization failed to take into consideration that most babel plugins work by directly mutating the node in question. In practice what that meant was that once any usage of a given global was needed to be transformed (e.g. say you had
computed(...args, function(){})
and are transpiling for IE11), then all usages of that global would be mutated.A more concrete example.
In this example, the first method (
specialComputed
) needs to be transpiled to something akin to (most of the changes here are from@babel/plugin-transform-spread
):Unfortunately, since the generated
MemberExpression
forEmber.computed
is shared, this forced the othercomputed
usage to betranspiled to:
Which is clearly, totally invalid. 🤦