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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ddc-123/vue3-component-lib

v0.1.16

Published

一个基于 Vue 3 的轻量组件库,采用 Vite lib 模式构建,支持 ESM/CJS 双格式与类型文件输出,内置基础样式变量,开箱即用。

Readme

@ddc-123/vue3-component-lib

一个基于 Vue 3 的轻量组件库,采用 Vite lib 模式构建,支持 ESM/CJS 双格式与类型文件输出,内置基础样式变量,开箱即用。

安装

npm i @ddc-123/vue3-component-lib
# 或者
pnpm add @ddc-123/vue3-component-lib
  • 对等依赖:vue >= 3.3.0

快速开始

  • 全量引入(全局注册所有组件)
import { createApp } from 'vue'
import UiLib from '@ddc-123/vue3-component-lib'
import '@ddc-123/vue3-component-lib/style.css'
import App from './App.vue'

createApp(App).use(UiLib).mount('#app')
  • 按需使用(本地注册或直接在模板中使用)
import { UiButton } from '@ddc-123/vue3-component-lib'
import '@ddc-123/vue3-component-lib/style.css'

export default {
  components: { UiButton },
}

默认插件会自动全局注册组件,注册逻辑见 src/index.ts:7install(app) 方法,同时全局引入基础样式 src/styles/index.css

安装后如何导入

  • 在项目入口处(如 main.ts)引入库与样式:
import UiLib from '@ddc-123/vue3-component-lib'
import '@ddc-123/vue3-component-lib/style.css'
  • 全量使用时通过 app.use(UiLib) 完成全局注册;按需使用时只需按模块导入对应组件。
  • 样式文件为构建产物 dist/vue3-component-lib.css,包内导出子路径为 style.css,需要显式引入一次以确保主题变量与基础样式生效。

组件列表

  • UiButton 基础按钮,导出位置:src/components/index.ts:1
    • 主要 props:variant: 'primary' | 'secondary' | 'text'disabled: boolean(定义处:src/components/Button/Button.vue:12-20
    • 事件:click(MouseEvent)(定义处:src/components/Button/Button.vue:18-20

示例:

<template>
  <UiButton variant="primary">Primary</UiButton>
  <UiButton variant="secondary">Secondary</UiButton>
  <UiButton variant="text" :disabled="true">Text</UiButton>
</template>

主题与样式

  • 全局样式变量定义在 src/styles/index.css:1-4
  • 可在项目中覆盖 CSS 变量来自定义主题,例如:
:root {
  --ui-primary: #1f7ae0;
  --ui-text: #222;
}

本地开发(Playground)

仓库内置 playground 站点用于演示与调试组件:

npm run play         # 启动开发服务器
npm run play:build   # 构建演示站点
npm run play:preview # 预览构建产物
  • 在 Playground 中通过别名直接引用源码:playground/vite.config.ts:10
  • 路由会自动收集 playground/src/*/index.vue 作为演示页面,见 playground/src/router.ts:4-15

构建与类型检查

npm run build      # 产物输出到 dist/
npm run typecheck  # TypeScript 类型检查
  • 构建配置位于 vite.config.ts:8-22,输出 escjs 两种格式,并生成类型文件到 dist/types
  • 包入口与导出:
    • main: dist/index.cjs.js
    • module: dist/index.es.js
    • types: dist/types/index.d.ts
    • exports: import/require/default/types 指向上述文件(见 package.json

目录结构

├─ src
│  ├─ components
│  │  ├─ Button/Button.vue
│  │  └─ index.ts
│  ├─ styles/index.css
│  └─ index.ts
├─ playground
│  ├─ src
│  │  ├─ Button/index.vue
│  │  ├─ App.vue
│  │  ├─ Home.vue
│  │  └─ router.ts
│  └─ vite.config.ts
├─ vite.config.ts
├─ package.json
└─ docs
   ├─ 发布指南.md
   └─ 添加组件.md

发布到 npm(摘要)

  1. 登录并确认账户:npm loginnpm whoami
  2. 构建与类型检查:npm run buildnpm run typecheck
  3. 版本号递增:npm version patch
  4. 发布:npm publish(作用域包如需公开:npm publish --access public

详细步骤可参考 docs/发布指南.md

许可证

MIT