npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jrchan/commontools

v1.0.0

Published

React component library with TypeScript and PropTypes validation

Downloads

4

Readme

React UI 组件库

基于 Monorepo 架构的 React 组件库,采用 TypeScript + PropTypes 双重校验,使用 Rollup 进行打包。

特性

  • 🏗️ Monorepo 架构: 使用 npm workspaces 管理多包项目
  • 🔒 双重类型校验: TypeScript 编译时校验 + PropTypes 运行时校验
  • 📦 Rollup 打包: 支持 ESM 和 CJS 两种格式输出
  • 🎨 代码规范: ESLint + Prettier 确保代码质量
  • 🚀 开发体验: 热更新开发环境,完整的 TypeScript 支持

项目结构

组件库/
├── packages/
│   ├── components/          # 组件包
│   │   ├── src/
│   │   │   ├── Toast/      # Toast 组件
│   │   │   └── index.ts    # 入口文件
│   │   ├── types/          # TypeScript 声明
│   │   └── package.json
│   ├── utils/              # 工具包
│   │   ├── src/
│   │   └── package.json
│   └── example/            # 示例应用
│       ├── src/
│       └── package.json
├── rollup.config.js        # Rollup 配置
├── tsconfig.json           # TypeScript 配置
├── .eslintrc.js           # ESLint 配置
├── .prettierrc            # Prettier 配置
└── package.json           # 根配置

安装依赖

pnpm install

开发命令

# 启动开发服务器(示例应用)
pnpm run dev

# 构建组件库
pnpm run build

# 代码格式化
pnpm run format

# 代码检查
pnpm run lint

# 类型检查
pnpm run type-check

# 清理构建文件
pnpm run clean

技术栈

  • React 18 - 用户界面库
  • TypeScript - 类型安全
  • PropTypes - 运行时类型校验
  • Rollup - 打包工具
  • ESLint + Prettier - 代码质量
  • Vite - 开发工具
  • npm workspaces - Monorepo 管理

Git 配置

项目包含以下 Git 配置文件:

  • .gitignore - 忽略不必要的文件(依赖、构建产物、缓存等)
  • .gitattributes - 配置行尾符和语言检测
  • packages/example/.gitignore - 示例应用特定的忽略规则

构建产物策略

  • 组件库的 dist/ 目录默认不被忽略,以便 npm 发布
  • 示例应用的构建产物被忽略,不需要提交

开发指南

添加新组件

  1. packages/components/src/ 下创建组件目录
  2. 创建组件文件、类型定义、样式文件
  3. 添加 PropTypes 验证
  4. src/index.ts 中导出组件
  5. 在示例应用中添加使用演示

代码规范

项目使用 ESLint 和 Prettier 确保代码质量:

  • 使用 TypeScript 严格模式
  • 组件必须添加 PropTypes 验证
  • 遵循 React Hooks 规范
  • 使用 Prettier 格式化代码

构建产物

构建后会生成以下文件:

packages/components/dist/
├── index.esm.js     # ES Module 格式
├── index.cjs.js     # CommonJS 格式
└── index.d.ts       # TypeScript 声明文件

许可证

MIT