-
Notifications
You must be signed in to change notification settings - Fork 10
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
WIP es2015, rollup config file, and source maps #73
Conversation
Woohoo! Thanks @micahstubbs this looks awesome. Will take a closer 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.
Thanks a ton @micahstubbs ! This ES2015ification really cleans things up.
Will verify tests locally & fix the setters for chainability.
@@ -16,7 +16,7 @@ | |||
"url": "https://github.com/curran/d3-component.git" | |||
}, | |||
"scripts": { | |||
"pretest": "rm -rf build && mkdir build && rollup -f umd -g d3-selection:d3 -n d3 -o build/d3-component.js -- index.js", | |||
"pretest": "rm -rf build && mkdir build && rollup -c", |
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.
Nice.
"uglify-js": "2" | ||
"uglify-js": "2", | ||
"eslint": "^2.9.0", | ||
"eslint-config-airbnb": "^9.0.1", |
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.
Awesome. I'm all for it - ESLint & Babel.
let pkg = require('./package.json'); | ||
let external = Object.keys(pkg.dependencies); | ||
|
||
export default { |
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.
A Good Thing, moving all this to a config file.
render = noop, | ||
destroy = noop, | ||
key; | ||
const setInstance = (node, value) => { node.__instance__ = value; }; // no operation |
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.
Oh wow, this stuff cleans up nicely with arrows.
instance && instance.destroy(); | ||
function destroyDescendant() { | ||
const instance = getInstance(this); | ||
if (instance) { instance.destroy(); } |
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 this is definitely more clear.
component.create = function(_) { return (create = _, component); }; | ||
component.destroy = function(_) { return (destroy = _, component); }; | ||
component.key = function(_) { return (key = _, component); }; | ||
component.render = (_) => { |
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'm guessing this change was ESLint-induced. I'll iterate on this part a bit more. These setters should return component
for chainability, like this:
component.create = (_) => {
create = _;
return component;
};
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.
@curran please do improve this. I actually manually refactored this, in response to an eslint error. I wasn't certain of the return value, and so took a guess.
the rule it complained about here is http://eslint.org/docs/rules/no-return-assign
This PR shows what an es2015 version of d3-component could look like.
new is a
rollup.config.js
file for easier rollup configuration, as well as source maps.still to do: