fix: 修复npm publish推送失败的问题

解决以下问题:
- 修复package.json中repository URL的拼写错误
- 添加缺失的构建依赖项(@rollup/plugin-babel, @babel/core等)
- 修复TypeScript类型定义中的字段名冲突
- 修复JavaScript代码中的import.meta语法错误
- 移除JavaScript文件中不当的类型导出
- 添加缺失的LICENSE文件
- 完善package.json配置(添加browser字段等)

确保项目能够成功构建和发布到npm。

Fixes: npm publish失败问题
Closes: 构建配置优化
This commit is contained in:
2025-12-01 22:49:20 +08:00
parent 6ad59a6ae7
commit 75b25b34f4
7 changed files with 4199 additions and 18 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 yuantao
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

4160
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@
"description": "专门为UniApp环境设计的错误监控和上报工具支持全局错误捕获、Promise错误捕获、网络错误捕获等", "description": "专门为UniApp环境设计的错误监控和上报工具支持全局错误捕获、Promise错误捕获、网络错误捕获等",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/index.esm.js", "module": "dist/index.esm.js",
"browser": "dist/index.umd.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"files": [ "files": [
"dist", "dist",
@@ -22,13 +23,13 @@
"error-handling" "error-handling"
], ],
"author": { "author": {
"name": "iFlow CLI", "name": "yuantao",
"email": "contact@iflow.dev" "email": "work@pandorastudio.cn"
}, },
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "hhttps://git.pandorastudio.cn/product/uniapp-error-monitor.git" "url": "https://git.pandorastudio.cn/product/uniapp-error-monitor.git"
}, },
"homepage": "https://git.pandorastudio.cn", "homepage": "https://git.pandorastudio.cn",
"engines": { "engines": {
@@ -44,14 +45,18 @@
"prepublishOnly": "npm run clean && npm run build" "prepublishOnly": "npm run clean && npm run build"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.28.5",
"@babel/preset-env": "^7.28.5",
"@rollup/plugin-babel": "^6.1.0",
"@rollup/plugin-commonjs": "^25.0.0", "@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-node-resolve": "^15.0.0", "@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-typescript": "^11.0.0", "@rollup/plugin-typescript": "^11.0.0",
"rollup": "^3.0.0",
"rollup-plugin-terser": "^7.0.0",
"typescript": "^5.0.0",
"eslint": "^8.0.0", "eslint": "^8.0.0",
"rimraf": "^5.0.0" "rimraf": "^5.0.0",
"rollup": "^2.0.0",
"rollup-plugin-terser": "^7.0.0",
"tslib": "^2.8.1",
"typescript": "^5.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"@dcloudio/uni-app": "^3.0.0" "@dcloudio/uni-app": "^3.0.0"

View File

@@ -1,6 +1,7 @@
import { defineConfig } from 'rollup' import { defineConfig } from 'rollup'
import babel from '@rollup/plugin-babel' import babel from '@rollup/plugin-babel'
import { terser } from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import typescript from '@rollup/plugin-typescript'
const pkg = require('./package.json') const pkg = require('./package.json')
@@ -13,9 +14,10 @@ const external = [
] ]
const plugins = [ const plugins = [
typescript(),
babel({ babel({
babelHelpers: 'bundled', babelHelpers: 'bundled',
extensions: ['.js', '.ts', '.vue'], extensions: ['.js', '.ts'],
exclude: ['node_modules/**'], exclude: ['node_modules/**'],
presets: [ presets: [
['@babel/preset-env', { ['@babel/preset-env', {

View File

@@ -97,13 +97,5 @@ export {
serializeError serializeError
} }
// 导出类型定义
export {
ErrorMonitorOptions,
ErrorType,
ErrorStats,
ErrorInfo
} from './types'
// 导出默认实例(方便直接使用) // 导出默认实例(方便直接使用)
export default errorMonitorInstance export default errorMonitorInstance

View File

@@ -104,7 +104,7 @@ export interface ErrorInfo {
// 小程序错误特有字段 // 小程序错误特有字段
/** 错误对象 */ /** 错误对象 */
error?: any errorObject?: any
/** 页面路径pageNotFound 时) */ /** 页面路径pageNotFound 时) */
path?: string path?: string
/** 查询参数pageNotFound 时) */ /** 查询参数pageNotFound 时) */

View File

@@ -141,7 +141,8 @@ export function isProduction() {
// 检查环境变量 MODE // 检查环境变量 MODE
try { try {
if (typeof import !== 'undefined' && import.meta?.env?.MODE === 'development') { // 使用 process.env 检测环境变量
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'development') {
return false return false
} }
} catch (error) { } catch (error) {