FluidFramework
FluidFramework copied to clipboard
improvement(build-tools): Add build-infrastructure package
[!NOTE] This PR is one of several. This PR creates a new private package and establishes some interfaces only. Future changes will add implementations of those interfaces and additional APIs.
@fluid-tools/build-infrastructure
This change introduces a new package containing types and helper functions that will be used across multiple build-tools packages, including @fluidframework/build-tools and @fluid-tools/build-cli.
The primary purpose of this package is to provide a common way to enumerate Packages, Release Groups, and Workspaces across a Fluid repo.
The package is private and nothing depends on it yet, so it should cause no problems when merged in its current state.
[!IMPORTANT] I have found it easiest to write this as a new package, but I am not fanatical about this. There are practical reasons why a package is a little easier right now (the direction of dependencies between the packages in particular) but for the purposes of this review, if you think this should be organized into modules within an existing package instead, try and ignore that feedback for now and focus on the function and scope of the code.
Background
Today both fluid-build and build-cli (flub) need to understand the layout of the repo - what packages belong to what release groups, what folders are workspace roots vs. independent packages, etc. We have been using the types and classes from fluid-build in the flub code, but the relationship has always been strange because flub has a concept of release groups while fluid-build uses a MonoRepo class which is analogous to a Workspace.
Conceptually, Release Groups and Workspaces are distinct, but in code there is not a strong representation of the "release group" concept. In flub we use the MonoRepo class and a type ReleaseGroup = string together as a stand-in for the ReleaseGroup concept which has meant that release groups and workspaces (the MonoRepo class) are more or less the same thing in practice.
That has always been a very weird situation that has gotten complicated as the repo has grown, and now we find that we want the benefits of interdependencies in between packages provided by workspaces but the flexibility of releasing and versioning groups of packages within those workspaces. These changes are a step towards that future.
How the API and interfaces were developed
The interfaces exposed by this package were extracted from the uses of packages and release groups in build-tools and build-cli. The minimal set of properties and functions necessary by both of those packages was used. In some cases, duplicative properties or functions were removed. For example, the Package type had dependencies and combinedDependencies; now it just has the latter and the caller can filter out what it doesn't want or extend the shared interface.
The goal
The eventual goal state - far beyond this PR - is to have all the shared types and data about the repo layout and other shared code in the build-infrastructure package, and then have flub and fluid-build be in individual packages. They shouldn't depend on each other - all the shared logic - especially the types - should be in the infra package.
See the package README in this PR for more details. Excerpts are included here for convenience.
⯅ @fluid-example/bundle-size-tests: +245 Bytes
| Metric Name | Baseline Size | Compare Size | Size Diff |
|---|---|---|---|
| aqueduct.js | 459.85 KB | 459.89 KB | ⯅ +35 Bytes |
| azureClient.js | 557 KB | 557.04 KB | ⯅ +49 Bytes |
| connectionState.js | 724 Bytes | 724 Bytes | ■ No change |
| containerRuntime.js | 259.47 KB | 259.48 KB | ⯅ +14 Bytes |
| fluidFramework.js | 405.81 KB | 405.82 KB | ⯅ +14 Bytes |
| loader.js | 134.16 KB | 134.18 KB | ⯅ +14 Bytes |
| map.js | 42.46 KB | 42.46 KB | ⯅ +7 Bytes |
| matrix.js | 148.29 KB | 148.29 KB | ⯅ +7 Bytes |
| odspClient.js | 523.96 KB | 524 KB | ⯅ +49 Bytes |
| odspDriver.js | 97.84 KB | 97.86 KB | ⯅ +21 Bytes |
| odspPrefetchSnapshot.js | 42.81 KB | 42.82 KB | ⯅ +14 Bytes |
| sharedString.js | 164.48 KB | 164.49 KB | ⯅ +7 Bytes |
| sharedTree.js | 396.27 KB | 396.28 KB | ⯅ +7 Bytes |
| Total Size | 3.31 MB | 3.31 MB | ⯅ +245 Bytes |
Baseline commit: 5c17a9c05323dd19c93d94d6797b4d6e65fc189d
Generated by :no_entry_sign: dangerJS against ea5fc632aac74c49b9f6dee86a033c6b41f8e76c