TooTallNate/node-gyp — pull request #460 by tmpvar (2014-06-17 01:14:10+00:00)
Title: WIP: double compile when installing dependent addons

This pull request adds a _failing_ test that simulates a `npm install` on an addon that uses build artifacts from a dependency. The issue is that the dependency will be built twice:

* once at dependency install time
* once at the root level `node-gyp rebuild`

Generally this doesn't matter as rebuilding a couple files is no big deal. However, when the dependency is something big like [skia](https://code.google.com/p/skia/) the build time is on the order of minutes. Multiply that by two and it becomes fairly annoying!

The following output is essentially what this test does. It's too bad there isn't a way to add a '../' to package.json (npm/npm#1558) to make this a bit more like case that you'd find in the wild, but I think that this properly exercises the issue.

```

node-gyp ~ parent (dependent-addons)‣ npm install ../child

> child@0.0.0 install /Users/tmpvar/work/js/node-gyp/test/test-dependent-addon/parent/node_modules/child
> node-gyp rebuild

CXX(target) build/Release/obj.target/child-static/child.o
LIBTOOL-STATIC build/Release/child-static.a
SOLINK_MODULE(target) build/Release/child.node
SOLINK_MODULE(target) build/Release/child.node: Finished
child@0.0.0 node_modules/child
node-gyp ~ parent (dependent-addons)‣ npm install

> child@0.0.0 install /Users/tmpvar/work/js/node-gyp/test/test-dependent-addon/parent/node_modules/child
> node-gyp rebuild

CXX(target) build/Release/obj.target/child-static/child.o
LIBTOOL-STATIC build/Release/child-static.a
SOLINK_MODULE(target) build/Release/child.node
SOLINK_MODULE(target) build/Release/child.node: Finished

> parent@0.0.0 install /Users/tmpvar/work/js/node-gyp/test/test-dependent-addon/parent
> node-gyp rebuild

CXX(target) build/Release/obj.target/child-static/node_modules/child/child.o
LIBTOOL-STATIC build/Release/child-static.a
CXX(target) build/Release/obj.target/parent/parent.o
LIBTOOL-STATIC build/Release/parent.a

```

If you'd like to see what drove me to looking into this:

```
git clone https://github.com/tmpvar/node-boosh.git
cd node-boosh
npm install
```
and watch it build context2d twice

I'll attempt to find a solution to this and am open to suggestions!