question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lodash-cherry-pick

See original GitHub issue

Hello!

We want to use mobx-react-form in our application, but we cannot because we use the old lodash version (3.x) globally on the whole site, so sooner or later we can clash with the some lodash breaking changes (3.x vs 4.x). I think that peer dependency on the lodash is very bad. Probably you need to drop the lodash dependency or include it in the library bundle (drop it from the webpack.config.babel.js/externals section).

Probably the best solution will be cherry picking individual lodash functions, for example: import intersection from "lodash/intersection" Also you can use this plugin https://github.com/lodash/babel-plugin-lodash.

I can help with the pull request if you approve.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
vkrolcommented, Oct 7, 2016

If I add the babel-plugin-lodash to the .babelrc then this line of code https://github.com/foxhound87/mobx-react-form/blob/master/webpack.config.babel.js#L29 become useless and imported lodash methods will be included in the umd build. Is this the desired result?

1reaction
vkrolcommented, Oct 6, 2016

We can add it for sure, this should lighten the commonjs build.

Thanks. I will create the PR tomorrow.

Anyway I suppose that your issue with the older lodash version should occur only using the UMD build.

If you use commonjs instead, the version of the package’s dependencies should remain the version specified in the package.json despite you are using an older one in your project.

Tell me if I’m wrong.

Yes, you are right. I am sorry for the confusion. But the cherry picking is the good thing anyway 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Aggregating Cherry-Picked Lodash Methods In An Application ...
Ben Nadel demonstrates how to aggregate and package cherry-picked Lodash methods in an application module in JavaScript.
Read more >
Lodash
Review the build differences & pick one that's right for you. ... Cherry-pick methods for smaller browserify/rollup/webpack bundles.
Read more >
Lodash unable to use chain with cherry pick import
import chain from lodash/chain only works if there is a default export from the module. If you want to import a particular named...
Read more >
ckotzbauer/lodash-loader - GitHub
This Webpack loader cherry-picks Lodash functions and require them explicitly to reduce the webpack bundle size. Installation. npm install lodash-loader ...
Read more >
Correct, can probably 'cherry pick' the method npm i
can probably 'cherry pick' the method npm i --save lodash.uniqueid and import it in the file as so import uniqueId from 'lodash.uniqueid'
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found