`Cannot find module 'underscore'` when using apiCompatibilityChecks
rochdev opened this issue · 6 comments
The best way to solve this would be to remove the dependency on underscore, but otherwise the library should depend on underscore.
Since underscore is only used for _.each
, I think it would be easier to just replace it with [].forEach
or with a plain for loop.
@rochdev @yurishkuro adding an underscore
dep for the tests seems totally reasonable to me... it's a small (and somewhat ubiquitous) package. Any reason not to just do that? (for
can have so many caveats in .js-land that I try to avoid it even when it's safe)
Since there is no such thing as a test dependency, it would need to be added to dependencies
which would also load it for production use. I totally disagree that underscore is ubiquitous since most developers have migrated from underscore to lodash (ref).
As you can see here, underscore's _.each
is actually just wrapping a for
loop, so the argument against for
is invalid.
I am willing to send a PR that removes the dependency on underscore.
Given how minimal the underscore usage is, removing it sounds good to me. 👍
Since there is no such thing as a test dependency
You had me with that bit – sorry to be a little ignorant about the .js universe. So yes, a PR is great if you're up for it.
PS: my point about underscore was not that it was the most popular, but just that it is widely-used (which it is, lodash or not).
PPS: IMO the _.each
impl pointer you provided is a lot more than wrapping a for
loop... e.g., it calls through https://github.com/jashkenas/underscore/blob/master/underscore.js#L990 etc: precisely the sort of compatibility madness that has bitten many a javascript programmer who's "just trying to iterate over a dictionary".