Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it still necessary toimport isNill from lodash.isNill instad ofimport {isNil} from lodash?#5742

Answeredbyjdalton
seyyedhassanpour asked this question inQ&A
Discussion options

why we need to use

importgroupByfrom'lodash.groupby'importisNilfrom'lodash.isnil'

instead of below?

import{groupBy,isNil}from'lodash'

is this still needed?

There are a bunch ofdifferent approaches and results and most of the are for 2020, 2019 or older.
What is the rightway? can we use a syntax like this

import {groupBy,isNil} from 'lodash' or 'lodash-es'

And what is the difference between the lodashandlodash-es`?
It would greatly appreciated it if anyone shed some light on this topic.

You must be logged in to vote

For modern environments you should import from lodash-es.

import{groupBy}from'lodash-es'

Replies: 1 comment 4 replies

Comment options

For modern environments you should import from lodash-es.

import{groupBy}from'lodash-es'
You must be logged in to vote
4 replies
@seyyedhassanpour
Comment options

Thank you for your response. It would be greatly appreciated if you answer this one:
With this pattern, all the package wont be included into final bundle?

@ZachHaber
Comment options

Assuming that none of your other dependencies rely on the base 'lodash' package, that's correct. If they do, however, you will likely get double lodash included.

@hellohejinyu
Comment options

Assuming that none of your other dependencies rely on the base 'lodash' package, that's correct. If they do, however, you will likely get double lodash included.

importgroupByfrom'lodash/groupBy'

What will happen if I use it like this?🧐

@ZachHaber
Comment options

What will happen if I use it like this?🧐

Then you'll get doublegroupBy if you have the fulllodash imported anywhere already... Triple if you also havelodash-es, and quadruple if you also havelodash.groupBy... etc... 😢

There are so many different way to accidentally end up with multiple lodash packages installed.

Answer selected byjdalton
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
4 participants
@seyyedhassanpour@jdalton@hellohejinyu@ZachHaber

[8]ページ先頭

©2009-2025 Movatter.jp