简体   繁体   English

对等依赖的对等依赖

[英]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 . 但它有助于通过DepADepB DepA

The App works with DepB and has it as a dependency (regular). AppDepB一起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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM