@cooperco/cooper-component-library

中文文档
0.1.154发布于 2026/11/06TypeScriptESM + CJS近 30 天下载 2309

A Vue 3 component library built with TypeScript, Vite, and Tailwind CSS. Published as @cooperco/cooper-component-library and designed for integration with Contentful CMS via GraphQL.

原始使用文档
文档目录12 节
  1. Tech Stack
  2. Recommended IDE Setup
  3. Development
  4. Testing Locally
  5. Building and Publishing
  6. Workflow
  7. Hotfix releases
  8. Build Process
  9. Package Exports
  10. Project Structure
  11. Documentation
  12. TODO Issues

Cooper Component Library

A Vue 3 component library built with TypeScript, Vite, and Tailwind CSS. Published as @cooperco/cooper-component-library and designed for integration with Contentful CMS via GraphQL.

Tech Stack

  • Vue 3.5+ - Composition API with <script setup>
  • TypeScript 5.3+ - Strict mode enabled
  • Tailwind CSS 3.4+ - Utility-first styling
  • Vite 5.2+ - Library build mode
  • Storybook 8.2+ - Component documentation
  • GraphQL - Contentful CMS integration
  • pnpm - Package manager

Development

# Install dependencies
pnpm install

# Start Storybook dev server
pnpm run dev

# Run linter
pnpm run lint

# Fix linting issues
pnpm run lint:fix

# Type check
pnpm run check-types

Testing Locally

To test the component library in a consuming project before publishing:

# 1. Build and pack the library
pnpm run local-test

This creates a .tgz file in the root directory (e.g., cooperco-cooper-component-library-0.1.61.tgz)

# 2. In the consuming project, install the local package
pnpm add /path/to/cooperco-cooper-component-library-0.1.61.tgz

This allows you to test changes locally before publishing to npm.

Building and Publishing

The build and publish process needs to happen manually when changes are merged to main:

Workflow

  1. Merge to main - Merge your feature branch to main
  2. Patch version - Update version number using npm version patch (or minor/major)
  3. Publish - Run npm publish to publish to npm registry
  4. Push - Push changes and tags to GitHub

Hotfix releases

If one urgent fix must reach an environment that is pinned to an older library version, and the fix touches nothing under cms/, see docs/hotfix-release.md for publishing "old tag + this fix only" as a pre-release without dragging in intermediate migrations.

Build Process

When you run pnpm run build, the following happens in order:

  1. build:types - Compiles Vue component TypeScript definitions
  2. build:cms - Compiles GraphQL queries for Contentful
  3. vite build - Builds the component library bundle

All build artifacts are output to the dist/ directory.

Package Exports

The package exports multiple entry points:

  • Components: @cooperco/cooper-component-library - Main component library
  • Styles: @cooperco/cooper-component-library/css/main.css - Main styles
  • Theme: @cooperco/cooper-component-library/css/theme.css - Theme variables
  • Queries: @cooperco/cooper-component-library/cms/contentful/graphql - GraphQL queries

Project Structure

├── src/
│   ├── components/          # Vue components
│   │   ├── ComponentName/
│   │   │   ├── ComponentName.vue
│   │   │   └── ComponentName.ts
│   │   ├── components.ts    # Component exports
│   │   └── types.ts         # Type exports
│   ├── config/              # Configuration (color palettes, passthroughs)
│   └── utils/               # Utility functions
├── cms/
│   └── contentful/
│       └── queries/         # GraphQL queries (see cms/contentful/queries/README.md)
├── .storybook/              # Storybook configuration
│   └── components/          # Component stories
└── dist/                    # Build output (generated)

Documentation

TODO Issues

  • There are many places where class is not recognized by TypeScript. Examples are "start"/"end" in ContainerModule. This is because we are not defining class on the component types. Defining them explicitly overrides the default Attribute Inheritance behavior of Vue. Need to find a way to get around this

版本与发布记录

@cooperco/cooper-component-library 共发布 157 个版本,首次发布于 2024/08/07;过去 12 个月发布了 95 个版本。

版本发布日期距今
0.1.154latest2026/11/065 天前
0.1.1532026/11/047 天前
0.1.1522026/11/047 天前
0.1.1512026/10/3011 天前
0.1.1502026/10/3012 天前
0.1.1492026/10/2714 天前

其他发布通道:hotfix → 0.1.128-hotfix.2。

关于 @cooperco/cooper-component-library 的常见问题

@cooperco/cooper-component-library 是什么?

A Vue 3 component library built with TypeScript, Vite, and Tailwind CSS. Published as @cooperco/cooper-component-library and designed for integration with Contentful CMS via GraphQL.

如何安装 @cooperco/cooper-component-library?

在项目目录运行 npm install @cooperco/cooper-component-library,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.0.0)、graphql-tag(^2.12.6)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cooperco/cooper-component-library 支持 TypeScript 吗?

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

@cooperco/cooper-component-library 支持 ESM 还是 CommonJS?

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

@cooperco/cooper-component-library 可以商用吗?

@cooperco/cooper-component-library 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@cooperco/cooper-component-library 的下载量有多少?

根据 npm 官方下载统计,@cooperco/cooper-component-library 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,309 次,日均约 77 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cooperco/cooper-component-library 还在维护吗?

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