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

Utilize lodash-es in es builds. #206

Merged
merged 1 commit into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
"presets": [
"./build/preset-es2015",
"stage-0"
]
],
"env": {
"es": {
"plugins": [
"./build/use-lodash-es"
]
}
}
}
10 changes: 10 additions & 0 deletions build/use-lodash-es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = function useLodashEs() {
return {
visitor: {
ImportDeclaration(path) {
const source = path.node.source;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work?

const { node: { source } } = path;

Not a big deal, just curious. It's a bit less verbose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. Its a fairly small piece of functionality isolated from the majority of the code base. I personally wouldn't spend too much time on worrying about aesthetic changes.

But if you have a really strong opinion here, I can attempt to make the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

No strong opinion, just thinking out loud.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 appreciate you taking a look at everything

source.value = source.value.replace(/^lodash($|\/)/, 'lodash-es$1');
}
}
};
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"dependencies": {
"invariant": "^2.2.1",
"lodash": "^4.13.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need lodash then? I don't have familiarity with lodash-es and the change in .babelrc, maybe you could give some context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. lodash will still be used in the source code. The only piece that changes is the es compiled files.These distribution files are rewritten to utilize lodash-es instead of lodash.

"lodash-es": "^4.17.4",
"reduce-reducers": "^0.1.0"
}
}