-
Notifications
You must be signed in to change notification settings - Fork 534
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
Add npm workspaces structure to primer/react #3074
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
49ddd03
test(axe): default `color-contrast` check to false
joshblack 485cbe7
chore: update generate script to not conditionally disable contrast c…
joshblack 2e1debf
Create adr-015-npm-workspaces.md
joshblack e1a819d
Merge branch 'main' into joshblack-patch-2
joshblack b7fac68
Merge branch 'joshblack-patch-2' of github.com:primer/react into josh…
joshblack ff6d7ae
docs: update adr
joshblack 0530fb7
Update adr-015-npm-workspaces.md
joshblack f66229b
Merge branch 'main' into joshblack-patch-2
joshblack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# ADR 015: NPM Workspaces | ||
|
||
## Status | ||
|
||
Proposed | ||
|
||
## Context | ||
|
||
> tl;dr | ||
> | ||
> We have workspaces within the project but no official way of connecting them or managing dependencies from the top-level. Similarly, scripts that grow in size or complexity have no dedicated home or ability to manage dependencies outside of the top-level workspace. | ||
|
||
The `primer/react` repo is composed of several workspaces that use `npm` to manage dependencies. In order to install these dependencies, a contributor needs to visit each directory and run `npm install`. The project also has a convenience script for this task, invoked through `npm run setup`, that goes through this process for contributors. | ||
|
||
These distinct workspaces may sometimes depend on each other. For example, the `docs` workspace depends on the `@primer/react` package which is defined at the top-level of the project. Similarly, examples in the `examples/*` folders may also depend on `@primer/react`. Currently these dependencies are expressed either through relative paths, file dependencies in `package.json`, or symlinks through `npm link`. | ||
|
||
There is also a collection of scripts under the `script` directory that exist in the project that involve varying levels of complexity and depth. | ||
|
||
## Looking forward | ||
|
||
As the project grows, we may look into supporting additional workspaces within the project in the form of experimental components or internal workspaces for projects the team is working on. We may also want a tighter integration between workspaces with respect to the `@primer/react` dependency so contributors don't have to worry about resolving or linking to the correct package during development. | ||
|
||
## Decision | ||
|
||
Setup the project to use [`npm` workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces). This will require changing the project to have a top-level `package.json` file which will use `workspaces` to reference child workspaces. The layout for the project would then be: | ||
|
||
``` | ||
- root | ||
# Root package.json, defines workspaces | ||
- package.json | ||
|
||
# Workspaces | ||
- docs | ||
- packages | ||
- react | ||
- * | ||
- examples | ||
- nextjs | ||
- consumer-test | ||
- * | ||
|
||
# Top-level scripts | ||
- script | ||
|
||
# Testing & Development | ||
- .storybook | ||
- .playwright | ||
|
||
# Repo config | ||
- .github | ||
- .vscode | ||
``` | ||
|
||
The following items will be installed and ran at the root-level: | ||
|
||
- Linting | ||
- `eslint` | ||
- `markdownlint` | ||
- Testing | ||
- Jest | ||
- Playwright | ||
- Development | ||
- Storybook | ||
- Type checking | ||
- TypeScript | ||
|
||
Certain configuration items, like for TypeScript or Babel, may need configuration defined at the top-level and extended by child workspaces. | ||
|
||
The current `@primer/react` package will move to the `packages/react` package. Workspaces that depend on `@primer/react` should reference the version of that package. | ||
|
||
### Impact | ||
|
||
- Scripts need to be updated | ||
- GitHub Action paths need to be updated | ||
- TypeScript refactor for base config | ||
- Changeset support | ||
- Performance from installing node modules for entire workspace | ||
- Find workarounds in cases where legacy-peer-deps is required as an option | ||
|
||
### Looking forward | ||
|
||
- Exploration into https://nx.dev/ for build tooling as npm workspaces does not support topological script ordering |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
looks like a good use case for toooooolchain!