依赖 @ng-bootstrap/ng-bootstrap 必须明确列入白名单 [英] Dependency @ng-bootstrap/ng-bootstrap must be explicitly whiteliste

查看:56
本文介绍了依赖 @ng-bootstrap/ng-bootstrap 必须明确列入白名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

angular 6 项目中,我使用angular cli 命令ng g lierary @some/libName 创建了angular 库.在我的库中,我有一个需要 @ng-bootstrap/ng-bootstrap 的组件,所以我通过 npm i --save @ng-bootstrap/ng-bootstrap 添加了它>.

当我尝试使用命令 ng build @some/libName --prod 构建库时,它会抛出以下错误.

依赖@ng-bootstrap/ng-bootstrap 必须明确列入白名单

有人解决了吗?

解决方案

更新

此警告来自 ng-packagr (现在有一个部分关于这个的 ng-packagr 文档).结果 ng-packagr 只是告诉你它希望你将所有依赖项添加到 "allowedNonPeerDependencies": [] 属性在 ng-package.json(此选项过去称为 whitelistedNonPeerDependencies").例如:

<代码>{allowedNonPeerDependencies":[tslib",...]}

<小时>

原创

我自己就遇到了这个.这个警告来自 ng-packagr 我认为(angular-cli 依赖于生成和打包库).我不太确定他们所说的白名单"是什么意思.因为在 ng-packagr 的文档中似乎没有直接解释这种措辞,但是 这个问题在 ng-packagr 存储库中 有很多不同的选项来解决这个问题.

<块引用>

  1. Peers(例如Angular、RxJS):在这个用例中,第三方依赖是你的库的peerDependency.您库的用户需要在他们的依赖项部分中包含您的库和第三方库.
  2. 嵌入(例如遗留的 JS 库):您有一个遗留的 JavaScript 库(例如一个专有后端的适配器),并且您想(需要)将遗留代码嵌入到您的库中.在这种情况下,第三方依赖项是您的库的 devDependency,并将嵌入到您的库包中.
  3. 混合模式 - 嵌入式 &peer(例如 UX 指南、Angularized styleguide):在这个用例中,第三方依赖是一个 peerDependency,但也(部分)嵌入到你的库中.您可能希望在您的库中重新使用来自第三方库的现有 CSS/SCSS/LESS 样式表,从而嵌入"样式表.库中来自第三方的代码.同时,第三方依赖是您的库的 peerDependency.

github 问题有更多相关信息.

In angular 6 project, I created angular library using angular cli command ng g lierary @some/libName. In my library, I have a component which needs @ng-bootstrap/ng-bootstrap, so I added it by npm i --save @ng-bootstrap/ng-bootstrap.

When I try to build the library using command ng build @some/libName --prod it throws below error.

Dependency @ng-bootstrap/ng-bootstrap must be explicitly whiteliste

Did anyone solved it?

解决方案

Update

This warning is coming from ng-packagr (and there's now a section of the ng-packagr docs about this). Turns out ng-packagr is just telling you that it wants you to add all dependencies to an "allowedNonPeerDependencies": [] property in ng-package.json (this option used to be called "whitelistedNonPeerDependencies"). For example:

{
  "allowedNonPeerDependencies": [
    "tslib",
    ...
  ]
}


Original

Just ran into this myself. This warning is coming from ng-packagr I think (which the angular-cli relies upon to generate and package libraries). I'm not exactly sure what they mean by "whitelist," as that phrasing doesn't seem to be directly explained in ng-packagr's docs, but this issue in the ng-packagr repo has a ton of different options for how to work around the problem.

  1. Peers (such as Angular, RxJS): in this use case, the third-party dependency is a peerDependency of your library. Users of your library need to include both your library and the third-party library in their dependencies section.
  2. Embedding (e.g. legacy JS libraries): you have a legacy JavaScript library (e.g. an adapter to a proprietary backend) and you want to (need to) embed the legacy code in your library. In this case, the third-party dependency is a devDependency of your library and will be embedded into the bundle of your library.
  3. Mixed mode - embedded & peer (e.g. UX guidelines, Angularized styleguide): in this use case, the third-party dependency is a peerDependency but also (partially) embedded in your library. You may want to re-use existing CSS/SCSS/LESS stylesheets from the third-party library in your library, thus "embedding" code from the third-party in your library. At the same time, the third-party dependency is a peerDependency of your library.

The github issue has more info on this.

这篇关于依赖 @ng-bootstrap/ng-bootstrap 必须明确列入白名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆