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

Import throttle lodash function directly #511

Merged
merged 1 commit into from
Mar 11, 2023

Conversation

merceyz
Copy link
Contributor

@merceyz merceyz commented Apr 6, 2022

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

Ref yarnpkg/berry#4315

@vadimdemedes
Copy link
Owner

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

@merceyz
Copy link
Contributor Author

merceyz commented Jul 24, 2022

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

@sindresorhus
Copy link
Collaborator

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

@vadimdemedes vadimdemedes changed the title perf: only import used lodash function Import throttle lodash function directly Mar 11, 2023
@vadimdemedes
Copy link
Owner

@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?

@sindresorhus
Copy link
Collaborator

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

@sindresorhus sindresorhus merged commit 025c10f into vadimdemedes:master Mar 11, 2023
@merceyz merceyz deleted the patch-1 branch March 11, 2023 18:24
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.

None yet

3 participants