Design System with Turborepo
Description
This is an official starter Turborepo with a single Storybook documentation site, a shared UI component library, and three local packages.
npx boilerapp turborepo-design-system文档
Turborepo Design System Starter
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.
This guide explains how to use a React design system starter powered by:
- 🏎 Turborepo — High-performance build system for Monorepos
- 🚀 React — JavaScript library for user interfaces
- 🛠 Tsup — TypeScript bundler powered by esbuild
- 📖 Storybook — UI component environment powered by Vite
As well as a few others tools preconfigured:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
- Changesets for managing versioning and changelogs
- GitHub Actions for fully automated package publishing
Using this example
Run the following command:
npx create-turbo@latest -e design-system
Useful Commands
pnpm build- Build all packages, including the Storybook sitepnpm dev- Run all packages locally and preview with Storybookpnpm lint- Lint all packagespnpm changeset- Generate a changesetpnpm clean- Clean up allnode_modulesanddistfolders (runs each package's clean script)
Turborepo
Turborepo is a high-performance build system for JavaScript and TypeScript codebases. It was designed after the workflows used by massive software engineering organizations to ship code at scale. Turborepo abstracts the complex configuration needed for monorepos and provides fast, incremental builds with zero-configuration remote caching.
Using Turborepo simplifies managing your design system monorepo, as you can have a single lint, build, test, and release process for all packages. Learn more about how monorepos improve your development workflow.
Apps & Packages
This Turborepo includes the following packages and applications:
apps/docs: Component documentation site with Storybookpackages/ui: Core React componentspackages/typescript-config: Sharedtsconfig.jsons used throughout the Turborepopackages/eslint-config: ESLint preset
Each package and app is 100% TypeScript. Workspaces enables us to "hoist" dependencies that are shared between packages to the root package.json. This means smaller node_modules folders and a better local dev experience. To install a dependency for the entire monorepo, use the -w workspaces flag with pnpm add.
This example sets up your .gitignore to exclude all generated files, other folders like node_modules used to store your dependencies.
Compilation
To make the ui library code work across all browsers, we need to compile the raw TypeScript and React code to plain JavaScript. We can accomplish this with tsup, which uses esbuild to greatly improve performance.
Running pnpm build from the root of the Turborepo will run the build command defined in each package's package.json file. Turborepo runs each build in parallel and caches & hashes the output to speed up future builds.
For @acme/ui, the build command is equivalent to the following:
tsup src/*.tsx --format esm,cjs --dts --external react
tsup compiles all of the components in the design system individually, into both ES Modules and CommonJS formats as well as their TypeScript types. The package.json for @acme/ui then instructs the consumer to select the correct format:
{
"name": "@acme/ui\
Prix
Gratuit