diff --git a/package.json b/package.json index 1859efa..42478f5 100644 --- a/package.json +++ b/package.json @@ -22,26 +22,19 @@ "scripts": { "build": "rollup -c", "build:watch": "rollup -c -w", - "prepublishOnly": "npm run build", "patch": "npm version patch", "minor": "npm version minor", "publish": "npm publish", "postinstall": "echo 'Thanks for using our component library!'" }, "dependencies": { - "@ahooksjs/use-url-state": "^3.5.1", - "@ant-design/icons": "^6.2.5", - "@ant-design/pro-components": "^3.1.14-6", "@cqsjjb/jjb-common-lib": "latest", "@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-react": "^1.0.6", - "ahooks": "^3.9.5", - "antd": "^6.4.4", "dayjs": "^1.11.18", "docx-preview": "^0.3.7", "exceljs": "^4.4.0", "lodash-es": "^4.17.21", - "react": "^18.3.1", "react-pdf": "^10.2.0", "react-signature-canvas": "^1.1.0-alpha.2", "throttle-debounce": "^5.0.2", @@ -49,6 +42,9 @@ "x-data-spreadsheet": "^1.1.9" }, "devDependencies": { + "@ahooksjs/use-url-state": "^3.5.1", + "@ant-design/icons": "^6.2.5", + "@ant-design/pro-components": "^3.1.14-6", "@antfu/eslint-config": "^5.4.1", "@babel/core": "^7.28.5", "@babel/preset-react": "^7.28.5", @@ -59,12 +55,23 @@ "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^16.0.3", "@rollup/plugin-terser": "^0.4.4", + "ahooks": "^3.9.5", + "antd": "^6.4.4", "eslint": "^9.37.0", "eslint-plugin-format": "^1.0.2", "eslint-plugin-react-hooks": "^7.0.0", "eslint-plugin-react-refresh": "^0.4.23", "glob": "^13.0.0", "rollup": "^4.54.0", + "react": "^18.3.1", "typescript": "^5.9.3" + }, + "peerDependencies": { + "@ahooksjs/use-url-state": ">=3.5.1 <4", + "@ant-design/icons": ">=6.2.5 <7", + "@ant-design/pro-components": ">=3.1.14-6 <4", + "ahooks": ">=3.9.5 <4", + "antd": ">=6.4.4 <7", + "react": ">=18.3.1 <19" } } diff --git a/rollup.config.js b/rollup.config.js index b3b299e..f41d0a4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -289,9 +289,11 @@ const external = (id) => { } // 4. npm 依赖包标记为外部 -> 不打包到 bundle 中 - // 原因:减少 bundle 体积,避免版本冲突,让消费者项目自己管理依赖 - // 从 package.json 的 dependencies 中读取依赖列表 - const dependencies = Object.keys(pkg.dependencies || {}); + // dependencies 由组件库安装,peerDependencies 由消费者提供,两者都应保留 import。 + const dependencies = [ + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), + ]; return dependencies.some(dep => id === dep || id.startsWith(dep + '/')); };