Library for building distributed, real-time collaborative web applications
Перейти к файлу
Tyler Butler dda812637f
build(client): Update build-tools dependencies to latest (0.44) (#22297)
Updated the following:

  client (release group)

Dependencies on build-tools updated:

  @fluid-tools/build-cli: 0.44.0
  @fluidframework/build-tools: 0.44.0
  @fluidframework/bundle-size-tools: 0.44.0
  @fluid-tools/version-tools: 0.44.0

I also made two small changes to the root Biome config and the
test-snapshots Biome config. The configs exposed a case where `git
ls-files` will return a path to a directory - if that directory is a
submodule. These config changes enable the Biome task caching to work
even with this ls-files oddity by ensuring the directory path doesn't
make it into the cached file list.
2024-08-23 00:49:37 +00:00
.changeset build(client): Generate changelogs for 2.2 release (#22241) 2024-08-16 23:23:32 +00:00
.devcontainer refactor: Add hostRequirements section to devcontainer.json (#19473) 2024-02-09 16:02:29 -06:00
.github revert: CODEOWNERS additions (#22294) 2024-08-22 15:07:54 -07:00
.vscode feat(build-cli): New command generate:releaseNotes (#21951) 2024-08-05 20:36:46 +00:00
RELEASE_NOTES build: Generate release notes for 2.2 release (#22067) 2024-08-16 21:11:43 +00:00
azure build(client): Update build-tools dependencies to latest (0.44) (#22297) 2024-08-23 00:49:37 +00:00
build-tools [bump] build-tools: 0.44.0 => 0.45.0 (minor) (#22251) 2024-08-22 14:23:50 -07:00
common refactor(markdown-magic): Simplify template names (#21964) 2024-07-22 16:33:44 -07:00
docs docs(website): Expand "Fluid Releases and API Support Levels" documentation (#22279) 2024-08-21 16:03:15 -07:00
examples build(client): Update build-tools dependencies to latest (0.44) (#22297) 2024-08-23 00:49:37 +00:00
experimental build(client): Update build-tools dependencies to latest (0.44) (#22297) 2024-08-23 00:49:37 +00:00
feeds Remove test-app-insights-logger and load-test collateral (#22118) 2024-08-06 18:59:41 +00:00
packages build(client): Update build-tools dependencies to latest (0.44) (#22297) 2024-08-23 00:49:37 +00:00
patches build: Patch API-Extractor to omit import statements from API reports (#21538) 2024-06-20 18:24:15 +00:00
scripts ci: Replace bash publish script with flub publish tarballs (#21018) 2024-07-26 21:15:31 +00:00
server Vermadhr/correlation id source tracking (#22292) 2024-08-22 18:00:29 +00:00
tools feat(api-markdown-documenter): Add `lintApiModel` API (#22250) 2024-08-21 11:34:09 -07:00
.dockerignore Delete auspkn and verdaccio references (#6011) 2021-05-03 14:04:56 -07:00
.git-blame-ignore-revs build: Add formatting commit to blame ignore (#14588) 2023-03-21 09:12:06 -07:00
.gitattributes Add a .git-blame-ignore-revs file with prettier commits (#13928) 2023-02-01 10:59:30 -08:00
.gitignore build(client-devtools): reclaim @alpha for traditional use (#21396) 2024-06-13 01:21:12 +00:00
.gitmodules Update submodule branch to main (#3263) 2020-08-20 09:09:08 -07:00
.markdownlint.json Automation: Main Next Integrate 2023-02-27 11:55:24 -06:00
.npmrc build: Set prefer-frozen-lockfile=true in all .npmrc files (#21922) 2024-07-16 18:19:41 -07:00
.nvmrc Recommend development with node 18 (#16983) 2023-08-23 15:57:00 -07:00
.prettierignore refactor(tree): introduce v1 optional/required field persisted format (#20341) 2024-03-26 17:29:05 -07:00
.releaseGroup build: Remove lerna from client and build-tools (#16161) 2023-08-17 13:04:31 -07:00
BREAKING.md docs: Update changesets for clarity (#16504) 2023-08-02 17:20:11 -07:00
CODE_OF_CONDUCT.md Add security and code of conduct (#3463) 2019-09-06 16:52:25 -07:00
CONTRIBUTING.md Add link to wiki from CONTRIBUTING.md (#2629) 2020-06-19 19:19:57 -07:00
ClientRequirements.md refactor(markdown-magic): Simplify template names (#21964) 2024-07-22 16:33:44 -07:00
CredScanSuppressions.json refactor(ci): Update credscan suppressions to handle historian and gitrest (#22211) 2024-08-14 16:58:48 -05:00
LICENSE Policy-Check: Pick up and apply ^0.2.22453 (#5868) 2021-04-20 14:00:26 -07:00
NOTICE.md Clean up entries in root NOTICE for content are deleted from the repo already (#11132) 2022-07-15 13:37:02 -07:00
PACKAGES.md Move migration-tools to separate example package (#22267) 2024-08-22 16:24:14 -07:00
README.md refactor(markdown-magic): Simplify template names (#21964) 2024-07-22 16:33:44 -07:00
SECURITY.md Add security and code of conduct (#3463) 2019-09-06 16:52:25 -07:00
biome.jsonc build(client): Update build-tools dependencies to latest (0.44) (#22297) 2024-08-23 00:49:37 +00:00
fluidBuild.config.cjs build: Generate release notes for 2.2 release (#22067) 2024-08-16 21:11:43 +00:00
layerInfo.json Use test accounts for examples run against odsp/odspdf (#21591) 2024-06-24 23:09:32 +00:00
lerna.json [bump] client: 2.2.0 => 2.3.0 (minor) (#22248) 2024-08-16 18:16:36 -07:00
package.json build(client): Update build-tools dependencies to latest (0.44) (#22297) 2024-08-23 00:49:37 +00:00
pnpm-lock.yaml build(client): Update build-tools dependencies to latest (0.44) (#22297) 2024-08-23 00:49:37 +00:00
pnpm-workspace.yaml build(client): Include markdown-magic and changelog-generator-wrapper in client release group (#21393) 2024-06-25 02:21:20 +00:00
prettier.config.cjs build: Update shared prettier config (#15758) 2023-06-05 12:37:40 -07:00
syncpack.config.cjs build(client): Add missing independent packages to syncpack config (#22128) 2024-08-05 21:57:24 -07:00

README.md

Fluid

The Fluid Framework is a library for building distributed, real-time collaborative web applications using JavaScript or TypeScript.

Getting started using the Fluid Framework

You may be here because you want to...

  • Learn more about the Fluid Framework
  • Build a Fluid object

Documentation and guides can be found at https://fluidframework.com/.

Hello World repo can be found at https://github.com/microsoft/FluidHelloWorld.

Core Examples repo can be found at https://github.com/microsoft/FluidExamples.

Have questions? Engage with other Fluid Framework users and developers in the Discussions section of our GitHub repo.

Using Fluid Framework libraries

When taking a dependency on a Fluid Framework library's public APIs, we recommend using a ^ (caret) version range, such as ^1.3.4. While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries, library consumers should always prefer ^.

If using any of Fluid Framework's unstable APIs (for example, its beta APIs), we recommend using a more constrained version range, such as ~.

Code structure

The core code for both the Fluid client packages and the reference ordering service is contained within this repo.

The repo structure is somewhat unique because it contains several pnpm workspaces: some for individual packages and some for larger collections which we call "release groups". The workspaces are versioned separately from one another, but internally all packages in a workspaces are versioned together.

These workspaces do not align with package namespaces, and also don't always correspond to a single directory of this repo.

Here's the list of release group workspaces:

Here's a list of other sets of other packages (each package within these groups is versioned independently, forming its own release group):

  • "Common" Packages: miscellaneous packages in the ./common directory and published under the @fluidframework/ namespace. Most of these (but not all) have "common" in their package name. Packages which are used by multiple other groups of packages (such as built tools, linter configs and protocol definitions) live here.
  • "Tools" Packages: miscellaneous packages in the ./tools directory and published under a variety of namespaces. Logically about the same as "Common", but most of the names include "tools" instead of "common".
  • Auxiliary Microservice Packages (supporting Routerlicious)
    • ./server excluding routerlicious, gitrest and historian (Published in the @fluidframework/ namespace)
  • ./docs: The code and content for https://fluidframework.com.

Dependencies between packages in various layers of the system are enforced via a build step called layer-check. You can view the full list of packages and layers in PACKAGES.md.

  • Note: to update the contents of PACKAGES.md for local package changes, run pnpm layer-check --md ..

Setup and Building

Install the required tools:

Clone a copy of the repo and change to the repo root directory:

git clone https://github.com/microsoft/FluidFramework.git
cd FluidFramework

Enable NodeJs's corepack:

corepack enable

Run the following to build the client packages:

pnpm install
npm run build

You can use the experimental worker mode to get faster build time as well: npm run build:fast

See also: Contributing

Build in VSCode

To build Fluid Framework within VSCode, open the Fluid Framework repo folder as a work space and use Ctrl-Shift-B to activate the build task. It is the same as running npm run build on the command line.

NodeJs Installation

We recommend using nvm (for Windows or MacOS/Linux) or fnm to install Node.js. This ensures you stay at the correct version while allowing other uses of NodeJS to use the (possibly different) versions they need side-by-side.

Because of a transitive dependency on a native addon module, you'll also need to ensure that you have the prerequisites for node-gyp. Depending on your operating system, you'll have slightly different installation requirements (these are largely copied from node-gyp's documentation):

On Windows

The node installer should ask if you want to install "Tools for Native Modules." If you check the box for this nothing further should be needed. Otherwise, you can follow the steps listed here

On Unix

  1. Python v3.7, v3.8, v3.9, or v3.10
  2. make
  3. A C/C++ toolchain (like GCC)

On MacOS

If you've upgraded your Mac to Catalina or higher, you may need to follow these instructions.

  1. Python v3.7, v3.8, v3.9, or v3.10
  2. XCode Command Line Tools, which will install make, clang, and clang++
    • You can install these by running xcode-select --install from a command line.

Other Build Requirements

  • Building server/Routerlicious
    • Refer to that package's README for additional requirements.
    • Note that these requirements do not affect all workflows (e.g. the one noted above), but will affect workflows that include the packages under server (e.g. fluid-build --symlink:full).

On Windows

  • Ensure that you have enabled running Powershell scripts by setting your environment's Execution Policy.

Other Build Commands

Building our docs

There are a few different areas in which we generate documentation content as a part our overall build.

  1. fluidframework.com
    • We build the contents of our public website from the docs directory under the root of this repo. See its README for more details.
  2. Generated README contents
    • We leverage a local tool (markdown-magic) to generate / embed contents in our various package-level READMEs. This is done as a part of a full build, but it can also be executed in isolation by running npm run build:readme from the repo root.
  3. API reports
    • We leverage API-Extractor to generate summaries of our package APIs. This is done as a part of a full build, but it can also be executed in isolation by running npm run build:api from the repo root.

Common Workflows and Patterns

This section contains common workflows and patterns to increase inner dev loop efficiency.

Build

  • pnpm install from the root of the repository to install dependencies. This is necessary for new clones or after pulling changes from the main branch.

  • pnpm run build:fast from the root of the repository to perform an incremental build that matches the CI build process. Incremental builds tend to leave extra files laying around, so running a clean is sometimes needed to cleanup ghost tests

  • pnpm run build:fast -- <path> to build only a specific part of the repository.

  • pnpm run build within a package directory to build that package.

  • pnpm run build:compile for cross-package compilation.

  • pnpm run format to format the code.

  • fluid-build --vscode to output error message to work with default problem matcher in vscode. If fluid-build is not installed, please install it with npm i -g @fluidframework/build-tools.

Multi package setup

  • fluid-build -t build <NAME_OF_PACKAGES> to build a multiple space-separated packages along with all their dependencies. If fluid-build is not installed, please install it with npm i -g @fluidframework/build-tools.

Debug

  • You can also use the VSCode JS debug terminal, then run the test as normal.

  • Sometimes, uncommitted changes can cause build failures. Committing changes might be necessary to resolve such issues.

Troubleshooting

  • pnpm clean if random build failures, especially with no changes
  • git clean -xdf to remove extraneous files if debugging becomes slow or hangs.

Testing

You can run all of our tests from the root of the repo, or you can run a scoped set of tests by running the test command from the package you're interested in.

Note: Some of the tests depend on test collateral that lives in a submodule here: https://github.com/microsoft/FluidFrameworkTestData. You may choose to fetch that collateral into your local repository, which is required to run all the tests - otherwise some will be skipped.

First, ensure you have installed Git LFS. Then, from the repo root:

git lfs install
git submodule init
git submodule update

Run the tests

Before running the tests, the project has to be built. Depending on what tests you want to run, execute the following command in the package directory or at the root:

npm run test
  • To run a single test within a module, add .only to it or describe. To exclude a test, use .skip.

  • You can use ts-mocha to quickly run specific test files without needing to make the whole project compile. For more details on test filtering using CLI arguments, refer to the Mocha documentation.

  • Our test setup generally requires building before running the tests.

  • Incremental builds may leave extra files, which can result in ghost tests. To avoid this, consider running a clean build with the following command:

pnpm clean <package>

This removes any leftover files from previous builds, providing a clean testing environment.

Include code coverage

npm run test:coverage

Mimic the official CI build

Our CI pipelines run on Linux machines, and the npm scripts all have the ci prefix. To replicate the test steps from the CI pipeline locally, run the following commands for the packages or pnpm workspaces:

Run Non-Windows Windows
PR npm run ci:test npm run test:report && npm run test:copyresults
Official npm run ci:test:coverage npm run test:coverage && npm run test:copyresults

Run tests from within VS Code

We've checked in VS Code configuration enabling F5 from a spec.ts file to run those tests if you set the debug configuration to "Debug Current Test".

Run it locally

Single browser window, two panes

This will use an in-memory implementation of the Fluid server to sync between the two panes in the browser window.

  • Choose an example under /examples
  • Navigate to the example's directory, e.g. /examples/data-objects/clicker
  • npm run start
  • Browse to http://localhost:8080 to interact with two copies of the example side-by-side

Multiple browser instances on the same device

This will run the local Fluid server implementation we call "Tinylicious", so you can sync between multiple browser instances.

First, start Tinylicious by running these commands from /server/routerlicious/:

pnpm install

Then these commands from /server/routerlicious/packages/tinylicious:

pnpm run build
pnpm run start

Then:

  • Navigate to the example of your choice (same as above)
  • npm run start:tinylicious
  • Browse to http://localhost:8080, copy the full URL you're redirected to, and open in a second window to collaborate

Tools

Prettier

This repository uses prettier as its code formatter. Right now, this is implemented on a per-package basis, with a shared base configuration.

  • To run prettier on your code, run npm run format from the appropriate package or release group, or run npm run format:changed from the root of the repo to format only files changed since the main branch. If your change is for the next branch instead, you can run npm run format:changed:next.
  • To run prettier with fluid-build, you can specify "format" via the script argument: fluid-build -t format or npm run build:fast -- -t format

To ensure our formatting remains consistent, we run a formatting check as a part of each package's lint script.

VSCode Options

Our workspace configuration specifies prettier as the default formatter. Please do not change this.

It is not configured to do any formatting automatically, however. This is intentional, to ensure that each developer can work formatting into their workflow as they see fit. If you wish to configure your setup to format on save/paste/etc., please feel free to update your user preferences to do so.

Notable setting options:

  • format on save
  • format on paste
User editor formatting setting options

Git Configuration

Run the following command in each of your repositories to ignore formatting changes in git blame commands: git config --local blame.ignoreRevsFile .git-blame-ignore-revs

Developer notes

Root dependencies

The root package.json in the repo includes devDependencies on the mocha and jest testing tools. This is to enable easier test running and debugging using VSCode. However, this makes it possible for projects to have a 'phantom dependency' on these tools. That is, because mocha/jest is always available in the root, projects in the repo will be able to find mocha/jest even if they don't express a dependency on those packages in their package.json. We have lint rules in place to prevent phantom dependencies from being introduced but they're not foolproof.

Contributing

There are many ways to contribute to Fluid.

Detailed instructions for working in the repo can be found in the Wiki.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services. Use of these trademarks or logos must follow Microsofts Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.