Skip to content

Commit

Permalink
fix: add constant violations to references in mangler collect phase (#…
Browse files Browse the repository at this point in the history
…830)

* fix: do not update references for constant violations renaming

fix #822

* add constant violations to references in mangler collect phase
  • Loading branch information
boopathi committed May 3, 2018
1 parent 8b90599 commit e9f96ff
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
@@ -0,0 +1,32 @@
function d3_svg_line(projection) {
var x = d3_geom_pointX,
y = d3_geom_pointY,
defined = d3_true,
interpolate = d3_svg_lineLinear,
interpolateKey = interpolate.key,
tension = 0.7;

function line(data) {
var segments = [],
points = [],
i = -1,
n = data.length,
d,
fx = d3_functor(x);
function segment() {
segments.push("M", interpolate(projection(points), tension));
}
while (++i < n) {
if (defined.call(this, (d = data[i]), i)) {
points.push([+fx.call(this, d, i)]);
} else if (points.length) {
segment();
points = [];
}
}
if (points.length) segment();
return segments.length ? segments.join("") : null;
}

return line;
}
@@ -0,0 +1,35 @@
function d3_svg_line(a) {
var c = d3_geom_pointX,
d = d3_geom_pointY,
e = d3_true,
f = d3_svg_lineLinear,
g = f.key,
h = 0.7;

function b(b) {
var j = [],
k = [],
l = -1,
m = b.length,
n,
o = d3_functor(c);

function g() {
j.push("M", f(a(k), h));
}

while (++l < m) {
if (e.call(this, n = b[l], l)) {
k.push([+o.call(this, n, l)]);
} else if (k.length) {
g();
k = [];
}
}

if (k.length) g();
return j.length ? j.join("") : null;
}

return b;
}
5 changes: 5 additions & 0 deletions packages/babel-plugin-minify-mangle-names/src/index.js
Expand Up @@ -131,6 +131,11 @@ module.exports = babel => {
// Collect bindings defined in the scope
Object.keys(scope.bindings).forEach(name => {
scopeTracker.addBinding(scope.bindings[name]);

// add all constant violations as references
scope.bindings[name].constantViolations.forEach(() => {
scopeTracker.addReference(scope, scope.bindings[name], name);
});
});
},

Expand Down

0 comments on commit e9f96ff

Please sign in to comment.