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

Reuse removed vars in mangler #395

Merged
merged 10 commits into from May 22, 2017
Merged

Reuse removed vars in mangler #395

merged 10 commits into from May 22, 2017

Conversation

boopathi
Copy link
Member

@boopathi boopathi commented Jan 31, 2017

Duplicate of #284. Rebased with current master.

Changes added to master / Issues reported for master and propagated to this branch:

@boopathi boopathi added enhancement Tag: New Feature Pull Request adding a new feature and removed enhancement labels Jan 31, 2017
@boopathi boopathi added this to Mangler PRs in Mangler Jan 31, 2017
@kangax
Copy link
Member

kangax commented Feb 1, 2017

@boopathi this looks great. The only thing I don't like is the "tracker" name since it doesn't really explain what it is or what it tracks and it might make reading code that uses it harder. Wouldn't "Scope" or "ScopeChain" be a better name?

@boopathi
Copy link
Member Author

boopathi commented Feb 2, 2017

It is not Scope. It is basically -

type Tracker {
  references: Map<Scope, CountedSet<String> >
  bindings: Map<Scope, Map<String, Binding> >
}

It counts references and maintains bindings.

Maybe call it ScopeTracker ?

@kangax
Copy link
Member

kangax commented Feb 3, 2017 via email

@boopathi boopathi force-pushed the reuse-vars-4 branch 2 times, most recently from cf98f73 to f2d24f7 Compare February 3, 2017 13:45
@boopathi boopathi force-pushed the reuse-vars-4 branch 5 times, most recently from 033a3db to 55bee2a Compare February 17, 2017 00:05
@boopathi boopathi mentioned this pull request Mar 3, 2017
@boopathi boopathi force-pushed the reuse-vars-4 branch 2 times, most recently from 0a36f1c to 8f96264 Compare May 8, 2017 12:09
@codecov
Copy link

codecov bot commented May 19, 2017

Codecov Report

Merging #395 into master will decrease coverage by 0.75%.
The diff coverage is 68.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #395      +/-   ##
==========================================
- Coverage   83.26%   82.51%   -0.76%     
==========================================
  Files          34       38       +4     
  Lines        2539     2693     +154     
  Branches      908      943      +35     
==========================================
+ Hits         2114     2222     +108     
- Misses        254      291      +37     
- Partials      171      180       +9
Impacted Files Coverage Δ
...gin-minify-mangle-names/src/is-label-identifier.js 100% <100%> (ø)
...el-plugin-minify-mangle-names/src/scope-tracker.js 60.49% <60.49%> (ø)
...es/babel-plugin-minify-mangle-names/src/charset.js 62.06% <62.06%> (ø)
...ages/babel-plugin-minify-mangle-names/src/index.js 80.1% <72.89%> (+2.45%) ⬆️
...abel-plugin-minify-mangle-names/src/counted-set.js 82.35% <82.35%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2710cf...0d29d98. Read the comment docs.

@codecov
Copy link

codecov bot commented May 19, 2017

Codecov Report

Merging #395 into master will decrease coverage by 0.31%.
The diff coverage is 75.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #395      +/-   ##
==========================================
- Coverage   83.26%   82.94%   -0.32%     
==========================================
  Files          34       40       +6     
  Lines        2539     2715     +176     
  Branches      908      949      +41     
==========================================
+ Hits         2114     2252     +138     
- Misses        254      279      +25     
- Partials      171      184      +13
Impacted Files Coverage Δ
...gin-minify-mangle-names/src/is-label-identifier.js 100% <100%> (ø)
...es/babel-plugin-minify-mangle-names/src/charset.js 63.33% <63.33%> (ø)
...lugin-minify-mangle-names/src/fixup-var-scoping.js 65% <65%> (ø)
...el-plugin-minify-mangle-names/src/scope-tracker.js 71.01% <71.01%> (ø)
...ages/babel-plugin-minify-mangle-names/src/index.js 81.96% <77.66%> (+4.32%) ⬆️
...bel-plugin-minify-mangle-names/src/bfs-traverse.js 85% <85%> (ø)
...abel-plugin-minify-mangle-names/src/counted-set.js 88.23% <88.23%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2710cf...310b40e. Read the comment docs.

ResetNext identifier only when reuse is true

Fix tests - add keepClassName

Reuse vars as default

I dont know why it works - #326

Extract tracker to a separate file, Add topLevel Option
if (
path.parentPath.isMemberExpression({ property: node }) ||
path.parentPath.isObjectProperty({ key: node })
path.parentPath.isExportSpecifier() &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about import specifiers? are they safe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

let parent = scope;
do {
this.references.get(parent).add(name);
if (!binding) throw new Error("How did global come here");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename the error message properly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@boopathi boopathi merged commit 51bbb07 into master May 22, 2017
@boopathi boopathi moved this from Mangler PRs to Done in Mangler May 22, 2017
@boopathi boopathi deleted the reuse-vars-4 branch September 18, 2017 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tag: New Feature Pull Request adding a new feature
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants