@@ -17,15 +17,15 @@ The mono-repository root directory contains three main folders.
17
17
18
18
## Libs
19
19
20
- Historically, much of the feature logic of Bitwarden has existed within the ` apps ` directories, only
21
- being moved to ` libs ` (usually ` libs/common ` or ` libs/angular ` ) if it needed to be shared between
22
- multiple clients.
20
+ Historically, much of the feature logic of Bitwarden has existed within the ` apps/ ` directories,
21
+ only being moved to ` libs/ ` (usually ` libs/common/ ` or ` libs/angular/ ` ) if it needed to be shared
22
+ between multiple clients.
23
23
24
24
We are attempting to move to a more modular architecture by creating additional libs that are more
25
- feature-focused and more accurately convey team code ownership.
25
+ feature-focused and which more accurately convey team code ownership.
26
26
27
27
- ` common ` : Common code shared between all the clients including CLI
28
- - ` angular ` : Low-level Angular specific utilities used by all the visual clients
28
+ - ` angular ` : Low-level Angular utilities used by all the visual clients
29
29
- ` node ` : Used to be shared code for CLI and Directory Connector CLI, but since directory connector
30
30
no longer uses the same version of libs this module is deprecated
31
31
- ` admin-console ` : Code owned by the Admin Console team
@@ -38,15 +38,21 @@ feature-focused and more accurately convey team code ownership.
38
38
- ` platform ` : Code owned by the Platform team
39
39
- ` vault ` : Code owned by the Vault team
40
40
41
- For more on this approach, check out the
41
+ ### Background
42
+
43
+ More on this approach can be found in the
42
44
[ Nx documentation] ( https://nx.dev/concepts/more-concepts/applications-and-libraries ) :
43
45
44
46
> place 80% of your logic into the ` libs/ ` folder and 20% into ` apps/ `
45
47
46
- We are doing the opposite of this right now. What code should be moved from ` apps/ ` to ` libs/ ` ? At
47
- this time, any code in the ` /apps/web/* ` that doesn't have a tight coupling with the web client can
48
- be moved into a lib. For components, this means they should only be the CL, no global CSS or
49
- anything exported from web-specific modules.
48
+ We are doing the opposite of this right now. The code that remains in ` apps/ ` should be primarily
49
+ concerned with bootstrapping the application and consuming and configuring code exported from
50
+ ` libs/ ` . Over time, code not meeting this criteria should be moved from ` apps/ ` to ` libs/ ` .
51
+
52
+ Any code in the ` apps/ ` that doesn't have a tight coupling with the client can be moved into a lib:
53
+ if an exported member is wholly dependent on other libs but not ` apps/ ` , it can likely be moved to a
54
+ lib itself. (More concretely, this bars components that rely on global client-specific CSS, but not
55
+ components built with Tailwind and the CL.)
50
56
51
57
> Having a dedicated library project is a much stronger boundary compared to just separating code
52
58
> into folders, though. Each library has a so-called "public API", represented by an index.ts barrel
@@ -56,10 +62,10 @@ anything exported from web-specific modules.
56
62
57
63
An existing example of this pattern is ` @bitwarden/components ` :
58
64
59
- - It is used by multiple apps and other libs
65
+ - It is consumed by multiple apps and other libs
60
66
- It manages a clear public and private API boundary through its barrel file
61
- - Code ownership is clear--only the files within ` libs/components `
62
- - The team can make independent decisions around internal folder structure and code style
67
+ - Code ownership is clear--the CL team only owns the files within ` libs/components `
68
+ - The CL team can make independent decisions around internal folder structure and code style
63
69
64
70
As part of this process, we are also investigating utilizing additional tooling (such as Nx) to make
65
71
creating new libs on the fly easier.
0 commit comments