[英]Peer dependency for peer dependency
Here is my current modules hierarchy: 这是我当前的模块层次结构:
I'm writing the
Module
(which has green background and is inside dotted square). 我正在编写
Module
(具有绿色背景,位于虚线方框内)。
It has DepA
dependency which has DepB
peer dependency. 它具有
DepA
依赖性,它具有DepB
对等依赖性。
My module is kind of a config-helper for the main App
. 我的模块是主
App
的配置助手。
Module
does not use DepB
itself. Module
不使用DepB
本身。
But it helps to work with DepB
via DepA
. 但它有助于通过
DepA
与DepB
DepA
。
The App
works with DepB
and has it as a dependency (regular). 该
App
与DepB
一起DepB
并将其作为依赖项(常规)。
So, I was thinking that this DepB
should be a peer dependency in the Module
. 所以,我认为这个
DepB
应该是Module
的对等依赖。
But that does not work. 但这不起作用。
It leads to unmet peer dependency
problem: DepA
expects to find it "inside" Module
. 它导致
unmet peer dependency
问题: DepA
希望在“内部” Module
找到它。
Why can't I proxy that peer dependency to the App
which actually uses it? 为什么我不能将该对等依赖代理到实际使用它的
App
?
What are the best practices for that kind of situation? 针对这种情况的最佳做法是什么?
Update 更新
The question is not relevant. 这个问题不相关。
See my answer. 看我的回答。
OMG, that was my fault! 天哪,那是我的错!
While testing Module
I did require('../')
instead of require('@my/module')
. 测试
Module
我确实require('../')
而不是require('@my/module')
。
By that I was trying to avoid re-installation on every change. 我试图避免在每次改变时重新安装。
That was the root of all incorrect module resolution issues. 这是所有不正确的模块解决问题的根源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.