-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improved monorepo docs #2969
improved monorepo docs #2969
Conversation
README.md
Outdated
|
||
Since now all the packages live under a single repository it might be confusing how to import different modules into the file you're working on. | ||
|
||
If you are working on `cbioportal-frontend` repository feel free to import any module from any package under `packages`. When importing from internal packages always use import statements like `import {something} from 'cbioportal-frontend-commons'`. Never do under any circumstances something like `import {something} from ../../packages/cbioportal-frontend-commons/src/lib/someLib` or `import {something} from ../../packages/react-mutation-mapper/src/component/someComponent`. Treat internal packages like any other npm package you would import. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to have a circle ci check or github action for this at some point, could be as simple as
git grep -q "../packages/" src/** && exit 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but maybe this is already caught by the build process itself?
README.md
Outdated
|
||
If you are working on `cbioportal-frontend` repository feel free to import any module from any package under `packages`. When importing from internal packages always use import statements like `import {something} from 'cbioportal-frontend-commons'`. Never do under any circumstances something like `import {something} from ../../packages/cbioportal-frontend-commons/src/lib/someLib` or `import {something} from ../../packages/react-mutation-mapper/src/component/someComponent`. Treat internal packages like any other npm package you would import. | ||
|
||
Avoid circular dependencies at all costs. For example, while it is okay to import a module from `cbioportal-frontend-commons` in `react-mutation-mapper`, there should not be any imports from `react-mutation-mapper` in `cbioportal-frontend-commons`. If you happen to need some component from from `react-mutation-mapper` in `cbioportal-frontend-commons`, consider moving that component into `cbioportal-frontend-commons` package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does adding a circular dependency result in some error while building?
README.md
Outdated
|
||
### Updating existing packages | ||
|
||
Whenever you need to update code under packages, you should also consider updating the version number in the corresponding `package.json` as well as the dependencies of other packages depending on the package you updated. For example if you update the `cbioportal-frontend-commons` version from`0.1.1` to `0.1.2`, corresponding `cbioportal-frontend-commons` dependency in the `package.json` for `react-mutation-mapper` and `cbioportal-frontend` should also be updated to the new version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a lerna or yarn workspace command that can help with this?
README.md
Outdated
### Updating existing packages | ||
|
||
Whenever you need to update code under packages, you should also consider updating the version number in the corresponding `package.json` as well as the dependencies of other packages depending on the package you updated. For example if you update the `cbioportal-frontend-commons` version from`0.1.1` to `0.1.2`, corresponding `cbioportal-frontend-commons` dependency in the `package.json` for `react-mutation-mapper` and `cbioportal-frontend` should also be updated to the new version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kinda same here as with other comments. Should prolly be some ci or lerna/yarn build failure when trying to build something that refers to an older version of a package included in the monorepo? I guess in some cases this might be desired behavior but ideally we would avoid that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @onursumer ! This looks good to me
If necessary we can open some issues about the questions I raised. I think ideally most of these things would be taken care of by the build process, so developers are alerted early about these pitfalls. If that's not the case or the messages the build process spits out are too cryptic, we can add some CI checks
afe6f84
to
a4859bb
Compare
@Luke-Sikina have a look at the documentation for monorepo and let me know what you think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few tiny things, but it looks reasonable. Any comment prefixed Suggestion:
is optional. As far as the updating of version numbers goes, is there a simple way to make sure we corrected the version numbers of all workspaces that depend on the one we changed?
@@ -271,6 +271,31 @@ In order to add a new workspace, one should create a new directory under `packag | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 268 typo: pakcages
instead of packages
@@ -271,6 +271,31 @@ In order to add a new workspace, one should create a new directory under `packag | |||
|
|||
Suggested way to add a new dependency to an existing workspace is to run `yarn workspace <workspace name> add <package name>` instead of just `yarn add <package name>`. For example, run `yarn workspace cbioportal-frontend add lodash` instead of `yarn add lodash`. Similarly to remove a package run `yarn workspace <workspace name> remove <package name>`. | |||
|
|||
### Tips for dependency management |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: add a subheading titled Adding a New Workspace
before line 270. You already have the information, but it doesn't stand out.
The cBioPortal uses a monrepo. In a monorepo, multiple related packages are housed in single repository and published separately. E.g. the main portal project (cbioportal-frontend) lives in the same repository as the libraries which it uses, but which are also | ||
published for use by other projects. Please abide by the following rules for working in a monorepo: | ||
|
||
1. If you are working on `cbioportal-frontend` repository, import modules from packages using the package's alias: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I like these tips.
README.md
Outdated
|
||
Remember that the packages are used by other projects and compatibility needs to be carefully managed. | ||
|
||
Whenever you need to update code under packages, you should also consider updating the version number in the corresponding `package.json` as well as the dependencies of other packages depending on the package you updated. For example if you update the `cbioportal-frontend-commons` version from`0.1.1` to `0.1.2`, corresponding `cbioportal-frontend-commons` dependency in the `package.json` for `react-mutation-mapper` and `cbioportal-frontend` should also be updated to the new version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from
0.1.1
you're missing a space character.
a4859bb
to
4af7f48
Compare
Added tips for dependency management and package.json updates.
Checks
Any screenshots or GIFs?
If this is a new visual feature please add a before/after screenshot or gif
here with e.g. GifGrabber.
Notify reviewers
Read our Pull request merging
policy. It can help to figure out who worked on the
file before you. Please use
git blame <filename>
to determine thatand notify them either through slack or by assigning them as a reviewer on the PR