How to require lodash/fp

Has anyone figured out a way to import lodash/fp (the functional variant of lodash)?

Both of these ways don’t seem to work.

_ = require('lodash/fp')
_ = require('https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)')

That took some sleuthing due to idiosyncrasies in how lodash publishes, but here you go:

3 Likes

Thanks Mike! You are the best!

1 Like

Should I use this approach to require individual functions? This doesn’t seem to work:

I also tried require('lodash/uniq').

you could do this

uniq = require('lodash.uniq').catch(() => window.uniq)

or use skypack to load it

uniq = (await import("https://cdn.skypack.dev/lodash.uniq")).default
1 Like