Installing Scroller's Dependencies
Installing dependencies for the Scroller library.
We don't want to include React and React-DOM in our package directly, but instead, have whoever uses our library provide it. In this case, we'll be installing React and React-DOM as peerDependencies. In the same directory as
yarn add react react-dom --peer. As you can see, we don't need to run separate
yarn add commands for each dependency.
yarn add takes single or multiple packages to install by separating the package names with whitespace.
Next, we'll need to install any development dependencies we'll be using. This may seem weird, but bear with me! In the same directory as
yarn add react react-dom esbuild --dev.
Yes, we're installing React and React-DOM twice... but not really! Remember in the last lesson when we talked about peer dependencies? These are libraries we expect the consumer of our library to provide - a contract. This means we won't be including React or React-DOM in our library. So, why did we install them as dev dependencies also? Well, to be able to test that the code we write is correct, we need some way of using React in a development setting, so we need to include
devDependencies. Don't worry! Both packages only get installed on the local disk once, because peer dependencies don't get downloaded.
Naturally, for a React library, we'll be needing React and React-DOM. What about ESBuild?