Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peerDependencies-对等依赖 #47

Open
huangshuwei opened this issue Nov 24, 2020 · 0 comments
Open

peerDependencies-对等依赖 #47

huangshuwei opened this issue Nov 24, 2020 · 0 comments

Comments

@huangshuwei
Copy link
Owner

huangshuwei commented Nov 24, 2020

前言

打包组件库或者工具库时,我们会将 vue、react、angular 排除打包文件外,而是希望用户使用时自己安装。这时就需要 peerDependencies了。

只有在发布库文件时才会用到

各种 dependencies 的比较

  • dependencies 生产环境需要的依赖包。比如 deepmerge、lodash 等
  • devDependencies 开发环境时需要的依赖包。比如webpack 插件、node 插件、gulp 插件等
  • peerDependencies 你通过externals排除在打包库文件之外的依赖。比如 vue、react、angular

peerDependencies

作用
告诉用户,你使用我的库,还需要具备 vue、react、angular 等环境。在peerDependencies 里的依赖,用户在安装的时候会自动安装

添加 peerDependencies 依赖命令

yarn add <package...> [--peer/-P]

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant