refactor(build): 调整依赖管理及构建配置
- 将部分依赖从 dependencies 移至 devDependencies,优化依赖分类 - 新增 peerDependencies,明确对外依赖版本范围,提升兼容性 - 修改 rollup 配置,将 peerDependencies 依赖也标记为外部依赖 - 移除 package.json 中的 prepublishOnly 脚本,简化发布流程 - 保持依赖版本一致性,减少潜在版本冲突风险2.0
parent
41fc5a2445
commit
cb64d58b1e
21
package.json
21
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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 + '/'));
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue