Skip to content

Use lodash per-method packages#7

Closed
Zirro wants to merge 1 commit into
request:masterfrom
Zirro:lodash-packages
Closed

Use lodash per-method packages#7
Zirro wants to merge 1 commit into
request:masterfrom
Zirro:lodash-packages

Conversation

@Zirro

@Zirro Zirro commented Sep 25, 2017

Copy link
Copy Markdown

The complete lodash package weighs in at about 5.1 MB, making it a very large production dependency. By using lodash's per-method packages instead, you can reduce the size of many node_modules folders out there.

I replaced ._isArray with Array.isArray() as the former has been deprecated in favour of the latter.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 9496ab4 on Zirro:lodash-packages into 77e4f18 on request:master.

3 similar comments
@coveralls

coveralls commented Sep 25, 2017

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 9496ab4 on Zirro:lodash-packages into 77e4f18 on request:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 9496ab4 on Zirro:lodash-packages into 77e4f18 on request:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 9496ab4 on Zirro:lodash-packages into 77e4f18 on request:master.

@analog-nico

Copy link
Copy Markdown
Member

Thanks a lot @Zirro !

Quick question: Is it safe to replace _.isArray() with Array.isArray() in old environments like node.js v0.10?

@Zirro

Zirro commented Sep 27, 2017

Copy link
Copy Markdown
Author

Yes, that should be okay. Array.isArray() was specified in ES5, so it’s been supported for quite a while. Even lodash uses it in their code :-)

@2PacIsAlive

Copy link
Copy Markdown

hey all, currently fighting to shave down the size of a node.js docker image and this would help a bit.. any update on this PR?

@CorWatts

CorWatts commented Dec 6, 2018

Copy link
Copy Markdown

What's the latest on this? Could we please get this merged in?

@joshuawinsor

Copy link
Copy Markdown

What is the hold up on merging this? Why was #14 merged instead of this one?

@realityking

realityking commented Feb 20, 2019

Copy link
Copy Markdown

Note that lodash intends to not support the per-method packages in lodash v5 https://github.com/lodash/lodash/wiki/Roadmap

@2PacIsAlive

Copy link
Copy Markdown

hey just checking in on this, based on the latest info from @realityking are you still planning on merging this in?

@analog-nico

Copy link
Copy Markdown
Member

If you are using a package bundler like Webpack then you will be able to reduce the code size even more than if this library would use the per method packages. Splitting the lodash packages apart actually required some code duplicates. Those don’t exist in the main lodash library. Thus the main lodash plus using a package bundler is the way to go. I hope that works for you!

@odinho

odinho commented Feb 17, 2020

Copy link
Copy Markdown

That doesn't really work no.

I'm trying to reduce the size of our build artifacts we have for a few node servers. We don't want to run webpack on the servers for many reasons. But doing it because a dependency of a dependency chooses to drag in the whole of lodash is a bit weird. This is the only package still having a full lodash import.

@mastermatt

Copy link
Copy Markdown

Just a note that Lodash discourages the use of the per method packages and is planing on removing them in the next major.
https://lodash.com/per-method-packages

@odinho

odinho commented Feb 17, 2020

Copy link
Copy Markdown

Yeah sure. The best thing is to stop using lodash for super basic stuff as this project is doing :)

Indeed at work we've removed all of lodash, with our own small specialized helpers for stuff like debounce etc that does what's needed. Most other stuff we've just rewritten to regular js.

Now with optional chaining obj?.prop there won't be any need to use a helper for nice "get"-ing even :)

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.