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.
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.