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

Lodash tree shaking #1852

Merged
merged 1 commit into from
Feb 23, 2024
Merged

Lodash tree shaking #1852

merged 1 commit into from
Feb 23, 2024

Conversation

ahuth
Copy link
Contributor

@ahuth ahuth commented Feb 23, 2024

This PR updates our usage of Lodash so that we replace named imports

import {at} from 'lodash';

with deep ones

import at from 'lodash/at';

This should help tree shaking work better. I don't think this is a problem in our existing Remix apps (tree shaking works properly), but I'm running into an issue when trying to use ESM modules in Remix apps.


Alternatives:

  • Use lodash-es instead (which is esm). Downside of that is we'd need to have our existing Remix apps pre-bundle lodash so that it's cjs.
  • Maybe there's some Vite config I'm missing to make this work

Instead of

  import { debounce } from 'lodash';

use

  import debounce from 'lodash/debounce';

This helps with tree shaking. In particular I ran into issues with this
when trying to update Remix apps to use Vite.

An alternative would be to use 'lodash-es' instead, which is esm modules.
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.61%. Comparing base (59267c3) to head (a997516).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #1852   +/-   ##
=======================================
  Coverage   92.61%   92.61%           
=======================================
  Files         148      148           
  Lines        2856     2856           
  Branches      776      776           
=======================================
  Hits         2645     2645           
  Misses        195      195           
  Partials       16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ahuth ahuth changed the base branch from main to next February 23, 2024 16:51
Copy link

size-limit report 📦

Path Size
components 98.08 KB (+0.01% 🔺)
styles 39.93 KB (0%)

Copy link
Contributor

@booc0mtaco booc0mtaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Looks like we don't have many outliers.

@ahuth ahuth merged commit f55f9cb into next Feb 23, 2024
10 checks passed
@ahuth ahuth deleted the ah-lodash-tree-shake branch February 23, 2024 17:06
ahuth added a commit that referenced this pull request Feb 23, 2024
@booc0mtaco booc0mtaco mentioned this pull request Mar 4, 2024
booc0mtaco added a commit that referenced this pull request Mar 4, 2024
## [13.12.0](v13.11.0...v13.12.0) (2024-03-04)

[Storybook](https://61313967cde49b003ae2a860-telsscxlak.chromatic.com/?path=/docs/getting-started--docs)

### Features

* export ClickableStyleProps ([#1860](#1860)) ([0d1b49e](0d1b49e))
* **Select:** add support for required in overline ([#1855](#1855)) ([6e44566](6e44566))


### Bug Fixes

* lodash tree shaking ([#1852](#1852)) ([f55f9cb](f55f9cb))
* **Select:** add max height for Select.Options ([#1858](#1858)) ([24ed8bc](24ed8bc))
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.

2 participants