Source dependencies
One core benefit of a monorepo, often overlooked or underutilized, is the ability to leverage shared workspaces as source-level dependencies. When code is colocated within a monorepo, there should be no need to rebuild across workspace boundaries to incorporate changes from dependent workspaces.
However, some monorepo implementations have difficulties when they introduce TypeScript or other languages and features that require compilation or transpilation before sharing code across Workspaces. In fact, some notable projects and teams have opted to remove TypeScript due to these challenges alone.
Fortunately, with oneRepo, such concerns are avoidable, as it provides support for using source-level dependencies out of the box.
To achieve a workflow that eliminates the need for pre-compilation, each Workspace’s package.json
entry fields should point to the uncompiled source files, typically found in the src directory.
For workspaces that are publishable to external registries, the publishConfig
space in the package.json
can be used to define overrides for the published package, specifying the compiled entrypoints (e.g., within the dist
or build
directories) and other publish-only configurations.
When using the publishConfig
, oneRepo’s integrated change management tools automatically adjust the package.json
file during the publishing process. This ensures that the publicly available version of your package includes all necessary entry points pointing to the correctly built resources, rather than internal, unbuilt source dependencies.
Ensuring conformance
Section titled Ensuring conformanceUse the built-in one graph verify
command with a custom JSON schema to ensure all shared workspaces conform to using fields correctly.