Skip to content

Utilize lodash-es in es builds.#206

Merged
globalchubby merged 1 commit into
redux-utilities:masterfrom
jaridmargolin:lodash-es
Apr 16, 2017
Merged

Utilize lodash-es in es builds.#206
globalchubby merged 1 commit into
redux-utilities:masterfrom
jaridmargolin:lodash-es

Conversation

@jaridmargolin

Copy link
Copy Markdown
Contributor

This pattern exists in a few libraries that often coexist with redux actions:

https://github.com/reactjs/redux/blob/master/build/use-lodash-es.js
https://github.com/rt2zz/redux-persist/blob/master/tools/use-lodash-es.js

Without this patch, my bundle contains lodash-es and lodash modules. With the patch included, I was able to shave off a few gzipped KBs by sharing the already required/included lodash-es modules.

@globalchubby globalchubby self-requested a review April 4, 2017 03:57
@globalchubby

Copy link
Copy Markdown
Contributor

Thanks @jaridmargolin, I'll take a look this weekend. How many bytes are saved when running https://github.com/acdlite/redux-actions/blob/master/package.json#L12?

Comment thread build/use-lodash-es.js
return {
visitor: {
ImportDeclaration(path) {
const source = path.node.source;

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread package.json
@@ -62,6 +62,7 @@
"dependencies": {
"invariant": "^2.2.1",
"lodash": "^4.13.1",

Copy link
Copy Markdown
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
Copy Markdown
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.

@jaridmargolin

Copy link
Copy Markdown
Contributor Author

I don't believe there will be any effect on UMD builds. The purpose here is just to reduce the duplicated lodash module included while building es source.

@globalchubby globalchubby merged commit 41780a2 into redux-utilities:master Apr 16, 2017
@jaridmargolin

Copy link
Copy Markdown
Contributor Author

🙌 thanks!

@globalchubby

Copy link
Copy Markdown
Contributor

@jaridmargolin can you respond to #208 (comment)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants