Conversation
| let replacementPath = binding.path; | ||
| let isReferencedBefore = false; | ||
|
|
||
| if (binding.referencePaths.length > 1) { |
Member
Author
There was a problem hiding this comment.
unnecessary check.
boopathi
reviewed
Jun 21, 2017
|
|
||
| const replacements = []; | ||
| const { path: bindingPath } = | ||
| path.scope.getBinding(test.node.name) || {}; |
Member
There was a problem hiding this comment.
if (binding) check is clearer, like it's used everywhere else in babili
boopathi
reviewed
Jun 21, 2017
| const source = unpad(` | ||
| function foo(v) { | ||
| if (v) var w = 10; | ||
| if (w) console.log("hello", v); |
Member
There was a problem hiding this comment.
There is also
while (v) { var w = 10; }
if (w) console.log(w);
Member
Author
|
We need to handle this in simplify as well for the same case. Started to think, hoisting that var would be a better option than monkey patching at all places. Thoughts? @boopathi |
Member
|
var hoisting was considered earlier. But I didn't try measuring its effect on gzip yet. #48 (comment) |
Member
Author
|
Hmm alright, the problem itself is with babel's It becomes tricky to do the scope check on every pattern matching step in simplify. |
d7f8de5 to
20c2f81
Compare
20c2f81 to
57fe8ff
Compare
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.
this is required for only var bindings.
The other way we could fix this is to hoist all the var bindings before we run simplify & deadcode.