Temasys / AdapterJS

AdapterJS Javascript Polyfill and Tools for WebRTC - Skylink WebRTC
http://skylink.io/web
Other
429 stars 100 forks source link

Transitive dependencies not listed when AdapterJS used as direct dependency #262

Closed NTARelix closed 7 years ago

NTARelix commented 7 years ago

When adapterjs is a dependency of package mypackage and you attempt to view the dependencies of mypackage, none of the transitive dependencies installed by adapterjs show up in the dependency tree given by npm ls with respect to mypackage.

To demonstrate

  1. Create new package: $ mkdir mypackage && cd mypackage && npm init -y
  2. Install adapterjs as dependency: $ npm i -S adapterjs
  3. List all dependencies installed for mypackage: $ npm ls
    mypackage@1.0.0 /Users/ntarelix/mypackage
    └── adapterjs@0.14.1
  4. List all dependencies installed for adapterjs: $ cd node_modules/adapterjs/third_party/adapter/ && npm ls
    webrtc-adapter@2.0.3 /Users/ntarelix/mypackage/node_modules/adapterjs/third_party/adapter
    ├─┬ chromedriver@2.28.0
    │ ├── adm-zip@0.4.7
    │ ├── kew@0.7.0
    │ ├─┬ mkdirp@0.5.1
    │ │ └── minimist@0.0.8
    │ └── rimraf@2.6.1
    ├── eslint-config-webrtc@1.0.0
    ├─┬ faucet@0.0.1
    │ ├── defined@0.0.0
    ...

Notice how a lot more than just adapterjs was installed, but npm was unable to pick up on these dependencies because they were not listed as dependencies of adapterjs. It happens because adapterjs's package.json has a postinstall script that installs a submodule, webrtc-adapter.

This is problematic for a number of reasons. My particular problem comes from the setup of a private npm registry where I'm publishing all of my project's dependencies on a Nexus server semi-manually. I use npm ls to list all my dependencies and use that list to manually publish each listed version of each package individually. If they aren't listed with npm ls then they don't get published and cannot be installed by other packages later. This means adapterjs can't be installed using exclusively my private registry unless I npm ls from webrtc-adapter and also publish each of those dependencies.

Some other problems that I believe are also caused by this:

To solve this I believe it would be best to remove the postinstall script so nothing additional gets installed and because the distributables are already included when I npm i adapterjs. Not sure what the best practice alternative would be, but maybe putting it in a dev script and adding 1 more step to dev setup would be good enough.

NTARelix commented 7 years ago

Fixed in pull request: https://github.com/Temasys/AdapterJS/commit/9ebafbef9a95aa8daf6b25d6d5e5dddb59e1d407