proposed
The project can either use npm
or yarn
as the package manager. This should be an either/or situation but a number of issues have been encountered when using yarn
including:
yarn login
still prompts for a password at release time which doesn't work withnp
- publishing with
yarn
leaves only theindex.js
file in thelib
directory
-
Use
yarn
and fix the existing issuesYarn
is more widely used across the team's, and wider department's, projects so it would present a more consistent approach. There are more examples of common tasks written inyarn
from our existing projects and developer's are more likely to default to runningyarn
commands. -
Use
npm
Given that issues have been encountered using
yarn
and the fact thatnpm
provides a working alternative with no obvious drawbacks (save the more common use ofyarn
in the department), it's not worth fixing theyarn
issues. -
Use
npm
but use the script pattern to make it (more) opaque to the userThe script pattern abstracts the choice of package manager (and the implementation of various tasks) away from the user. This would allow whichever tool was the best fit to be used across all projects whilst maintaining a consistent experience for developers.
Use npm with the script pattern.
Any common tasks (e.g. lint
, test
, build
) should have a script defined in the script
directory. Any scripts run by CI should also be stored in this directory.
Using the script pattern allows us to present a consistent interface whilst using whichever tool works best. Further to that, it makes it easier for new developers coming to a project as they don't have to know the specific commands to perform each task. Instead, they can easily see the available commands and run them simply by name.
This pattern becomes increasingly useful the more projects it is used in as developers get used to going to the ./script
directory rather than running command directly. Without common usage across the team it risks becoming a third standard rather than a replacement for the previous two (Relevant XKCD).