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

Track using violations #1

Merged
merged 2 commits into from
Oct 31, 2016
Merged

Conversation

jridgewell
Copy link

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. 😁

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. 😁
@jridgewell
Copy link
Author

Also, the jQuery benchmark runs some ~40ms faster, react ~30ms.

}

const funcViolation = binding.referencePaths.some((p) => {
return p.node.start < start;
Copy link
Owner

@shinew shinew Oct 27, 2016

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.

Copy link
Author

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.

Copy link
Author

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;
Copy link
Owner

@shinew shinew Oct 27, 2016

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.

Copy link
Author

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.

@shinew
Copy link
Owner

shinew commented Oct 27, 2016

This looks like a better approach, if we can resolve the edge cases in my comments (above). @kangax @boopathi thoughts?

@shinew
Copy link
Owner

shinew commented Oct 28, 2016

@jridgewell I'll merge this once the multi-layer referencing is ready.

@shinew shinew merged commit 03884c7 into shinew:transform-void-to-nothing Oct 31, 2016
@shinew
Copy link
Owner

shinew commented Oct 31, 2016

Nice!

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.

2 participants