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

Swap lodash.throttle dependency in @uppy/status-bar with lodash #4272

Closed
2 tasks done
dolphinigle opened this issue Jan 11, 2023 · 3 comments · Fixed by #4274
Closed
2 tasks done

Swap lodash.throttle dependency in @uppy/status-bar with lodash #4272

dolphinigle opened this issue Jan 11, 2023 · 3 comments · Fixed by #4274
Labels

Comments

@dolphinigle
Copy link
Contributor

dolphinigle commented Jan 11, 2023

Initial checklist

  • I understand this is a feature request and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Problem

@uppy/status-bar currently uses lodash.throttle to import lodash's throttle function. However, lodash is deprecating individual packages like lodash.throttle in favor of directly using the lodash package ( https://lodash.com/per-method-packages ). lodash.throttle is also causing problems with Jest for some reason I still haven't been able to debug:

https://github.com/transloadit/uppy/blob/main/packages/%40uppy/status-bar/src/Components.jsx#L3

import throttle from 'lodash.throttle'

throttle would be undefined here when run with Jest. import * as throttle from 'lodash.throttle', import { throttle } from 'lodash', and const throttle = require('lodash.throttle') all works.

In our code, we ended up using yarn patch to move the dependency from lodash.throttle to lodash. It might be a good idea to do it here too.


memoize-one import is also causing problem with Jest ( https://github.com/transloadit/uppy/blob/main/packages/%40uppy/dashboard/src/Dashboard.jsx#L10 ), but we're not sure this is related. We similarly patch this using yarn patch in our codebase. These are the only two import statements that are causing problem with Jest in our codebase.

Solution

Migrate from lodash.throttle to lodash perhaps?

Alternatives

Never upgrade to lodash v5 in the future?

Thank you for the great library!

@Murderlon
Copy link
Member

Hi, since individual packages are being deprecated it's indeed best to migrate. Are you willing to make a PR for it?

@dolphinigle
Copy link
Contributor Author

@Murderlon I'd be happy to!

@dolphinigle
Copy link
Contributor Author

For future googlers, fixed this issue by setting "esModuleInterop": true in my tsconfig.json

aduh95 added a commit that referenced this issue Jun 19, 2023
Fixes: #4272
Co-authored-by: R <r@r.com>
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants