yocontra / glob2base

Extracts a base path from a node-glob instance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`lodash.findindex` dependency creates deep path of dependencies

iki opened this issue · comments

This is not a bug per se. Instead, it triggers related bugs in MSysGit (git for windows) msysgit/git#122 + msysgit/git#212, and breaks git repos that use https://github.com/gulpjs/gulp/ and have node_modules checked it.

Even when git config core.longpaths true, some files are not handled correctly on Windows and even when commited from cygwin or linux vm, they are still reported by git status:

node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._basecreatecallback/node_modules/lodash._setbinddata/
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._basecreatecallback/node_modules/lodash.bind/node_modules/
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._basecreatecallback/node_modules/lodash.identity/LICENSE.txt
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._basecreatecallback/node_modules/lodash.identity/package.json
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._basecreatecallback/node_modules/lodash.support/node_modules/
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._basecreatecallback/node_modules/lodash.support/package.json
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._baseisequal/node_modules/lodash._getarray/node_modules/
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash._baseisequal/node_modules/lodash._releasearray/node_modules/
node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/lodash.findindex/node_modules/lodash.createcallback/node_modules/lodash.keys/node_modules/lodash._shimkeys/node_modules/

The obvious workaround until fixed MSysGit is released, is to go to glob2base directory in node_modules tree and replace the lodash.findindex dependency with lodash, which weights same ~0.25 MB, but does not create the deep subtree:

rm -r node_modules/lodash.findindex/
sed -i "s/lodash\.findindex/lodash/" package.json
sed -i "s/lodash\.findindex')/lodash').findIndex/" index.js
npm install --production  #skip devDependencies
rm -r node_modules/lodash/dist/  # not needed 0.75 MB

Just a heads up. lodash v3 has significantly reduced the dep graphs of its modularized packages:

lodash.findindex@3.0.0
└─┬ lodash._basecallback@3.2.0
  ├─┬ lodash._baseisequal@3.0.1
  │ ├── lodash.isarray@3.0.0
  │ └── lodash.istypedarray@3.0.0
  ├── lodash._bindcallback@3.0.0
  └─┬ lodash.keys@3.0.3
    ├── lodash.isarguments@3.0.0
    ├── lodash.isarray@3.0.0
    └── lodash.isnative@3.0.0