This has several reasons, benefits and consequences:
- When running on root (which is not recommended anyway), `npm run build` was already necessary.
- This allows to not use the `prepublish` hook, whose behavior is going to change in npm v5 and again in npm v6.
- This allows to create both production and development builds when running from source.
- It makes `npm run build` compatible with Windows again for development environments (lost in previous commit).
- It uses the `prepublishOnly` hook added in npm v4. Since this hook is not available prior to that, deployment to npm from Travis has to be done on the Node.js v7 environment.
We are seeing more and more people installing on Node v7 so it's important to ensure `npm install` will pass correctly and our (limited but growing) test suite as well.
OSX builds have been nothing but a pain on Travis CI: they fail with no good reason, they stay pending forever, etc.
As far as I can tell, I can't remember one valid build they failed and we legitimately discovered a bug. Dev env on OSX is very close to Linux so it's good enough to have it here.
This allows for a more meaningful build: if a newer version of a sub-package breaks,
builds would still pass as it uses the cached version. This uses a cache for downloaded packages instead.
I am expecting this to slow down a little bit the builds (but we are OK overall)
but be more accurate in practice.
See https://docs.npmjs.com/cli/cache#configuration and https://docs.npmjs.com/files/folders#node-modules.