You've already forked uniapp-error-monitor
feat(refactor): 大幅重构和优化
✨ 主要更新: - 全面重写README.md,增强文档完整性和易读性 - 新增完整的使用示例和高级用法说明 - 重构代码架构,删除冗余文件,提升代码质量 - 添加TypeScript支持,增强类型安全 - 优化构建配置,支持多种输出格式(ESM/CJS/UMD) - 改进错误捕获机制,支持更多错误类型 📋 具体变更: - README: 从基础文档升级为完整的API参考和使用指南 - 构建: 删除build.sh,构建配置移至rollup.config.js - 类型: 添加index.d.ts,实现完整的TypeScript支持 - 示例: 新增USAGE_EXAMPLES.js提供详细使用示例 - 配置: 优化package.json脚本和依赖管理 🎯 技术提升: - 代码结构更清晰,维护性更好 - 类型安全性显著增强 - 文档质量和用户体验大幅提升 - 支持更多模块格式,兼容性更好 🔖 版本: 1.0.1 -> 1.1.0
This commit is contained in:
@@ -13,6 +13,25 @@ const external = [
|
||||
'uniapp'
|
||||
]
|
||||
|
||||
// 复制 TypeScript 定义文件到 dist 目录
|
||||
function copyTypescriptDefinitions() {
|
||||
return {
|
||||
name: 'copy-types',
|
||||
writeBundle() {
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const srcTypesFile = path.resolve(__dirname, 'src/index.d.ts')
|
||||
const destTypesFile = path.resolve(__dirname, 'dist/index.d.ts')
|
||||
|
||||
if (fs.existsSync(srcTypesFile)) {
|
||||
fs.copyFileSync(srcTypesFile, destTypesFile)
|
||||
console.log('✅ TypeScript definitions copied to dist/index.d.ts')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const plugins = [
|
||||
typescript(),
|
||||
babel({
|
||||
@@ -27,7 +46,8 @@ const plugins = [
|
||||
}
|
||||
}]
|
||||
]
|
||||
})
|
||||
}),
|
||||
copyTypescriptDefinitions()
|
||||
]
|
||||
|
||||
export default defineConfig([
|
||||
@@ -38,7 +58,8 @@ export default defineConfig([
|
||||
{
|
||||
file: pkg.module,
|
||||
format: 'es',
|
||||
sourcemap: true
|
||||
sourcemap: true,
|
||||
exports: 'named'
|
||||
},
|
||||
// UMD 输出 (用于浏览器)
|
||||
{
|
||||
@@ -48,13 +69,15 @@ export default defineConfig([
|
||||
sourcemap: true,
|
||||
globals: {
|
||||
'vue': 'Vue'
|
||||
}
|
||||
},
|
||||
exports: 'named'
|
||||
},
|
||||
// CommonJS 输出 (用于 Node.js)
|
||||
{
|
||||
file: pkg.main,
|
||||
format: 'cjs',
|
||||
sourcemap: true
|
||||
sourcemap: true,
|
||||
exports: 'named'
|
||||
}
|
||||
],
|
||||
external,
|
||||
@@ -69,6 +92,7 @@ export default defineConfig([
|
||||
format: 'umd',
|
||||
name: 'UniAppErrorMonitor',
|
||||
sourcemap: false,
|
||||
exports: 'named',
|
||||
plugins: [terser()]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user