-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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/fp
with ESM
#5285
Comments
I only found a way to use it in an ESM package, like: |
import fp from 'lodash/fp.js';
const {pipe, map, pickBy} = fp; ...seems to work. |
I don't think tree shaking will work like this. |
Why...? Why wouldn't lodash-es also have the fp functions... Seriously... lodash CJS/ESM is a total mess. It should really be an hybrid CJS/ESM package under the same name with everything available (Using |
It’s because lodash-fp is a wrapper around lodash which makes it difficult to modularize |
Wouldn't it just require yet another specialized transformation in the lodash cli for it? Same way that lodash-fp itself is created? |
I would require some tweaking and was technically possible with some back bending however, it’s been like 8yrs now so can say this confidently, FP in JavaScript is an anti pattern for work in teams and anything perf critical. I’m okay not investing in it going forward. |
What would you suggest for use as an alternative to |
To jump into this discussion, I use the Babel pipeline operator and current proposal relies on non-FP functions. So stuff like this should work:
Drawback is that it isn't currently supported by TypeScript and that the proposal doesn't proceed a lot. Still I think that chained function calls without pipe doesn't scale. |
Chain and tree-shaking (happens during bundling in rollup) do not work well together. Unfortunately we cannot use flow for all functions as we cannot import lodash/fp functions with lodash-es, see also: lodash/lodash#5285
Is there any chance of reviving this topic? Lodash/FP is absolutely needed, ESM is needed too |
Just use Ramda 😉 |
Is there anyway to use ESM with
lodash/fp
? I triedlodash-es
but it looks like fp functions are not published as part of that pacakge.The text was updated successfully, but these errors were encountered: