What Is A Workspace?
A code workspace can be thought of a singular area wherein all code
can be shared. This is a common pattern used internally by e.g. Meta
and Google.
The benefits include:
-
Unified versioning
a. Everything at that current commit works together
b. A label or branch can capture the same
-
Promotes code sharing and reuse
a. Easy to split code into lib modules
b. Easy to consume implement that code and the latest changes to it
-
Easier dependency management
a. One node_modules for all code
b. One build setup (like the AngularCLI)
-
Refactoring benefits
a. Code editors and IDEs are "workspace" aware
b. Can have a single commit for a refactor that spans applications
in the domain
-
Consistent developer experience
a. Ensures all necessary dependent code is available
Why We Love the Idea of a Workspace
Code Re-use
In any large application, code re-use is key. When workspaces are not
implemented, a separate npm
repo is required. You also need to
coordinate libraries and shared code.
Workspaces make it easier to share code and give visibility to other
workspaces without it being a walled off application. The apps inside
the workspace can be standalone - but have the ability to tap into the
required libraries if needed.
It Emphasizes Smaller Modules
Using the tree directory as your referencing point can become cumbersome
over time. As a result, a workspace encourages a modular approach to
building features. This often results in smaller modules, services and
components.
Workspace Notable Mentions
apps folder
All application that we will be creating will go into the apps folder.
libs folder
All code intended to be shared by any one of our apps, will be created
in the libs folder. It is a secret weapon.
tsconfig, test, and linting
This is where the universal configurations for Typescript, unit testing,
and linting will live. It will be accessible and used across all
applications apps folder, in addition to all the libraries in the lib
folder.
Leave Feedback