-
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
💄 JS files lose all unused vars and imports #100
Conversation
@@ -1,5 +1,4 @@ | |||
import * as d3 from 'd3'; | |||
import { union } from 'd3-array'; |
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.
union
is being used on line 130/129 no?
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.
Indeed, however that union
call is a native method in the Set prototype.
Check it:
Adding the following console logging to the js there:
let subgroups = Array.from(subgroups0.union(subgroups1));
console.log(subgroups0.constructor.name);
console.log(Set.prototype.union);
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.
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.
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.
Might be more backwards compatible to use the d3
implementation? assuming it does the same thing?
But I'm not sure how to even force it to actually do/ use that, and feels a bit out of scope for this PR
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.
Yeah, it must be a new-ish JS function. D3 used to provide stuff like that before they were available in vanilla JS. I guess luckily the syntax/interface/behavior is sufficiently similar.
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.
Well we can monitor it and if things start to seem off, we will know where to look :-)
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 suspect it is using a vanilla JS Set, and not an old-skool <=D3v4 set/map, but I don't really know the whole evolution of this code anymore, and it's spread out over multiple repos.
let subgroups0 = new Set(d3.map(subdataTechPerYear[0].stackedData, (d) => d.key).keys()); |
This PR is where things get a little spicy. I am simply removing every
var
andimport
that is unused!There are a few categories here:
var
or function argument was defined (and probably used at some point) and later removed from he function body, but left in the bodyvars
that are defined for their side-effects (you can just remove them and call the methods alone)This PR affects the following plots:
I will post side-by-sides of these plots before and after to show they still render (and I have visually inspected them to ensure all interactivity still functions as expected)
@MonikaFu FYI
Relates to #96
Towards #29