Closed mstade closed 8 years ago
As we grow the list of dependencies ez-build needs to do its job, it'll become unmanageable to have to add these on a per project basis. This PR takes care of it by automatically installing any missing dependencies, and verifying the semver compatibility of any already installed ones. This means the only dependency a project ever really needs is ez-build itself.
After reviewing this with the gang we decided that ez-build shouldn't rely on peer dependencies, and not automatically install anything at runtime. Instead, it should just specify these things as regular dependencies, with a flexible specification (i.e. something like ^6
to pick up everything up until v7.) This will mean if anyone needs a new version of babel, they'll just re-install ez-build and it should pick up whatever is the latest compatible one. This should be the case for all compiler dependencies, so postcss etc. as well.
This will ensure that all dependencies of ez-build are installed, yet still allow for the overriding of dependencies in the target environment. It works by checking the installed packages of the project (not necessarily what's in package.json) and verifies the information against a hard coded list of dependencies.
(N.B.: we may want to switch this hardcoded list to just using npm's peerDependencies feature. This will also not automatically install the peer dependencies, but we make it more explicit what dependencies are in fact involved.)
If all dependencies are installed, nothing happens; but for any dependency that is missing ez-build will automatically call npm to install it before building anything. On subsequent runs, no installation will happen as long as the dependency is not removed.
This will not modify the project's package.json.
Ideally, this will mean projects do not directly depend on babel and plugins thereof, but rather implicitly depend on them. However, should projects depend on additional plugins, such as the react preset, they must still include these in their list of dev dependencies.