babel-upgrade icon indicating copy to clipboard operation
babel-upgrade copied to clipboard

Add babel-plugin-lodash if in dependencies

Open hzoo opened this issue 6 years ago • 4 comments

https://twitter.com/kentcdodds/status/976808822307094528

Should be easy to do. Detect if lodash is used as a direct dependency and then add a new plugin? Not sure about the version or if we need to use the "latest version" package on npm to do that.

hzoo avatar Mar 22 '18 13:03 hzoo

a cursory idea at what might be involved, in case any first-time contributor needs some direction:

  1. in updateDeps.js, check for dependencies['lodash'] (reference flow, babel-loader portions for potentially similar logic)
  2. add babel-plugin-lodash to deps with appropriate version
    • version determination might be the most complex part of this -- perhaps we need to use the npm registry api?
  3. update tests to make sure regressions in this functionality will be caught!

noahlemen avatar Mar 24 '18 17:03 noahlemen

Looks like there was a similar issue open on the create-react-app project about a year ago.

Use of the _.chain API (supported in all current versions of lodash) breaks babel-plugin-lodash.

The good news is that chain is soon-to-be-deprecated with the release of lodash v.5.0.0 sometime this year.

It isn't clear how many projects would be affected by this, but maybe it is best to provide a warning or simply wait until chain is officially deprecated before moving forward?

ghost avatar Apr 14 '18 03:04 ghost

bummer. nice find though!

looks like some process has been made towards supporting this? https://github.com/lodash/babel-plugin-lodash/pull/176 -- sounds like it's not completely supported still

I'd vote towards holding off on this until it can be done safely for anyone using lodash. perhaps, as a compromise, we could detect if the user depends on lodash and is not using babel-plugin-lodash, and then log a suggestion to add it?

noahlemen avatar Apr 14 '18 03:04 noahlemen

@kedromelon Nah the maintainer of lodash decided to revert that for some unknown reason https://github.com/lodash/babel-plugin-lodash/issues/210 https://github.com/lodash/babel-plugin-lodash/issues/219

hipstersmoothie avatar May 29 '18 22:05 hipstersmoothie