ink icon indicating copy to clipboard operation
ink copied to clipboard

perf: only import used lodash function

Open merceyz opened this issue 3 years ago • 2 comments

Updates the lodash import to only include the used function which improves startup time and reduces the size of Ink when bundled.

Ref https://github.com/yarnpkg/berry/pull/4315

merceyz avatar Apr 06 '22 20:04 merceyz

Per-method Lodash packages are deprecated → https://lodash.com/per-method-packages. I think we should use another npm package for this.

vadimdemedes avatar Jul 24 '22 18:07 vadimdemedes

I'm aware of that, however this PR doesn't use those packages.

merceyz avatar Jul 24 '22 19:07 merceyz

@vadimdemedes I think this pull request makes sense. Importing sub-exports of Lodash does improve loading time as Lodash is huge.

sindresorhus avatar Mar 11 '23 09:03 sindresorhus

@sindresorhus It wasn't possible to import throttle directly from lodash-es like so:

import throttle from 'lodash-es/throttle.js`

But it was possible with lodash, which seems to still be a CJS module. Would that be a problem for ESM-only Ink?

vadimdemedes avatar Mar 11 '23 11:03 vadimdemedes

Should be fine and also beneficial as lodash-es is also not maintained anymore.

sindresorhus avatar Mar 11 '23 13:03 sindresorhus