A monorepo project template for components and utils.
Before developing package in this repo, make sure you understand the following clearly:
- The repository only contains rendering components and utils, which is all I need.
- There isn't any environment, e.g. backend api, client webview etc.
Initialize project with yarn
.
yarn
- Checkout feature/hotfix branch from master.
- Develop your package.
- Prelease beta package for testing on your branch.
- Merge back to master and release stable version.
yarn run dev
Dev server runs at http://localhost:6006/ and it will automatically open the browser for development.
yarn run create
# add dependencies at root
yarn add -W packageName
# remove dependencies at root
yarn remove -W packageName
# add dependencies for specific package
cd packages/packageDir
yarn add packageName
# remove dependencies for specific package
cd packages/packageDir
yarn remove packageName
- react: component
- styled-components: styles
- storybook: doc & preview
- webpack: bundler
- jest: test
When developing on feature/hotfix branch(we are not allow to develop on trunk master), we prerelease alpha package with dist-tag next
to npm registry.
Then publish your package
# on feature/hotfix branch
yarn run release
Anyone who use the beta package should install it with tag next
or the specific beta version, otherwise you will get the latest stable version.
# install with tag next
yarn add packageName@next
# or with specific beta version
yarn add packageName@1.0.0-beta.1
To release stable package, you should create merge request to merge code back to trunk master, and then release stable version.
# on master branch
yarn run release
No, you can't. We don't integrate any environment, so you have to pass the function down via props, which is a kind of IOC(invasion of control).
Because we use source files to build artifact package, there are files in other packages which are outside of "src" folder. Tsc(typescript compiler) will emit declaration files with folder "packageName/src", for detail see: https://stackoverflow.com/questions/52121725/maintain-src-folder-structure-when-building-to-dist-folder-with-typescript-3 and https://github.com/Microsoft/TypeScript/wiki/FAQ#why-does---outdir-moves-output-after-adding-a-new-file.
The simple solution is add "types": "dist/packageName/src" to "package.json"