A Monorepo with multiple packages and a shared build, test, and release process.
View example โก๏ธ https://storybook-monorepo.now.sh/
- ๐ Lerna โ- The Monorepo manager
- ๐ฆ Yarn Workspacesโ - โSane multi-package management
- ๐ Reactโ - โJavaScript library for user interfaces
- ๐ styled-componentsโ -โ CSS in JS elegance
- ๐ Babelโ - โCompiles next-gen JavaScript
- ๐ Storybook - UI Component Environment
- ๐ Jestโ -โ Unit/Snapshot Testing
yarn dev
- This starts Storybook for viewing all the components locally.yarn bootstrap
- This installs all of the packages and links dependent packages together.yarn build
- This babelfies all of the packages and creates/lib
folders for each one.yarn test
- Run all linting and unit tests before committing.yarn test -o
- Run only the tests that have changed.yarn test -u
- Update all of the snapshot tests.
lerna changed
- Show which packages have changed.lerna diff
- Show specifically what files have cause the packages to change.
When linking inside of the Monorepo, everything works as expected. If you are trying to consume packages from this Monorepo in a different application locally, using npm link
or yarn link
does not work as expected. However, we have a workaround for the time being.
- Run
yarn build
- Run
yarn dev
- Change the
package.json
of the consumer from$YOUR_PACKAGE_NAME
(which lives inside the monorepo) tofile:./../monorepo/packages/$YOUR_PACKAGE_NAME
- Run
rm -rf node_modules && yarn
in the consumer - ๐
All formatting and linting should be taken care of for you using stylelint, ESLint, and Prettier. You should also consider installing an extension for CSS syntax highlighting.
It's a known issue that yarn workspaces using yarn versions > 1.18.0
can produce the following false positive error message when adding or updating dependencies in packages.
error An unexpected error occurred: "expected workspace package to exist for "XXX".
To guard against this, we've: