-
Notifications
You must be signed in to change notification settings - Fork 0
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
Track using violations #1
Conversation
There's no way we can visit every identifier. Instead, figure out which constant violations hamper the minification. Oh, and some test cases. Those should probably be cleaned up. 😁
Also, the jQuery benchmark runs some ~40ms faster, react ~30ms. |
} | ||
|
||
const funcViolation = binding.referencePaths.some((p) => { | ||
return p.node.start < start; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this fail for references through multiple levels of indirection?
e.g.
function foo() {
bar();
var a = undefined;
console.log(a);
function bar() {
g();
}
function g() {
a = 4;
}
}
We cannot remove the = undefined
in this case. As I understand this, it only checks for 1 level of referencing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll be easy enough to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but it's unoptimized.
continue; | ||
} | ||
|
||
const { start } = node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the start
and end
attributes won't work for nodes that are runtime-generated: https://astexplorer.net/#/Pl6ASeZRlL. This is still probably better than any other way of determining relative ordering though, if we add some existence checks for these attributes for safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought doing a #replaceWith
auto-inherited the location. Looks like you have to t.inherits(newNode, oldNode)
in order to get that.
@jridgewell I'll merge this once the multi-layer referencing is ready. |
Nice! |
There's no way we can visit every identifier. Instead, figure out which
constant violations hamper the minification.
Oh, and some test cases. Those should probably be cleaned up. 😁