Skip to content

Commit 3423403

Browse files
authored
docs(ws-config-files) - add docs for "teambit.workspace/workspace-config-files" aspect (#9116)
1 parent e29703b commit 3423403

File tree

1 file changed

+99
-1
lines changed

1 file changed

+99
-1
lines changed

scopes/workspace/workspace-config-files/workspace-config-files.docs.mdx

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ labels: ['core aspect', 'cli', 'configuration', 'workspace']
44
---
55

66
This aspect provides the ability to write configuration files in the workspace.
7-
It provides an API to write configuration files in the workspace, and also provides cli commands to write configuration files.
7+
The main goal for these config file writers is to ensure that the LSP/IDE produces the same results as running the relevant commands (such as bit lint, bit format, or bit check types/TypeScript during build). It provides an API to write configuration files in the workspace, and also provides CLI commands to do so.
88

99
### Commands
1010

@@ -14,3 +14,101 @@ Main command is `bit ws-config` which has the following sub commands:
1414
- `bit ws-config clean` - remove all configuration files from the workspace
1515
- `bit ws-config list` - list all registered configuration writers.
1616
this is useful for filtering used configuration writers when using the `--writers` flag in the write/clean commands.
17+
18+
### How it works
19+
20+
**Background:**
21+
22+
Bit structures its workspaces in a manner that, while reminiscent of monorepos, introduces additional complexities:
23+
24+
1. **Component Isolation:** Each component behaves as an isolated package with its own `package.json` and configuration files (like `tsconfig`, `eslint`, `prettier`, `jest`, etc.). Some components might share configurations.
25+
26+
2. **Directory Structure Example:**
27+
28+
```
29+
- Root
30+
- node_modules
31+
- React-env
32+
- config1
33+
- Node-env
34+
- config2
35+
- Lit-env
36+
- config3
37+
- Users-domain
38+
- React-comp1
39+
- React-comp2
40+
- Node-comp1
41+
- Ecommerce-domain
42+
- React-comp3
43+
- React-comp4
44+
- Node-comp1
45+
- Node-comp2
46+
- Lit-comp1
47+
- Lit-comp2
48+
- Lit-comp3
49+
```
50+
51+
- **Observations:**
52+
- Sibling directories may require different configs at any hierarchy level.
53+
- Components across different domains might share the same config.
54+
- Actual config files reside within `node_modules` packages, not directly in the source folders.
55+
56+
**Flow:**
57+
58+
1. **Determining Config Associations:**
59+
60+
- **Step 1:** Identify the relevant config files for each component (e.g., for ESLint).
61+
- **Step 2:** Group components sharing the same config.
62+
- **Step 3:** Map the relevant paths for each config.
63+
64+
_Example Outcome:_
65+
66+
```json
67+
{
68+
"Config1": [
69+
"users-domain/react-comp1",
70+
"users-domain/react-comp2",
71+
"ecommerce-domain/react-comp3",
72+
"ecommerce-domain/react-comp4"
73+
],
74+
"Config2": ["..."],
75+
"Config3": ["..."]
76+
}
77+
```
78+
79+
2. **Optimizing Config File Placement:**
80+
81+
- Develop an algorithm to determine optimal locations for generated config files, minimizing workspace pollution.
82+
83+
_Example Outcome:_
84+
85+
```json
86+
{
87+
"root": "generated-config1", // Predominantly React components
88+
"users-domain": "generated-config2", // Exclusively Node components
89+
"ecommerce-domain": "generated-config3",
90+
"ecommerce-domain/node-comp1": "generated-config2",
91+
"ecommerce-domain/node-comp2": "generated-config2"
92+
}
93+
```
94+
95+
3. **Filesystem Structure:**
96+
97+
```
98+
- Root
99+
- node_modules
100+
- .config-files-dir
101+
- Config1.<hash>.js
102+
- Config2.<hash>.js
103+
- Config3.<hash>.js
104+
- generated-config1
105+
- ...
106+
```
107+
108+
Each `generated-config` extends its respective config file:
109+
110+
```json
111+
{
112+
"extends": ["./node_modules/.config-files-dir/.eslintrc.bit.<hash>.json"]
113+
}
114+
```

0 commit comments

Comments
 (0)