opentiny / ng

Angular UI components library.
https://opentiny.design/tiny-ng
MIT License
104 stars 11 forks source link

[Bug]: 希望 @opentiny/ng 将@opentiny/*的依赖定义成 dependencies,别定义成 peerDependencies #11

Closed fengyon closed 1 year ago

fengyon commented 1 year ago

Version

1.0.0

Angular Version

15.0.0

Link to minimal reproduction

https://www.npmjs.com/package/@opentiny/ng/v/1.0.0?activeTab=code 中的package.json

 "peerDependencies": {
    "@angular/common": ">=13.0.0",
    "@angular/core": ">=13.0.0",
    "@opentiny/ng-accordion": "1.0.0",
    "@opentiny/ng-actionmenu": "1.0.0",
    "@opentiny/ng-alert": "1.0.0",
    "@opentiny/ng-anchor": "1.0.0",
    "@opentiny/ng-autocomplete": "1.0.0",
    "@opentiny/ng-avatar": "1.0.0",
    "@opentiny/ng-base": "1.0.0",
    "@opentiny/ng-button": "1.0.0",
    "@opentiny/ng-buttongroup": "1.0.0",
    "@opentiny/ng-card": "1.0.0",
    "@opentiny/ng-cascader": "1.0.0",
    "@opentiny/ng-checkbox": "1.0.0",
    "@opentiny/ng-collapse": "1.0.0",
    "@opentiny/ng-collapsebox": "1.0.0",
    "@opentiny/ng-collapsebutton": "1.0.0",
    "@opentiny/ng-copy": "1.0.0",
    "@opentiny/ng-crumb": "1.0.0",
    "@opentiny/ng-date": "1.0.0",
    "@opentiny/ng-datebase": "1.0.0",
    "@opentiny/ng-datedominator": "1.0.0",
    ... (109条)
}

Step to reproduce

查看1.0.0版本的pakcage.json即可

What is expected

安装了 @opentiny/ng 之后,不需要安装里面的一大堆的子依赖。

一切@opentiny/ng有关的依赖定义成 dependencies,而非 peerDependencies。

What is actually happening

一般项目都是把所有组件库安装到node_modules,然后按需引入。 安装了 @opentiny/ng 之后,还需要安装里面的一大堆的子依赖(共有109个!!!),项目pacakage.json变得特别多、特别复杂、特别难以维护。

一般讲的是按需“引入”组件,按需构建,而非按需“安装”组件依赖。

Any additional comments (optional)

No response

lamianbu commented 1 year ago

请安装npm7或更高版本,会自动安装peerDependencies 。

抱歉,是我们文档和package.json没有描述要求npm7。

已发布1.0.1版,package.json已添加

"engines": { "npm": ">=7.0.0" },

安装时如果npm版本不对,会明确报错。

fengyon commented 1 year ago

据我所知,peerDependencies是不会自动安装的,dependencies才会自动安装。

我试了一下16.6.0的node版本,不会安装 peerDependencies

mkdir test && cd test 
npm init -y && npm install @opentiny/ng
cd node_modules/@opentiny && ls -a 

结果,只有@opentiny/ng 依赖,并没有组件的依赖

./  ../  ng/
chensi66666 commented 11 months ago

我也遇到同样的问题,放在peerDependencies 里安装很麻烦。项目用 yarn 和 pnpm 做包管理的时候都不会自动下载这些依赖