Migrate from lodash to lodash-es#125
Conversation
|
I just released 4.5.4-alpha.0 with this change. I tested this on browser, browser with importmaps, react-native and react-native with expo. They all worked! I'm going to give it another try on the weekend, and make a release if everything goes well! |
|
@Bengejd would you consider using https://es-toolkit.dev/compatibility.html here? It's API-compatible with lodash/lodash-es, but much, much smaller. |
| @@ -1,4 +1,4 @@ | |||
| import camelCase from "lodash/camelCase"; | |||
| import camelCase from "lodash-es/camelCase"; | |||
There was a problem hiding this comment.
Would it be possible to avoid the subdirectory-style imports and move to import { functionname } from 'lodash-es'? Asking because it's an impediment to aliasing lodash-substitutes like es-toolkit.
I believe that would be a decision that @fnando would have to make, as that fundamentally changes what the library depends on. Whereas this PR is simply changing the flavor of I encourage you to make your case in a separate PR or issue though, as the request is out of scope for this one at this time. |
|
@Bengejd makes sense. My second comment (about import format) should still be possible and makes user-level overrides much easier to accomplish if that's possible to consider. |
|
@geoffharcourt that seems reasonable to me. @fnando what are your thoughts? |
PR Checklist
PR Structure
PRs).
two PRs otherwise).
Thoroughness
fixes.
.mdfiles, etc… affected by this change.What
This PR migrates usage of
lodashto utilize thelodash-esbuild variant for better tree-shaking support.Why
lodash-esis the ESM build of lodash, which allows bundlers to tree-shake unused utility functions rather than including the entire library. Since this package targets modern bundler environments, usinglodash-esreduces the final bundle size for consumers. It also addresses issues brought to light in #111.Because
lodash-esships pure ESM, Jest cannot consume it directly in its default CommonJS environment. To support this, two changes were made to the dev/test setup:@babel/preset-envwas added and configured viababel.config.jsto transform ESM to CJS at test timetransformIgnorePatternsinjest.config.jswas updated to allowlodash-esto be transformed (Jest skipsnode_modulesby default)All tests are passing.
Known limitations
N/A