Skip to content

FISYCO

Public beta

Distributing design tokens in a monorepo: versions and consumers

5 min read

Engineering
A tokens package card in the centre of a monorepo, linked to web, admin and mobile app cards, with version tags on the links

Design tokens in a monorepo usually start as a folder that one app imports. Then a second app needs them, then a marketing site, then a package published for another team. At each step the same question returns: how do consumers get tokens, and how do they know when a change will break them? This note covers distributing tokens in a monorepo, from a workspace package to a versioned release.

Key takeaways

  • Put tokens in their own workspace package, not in an app. Every consumer imports the same package by name.
  • Inside the monorepo, link with the workspace protocol. pnpm resolves workspace: only to the local package.
  • When tokens leave the monorepo, version them. A renamed or removed token is a major change, as GitHub's Primer primitives changelog shows.
  • Record the intent of each change when it's made. Changesets keeps a note per change and turns it into versions and a changelog.

Step 1: a tokens package

The first move is structural. Take the token files out of the app that created them and give them a package of their own. For example, with a hypothetical @acme/tokens:

Now there's one owner, one folder to review and one import path. An app that needs a token imports @acme/tokens, not a relative path into another app.

Decide early what the package ships. Token packages often ship more than one format:

The DTCG format matters here because it's the tool-neutral format that other tools can read. Our note on Style Dictionary in practice shows how to build platform outputs from it.

Inside the monorepo, consumers should always get the local package, never a published copy by accident. Package managers support this with workspaces.

npm workspaces manage "multiple packages from your local file system from within a singular top-level, root package", and link them as symlinks in node_modules (npm). pnpm goes further with the workspace: protocol. With it, "pnpm will refuse to resolve to anything other than a local workspace package" (pnpm).

When the package is published, pnpm replaces workspace:* with the real version, and workspace:^ with a caret range. The same package.json works inside the repository and after release.

Step 3: choose how the package is built

Turborepo's documentation describes three kinds of internal package, and a tokens package can be any of them (Turborepo):

  • Just-in-Time. The consuming app compiles the package's source. It's the simplest setup, but Turborepo "cannot cache a build" for it.
  • Compiled. The package builds itself, for example with tsc, and consumers import the output.
  • Publishable. The package is built and published to a registry. It has "the most strict requirements".

For tokens, the source is often already the output: CSS and JSON need no compilation. A TypeScript file of token constants can be consumed Just-in-Time until a consumer outside the monorepo needs it.

Step 4: version what leaves the repository

While every consumer lives in the same repository, a change and its consumers can be updated in one pull request. Versions start to matter when a consumer can't be updated in the same commit: a published package, another team's repository, a mobile app with its own release train.

Then SemVer applies, and it's worth being strict about what counts as breaking for tokens:

GitHub's Primer, for one, treats token renames and removals as majors. The @primer/primitives changelog shows it: version 9.0.0 notes "Removed space tokens", and 10.0.0 lists "renaming some old ones and removing one" (Primer primitives).

Before a rename or removal, keep the old name as a deprecated alias for at least one minor release, then remove it in the next major. Our guide to breaking changes in a component library covers deprecation in detail.

A value change is the grey area. A brand colour that changes on purpose isn't breaking for the API, but it changes every screen. One common approach is a minor with a clear changelog line, so consumers can review it before upgrading.

Step 5: record changes as they happen

The hardest part of versioning isn't the number. It's remembering, at release time, what changed and why. Changesets solves this by recording each change when it's made. It describes itself as "a tool to manage versioning and changelogs with a focus on monorepos". Each changeset records the packages to release, the bump type and a summary (Changesets).

For example, a token rename then carries its own note:

At release, the notes become the version bump and the changelog. Primer's primitives, for one, are released with Changesets.

Consumers outside the monorepo

When another team installs your tokens from a registry, two things help them most:

  • A migration note per major. A list of renamed tokens with old and new names turns an upgrade into a search and replace.
  • A peer dependency where it applies. If the package ships React helpers, declare React as a peer dependency. npm describes peers as expressing "the compatibility of your package with a host tool or library" (npm).

For renamed tokens, a codemod saves consumers even that search and replace. The same guide shows a tested codemod for a component rename, and the same approach works for token names.

Where FISYCO fits

We build FISYCO to keep the tokens package in step with Figma. A tokens library writes CSS, SCSS, TypeScript, JSON and DTCG files into the folder you choose, such as packages/tokens/src. Changes arrive as a pull request against that folder, with renames detected by stable Figma ID rather than as a deletion plus an addition. That makes the version decision visible in review: the pull request lists which tokens were added, modified and removed before anyone bumps a number.

Deliver your Figma tokens to a workspace package as pull requests.
#Design tokens
KK

Written by

Kirill Karpov

Founder, FISYCO

Kirill Karpov is the founder of FISYCO, a design system assurance tool that keeps Figma and production code in sync.

Get new articles by email

Design systems, tokens and design-to-code delivery. No spam, and you can leave in one click.

By subscribing you agree to get blog emails from FISYCO. Details are in the privacy policy.

Keep your design system and your code in sync

FISYCO connects Figma libraries and your codebase, finds drift and opens the fix as a pull request.

Start for free

Related articles

6 min read

Engineering

Breaking changes in a component library without breaking teams

Every component library needs a change that breaks someone. How to deprecate, migrate with codemods and remove an API without a year of pinned versions.

5 min read

Engineering

Illustrations from Figma: SVG, PNG, WebP, AVIF — what to ship

SVG for flat vectors, WebP or AVIF for everything with texture. How to choose an illustration format, and ship sharp raster files at every density.

6 min read

Engineering

Reviewing AI-generated UI against your design system

AI writes UI fast, and review checks whether it works, not whether it reuses the system. What to look for, what to automate, and how to roll it out calmly.