@a-little-world/little-world-design-system-core

中文文档
1.18.0发布于 2026/10/16LGPL-3.0-onlyTypeScriptESM + CJS构建来源已验证近 30 天下载 1828

Core design tokens and utilities for Little World design system

原始使用文档
文档目录16 节
  1. Installation
  2. Usage
  3. Design Tokens
  4. Fonts
  5. Build pipeline
  6. Runtime exports ( src/fonts/index.ts )
  7. Local Development
  8. ⚠️ Important: Build from Root
  9. Building
  10. Testing with Native Package
  11. Development Workflow
  12. Publishing
  13. Automated Releases (Recommended)
  14. Manual Publishing (Fallback)
  15. TypeScript
  16. Dependencies

@a-little-world/little-world-design-system-core

Core design tokens, utilities, and shared types for the Little World Design System.

Installation

pnpm add @a-little-world/little-world-design-system-core

Usage

import { colors, spacing, typography } from '@a-little-world/little-world-design-system-core';

// Use design tokens
const styles = {
  backgroundColor: colors.primary,
  padding: spacing.medium,
  fontSize: typography.body.fontSize,
};

Design Tokens

The core package provides:

  • Colors - Primary, secondary, and semantic color palettes
  • Typography - Font families, sizes, weights, and line heights
  • Spacing - Consistent spacing scale
  • Breakpoints - Responsive design breakpoints
  • Shadows - Elevation and shadow definitions
  • Border Radius - Consistent border radius values

Fonts

Font binaries live in src/fonts/ and are exported from src/fonts/index.ts. TypeScript compilation does not copy .ttf files into dist/; a separate copy step runs at the end of the build so published packages include the font files next to the compiled JS.

Build pipeline

The build script runs, in order:

  1. clean — removes dist/ and generated .d.ts files under src/
  2. preprocess-svgs — processes SVG assets (unrelated to fonts)
  3. build:esm / build:cjs — compiles TypeScript to dist/esm and dist/cjs (including fonts/index.js, but not the .ttf binaries)
  4. copy-fonts — copies font files into both output trees

copy-fonts uses cpy-cli with --flat, so each file lands directly in dist/esm/fonts/ and dist/cjs/fonts/ (no nested source paths):

copy-fonts:esm  → dist/esm/fonts/
copy-fonts:cjs  → dist/cjs/fonts/

Copied files (must match filenames in src/fonts/):

  • SignikaNegative-Variable.ttf
  • SignikaNegative-Bold.ttf
  • DMSans-Variable.ttf

If you add or rename a font file, update copy-fonts:esm and copy-fonts:cjs in package.json and the paths in src/fonts/index.ts.

Runtime exports (src/fonts/index.ts)

The fonts module is re-exported from the package entry (export * from './fonts').

ExportPurpose
fontPathsRelative paths to .ttf files under ./fonts/ — for web consumers that load fonts from the published package (e.g. @font-face url()).
fontFamiliesCSS / React Native font family names (Signika Negative, DM Sans, etc.).
fontFilesMap of family name → asset from require('./….ttf') for React Native (expo-font / Font.loadAsync). Built inside a try/catch so web bundlers that cannot require binaries do not fail; on web, fontFiles stays undefined.

Native apps should guard usage:

import { fontFiles } from '@a-little-world/little-world-design-system-core';

if (fontFiles) {
  await Font.loadAsync(fontFiles);
}

Local Development

⚠️ Important: Build from Root

Always build and publish from the root of the monorepo, never from individual package directories.

✅ Correct (from root):

pnpm build:core
pnpm --filter=@a-little-world/little-world-design-system-core publish

❌ Incorrect (from package directory):

cd packages/core
pnpm run build
pnpm publish  # This will break workspace dependencies!

Building

# From root of monorepo
pnpm build:core

# Or from the core package directory
cd packages/core
pnpm run build

Testing with Native Package

The core package is automatically built and tested when you run the native testApp:

# This will build both core and native packages
pnpm native:setup

Development Workflow

  1. Make changes to design tokens or utilities
  2. Build core - pnpm build:core
  3. Test in native - pnpm native:setup-and-start (rebuilds and tests)
  4. Test in web - pnpm storybook:web (if web components use core tokens)

Publishing

Releases should ideally be automated and handled via merging into the main branch of the repo.

See the Versioning and Releases section in the root README for detailed information about the automated release process using Changesets.

The automated workflow will:

  • Detect version changes in package.json
  • Publish to GitHub Packages registry
  • Create GitHub releases with changelog information
  • Handle all publishing steps automatically

Manual Publishing (Fallback)

If you need to publish manually (not recommended):

# Ensure you're authenticated to GitHub Packages
pnpm login --registry=https://npm.pkg.github.com

# Build the package
pnpm build:core

# Publish from the core package directory
cd packages/core
pnpm publish --access restricted

Note: Manual publishing bypasses the automated changelog generation and release management. Use the automated process whenever possible.

TypeScript

The package includes TypeScript definitions for all design tokens and utilities:

import type { ColorToken, SpacingToken } from '@a-little-world/little-world-design-system-core';

// Type-safe usage
const color: ColorToken = 'primary'; // ✅ Valid
const invalidColor: ColorToken = 'invalid'; // ❌ TypeScript error

Dependencies

This package has minimal dependencies to avoid conflicts:

  • typescript - For type definitions
  • No runtime dependencies (pure design tokens and utilities)

版本与发布记录

@a-little-world/little-world-design-system-core 共发布 18 个版本,首次发布于 2025/12/31;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.18.0latest2026/10/1623 天前
1.17.12026/08/182 个月前
1.17.02026/08/132 个月前
1.16.12026/07/303 个月前
1.16.02026/07/223 个月前
1.15.02026/06/254 个月前

关于 @a-little-world/little-world-design-system-core 的常见问题

@a-little-world/little-world-design-system-core 是什么?

Core design tokens and utilities for Little World design system

如何安装 @a-little-world/little-world-design-system-core?

在项目目录运行 npm install @a-little-world/little-world-design-system-core,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@a-little-world/little-world-design-system-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@a-little-world/little-world-design-system-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@a-little-world/little-world-design-system-core 可以商用吗?

@a-little-world/little-world-design-system-core 使用 LGPL-3.0-only 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@a-little-world/little-world-design-system-core 的下载量有多少?

根据 npm 官方下载统计,@a-little-world/little-world-design-system-core 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,828 次,日均约 61 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@a-little-world/little-world-design-system-core 还在维护吗?

最新版本 1.18.0 发布于 2026/10/16(23 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2025/12/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。