Skip to content

Latest commit

 

History

History
73 lines (46 loc) · 2.8 KB

CONTRIBUTING.md

File metadata and controls

73 lines (46 loc) · 2.8 KB

Contributing to Triplit

We welcome contributions to Triplit! If you have an idea for a feature or change to Triplit, please open a GitHub discussion. If you have a bug to report, please open a GitHub issue. You can also come to our Discord server to get help with a bug, discuss a feature or see what others are building.

About the monorepo

Triplit is a monorepo managed with Yarn Workspaces.

It's divided into two main parts:

  • packages/ contains the Triplit packages.
  • templates/ contains examples apps that use Triplit.

Getting started

  1. Clone the repository
  2. Run yarn install to install the dependencies
  3. Run yarn build:packages to build the packages

Building packages

Triplit's packages are interconnected e.g. @triplit/client depends on @triplit/db. Each package consumes the build artifacts of the packages it depends on. This means that if you make a change to package, you'll need to rebuild it for other packages to use the new or changed behavior. Triplit uses Turbo to make this process faster and simpler.

For example, if you have a test app that uses @triplit/client and you make a change to @triplit/db, you'll need to rebuild @triplit/db and @triplit/client for the test app to use the new behavior. Turbo can build a package and its dependencies with a single command.

yarn turbo run build --filter=@triplit/client

If you want to rebuild continuously as you make changes, you can run

yarn turbo watch build --filter=@triplit/client

You can even continuously build a package's dependencies and dependents with a single command

yarn turbo watch build --filter=...@triplit/db

Read the Turbo documentation for more information.

Testing

Triplit uses Vitest for unit testing. We strongly encourage that you add tests for whatever you're contributing. If you are expanding the developer-facing API (e.g. @triplit/client or bindings for a specific framework) we recommend adding type tests as well. Here's an example of how we implement type testing.

You can run (and should) run every test in the monorepo from the root with

yarn test

Or you can run the test suite for a specific package from that package's directory

cd packages/client
yarn test

If you want to run a single test file, you can use Vitest directly

yarn vitest run my-test-file.spec.ts

Or run tests in watch mode

yarn vitest watch

Read the Vitest documentation for more information.