Skip to content

Monorepo

Vyacheslav Matyukhin edited this page Jan 10, 2024 · 2 revisions

This repository is called "squiggle", but it's not limited to Squiggle language, and de facto functions as QURI's main monorepo.

This page explains our overall repository setup.

pnpm

We use https://pnpm.io/. (We tried Yarn v1 and Yarn v2 before and decided that pnpm is slightly better.)

pnpm enforces strict dependencies resolution, so that you can't import a package that's implicitly installed because another package depends on it.

In those cases you might have to install the dependency explicitly. For example, components depends on @types/testing-library__jest-dom even though it should've been installed explicitly because we also install @testing-library/jest-dom.

Turborepo

We use Turborepo for CI.

Our package.json scripts don't include the dependencies (for example, "test" target is usually simply jest, and not pnpm run build && jest).

Instead, we rely on Turborepo dependsOn feature in turbo.json configs.

Take a look at our root-level turbo.json to see which tasks are considered common for our packages.

You can often use turbo run instead of pnpm run to run tasks while making sure that dependencies are built. For example, call npx turbo test instead of pnpm test in a package's directory. (Using pnpm test is ok too, if you know that dependencies are ready, but turbo test might be more convenient if you've just pulled new commits or switched to a new branch).

TypeScript

Configs

Common TypeScript configs are in packages/configs. You should extend tsconfig.base.json for most packages and tsconfig.nextjs.json for Next.js apps (documentation website and Squiggle Hub).

Project references

We use project references to make Typescript aware of our package dependency graph.

This might have been a mistake: sometimes (rarely) there's a collision between Typescript trying to build dependencies and turbo running builds in parallel. This might lead to failing CI jobs with error messages about bad file timestamps.

Also, Next.js doesn't support project references, so we still can't use them or make use of tsc -b in packages/hub or packages/website.

Clone this wiki locally