Turborepo

A monorepo is a single repository containing multiple distinct projects, with well-defined relationships. learn more at monorepo.tools

Turborepoenable managing deployable apps and associated Sharing Code in single git repo. Sharing Code cab be either Internal Packages or External Packages

Internal packages are packages which are only intended to be used inside your monorepo. They're extremely useful for sharing code between apps in closed-source monorepos. External packages run their files through a bundler before putting them on a package registry.

What's inside?

This Turborepo includes the following packages/apps:

Apps and Packages

  • WebApps

    • playground: an experimental svelte-kit web app to play with new ideas.

    • docs: a sample documentation web app build with astro's starlight

    • web: a sample landing page web app build with astro

    • console: a sample dashboard web app build with svelte-kit

  • Packages

    • ui: a stub Svelte component library shared by both web and docs applications

    • eslint-config: eslint configurations (includes eslint-plugin-svelte and eslint-config-prettier)

    • prettier-config: shared prettier configurations (plugins etc...)

    • typescript-config: shared tsconfig files

    • utils: utility functions used throughout the monorepo

Utilities

This Turborepo has some additional tools already setup for you:

Prerequisite

  1. Turbo CLI

pnpm add -g turbo@latest
  1. VS Code monorepo plugin: Monorepo Focus Workspace

code --install-extension alberto-varela.monorepo-focus-workspace

Setup

Create sveltekit turborepo

to create a new sveltekit turborepo, Run the following command:

pnpx create-turbo@latest -e with-svelte
# bunx create-turbo@latest -e with-svelte

Setup Remote Caching for Turborepo on Vercel

npx turbo login
npx turbo link
# bunx turbo login

Usage

Environment

App Environment Variables

Turbo is working on first-class solution to load dotEnv files. Meanwhile we recommend using a library called dotenv-run to solve this problem.

turbo automatically include environment variables from .env , .secrets as we set them at globalDotEnv in turbo.json

Run

turbo dev --filter=playground
turbo dev --filter=web
turbo dev --filter=docs

Test

turbo test --filter=helpers

Build

turbo build --filter=playground...
turbo build --filter=playground... --summarize
turbo build --filter=playground... --dry
turbo build --filter=playground... --graph

Maintenance

migrate command which both upgrades your repo to the specified version (latest by default) of turbo, and runs any codemods required.

pnpx  @turbo/codemod migrate

Docker Build

# for dockerfile
turbo prune --scope=playground --docker

Guides

turbo build
turbo dev
turbo dev  --filter=playground
turbo lint
turbo run generate
pnpx turbo login

turbo prune --scope=playground --docker

Last updated