[英]How to resolve “Critical dependency: the request of a dependency is an expression” error for my npm package?
I have a package called all-keyboardevent-keys
that exports an object of keyboardevent strings. 我有一个名为all-keyboardevent-keys
的程序包,该程序包可导出keyboardevent字符串对象。 This package is a dependency in another package that I created, onkey-event-manager
, which I have included in a Gatsby site. 该软件包是我创建的另一个软件包onkey-event-manager
的依赖项,该软件包已包含在Gatsby站点中。
Whenever I start the Gatsby development server on my site, I get the following warning: 每当我在自己的站点上启动Gatsby开发服务器时,都会收到以下警告:
WARNING Compiled with 1 warnings
warning in ./node_modules/all-keyboardevent-keys/lib/index.js
Critical dependency: the request of a dependency is an expression
In searching around, I have learned that this warning comes from webpack , a library that I know little about. 在四处搜寻时,我了解到此警告来自webpack ,这是我鲜为人知的库。
I would love to resolve this warning in my package so other users don't have a problem. 我很乐意解决我的包装中的此警告,以便其他用户没有问题。 Unfortunately, most of the answers on this site and others are for end users and not package maintainers. 不幸的是,此站点上的大多数答案以及其他答案都是针对最终用户的,而不是针对软件包维护者的。
What can I do, as a package author, to resolve this warning? 作为软件包作者,我该怎么做才能解决此警告?
The dependency package in question, all-keyboard-events
, had not been built correctly. 有问题的依赖程序包all-keyboard-events
尚未正确构建。 I replaced Parcel with Babel, updated the build configurations, built again, and the error was resolved. 我用Babel替换了Parcel,更新了构建配置,再次构建,错误得以解决。
I thought this was an instance of Webpack being too particular; 我认为这是Webpack过于具体的一个例子。 instead it was catching an error that my tests cases had missed. 相反,它捕获了我的测试用例遗漏的错误。
Hopefully that is helpful for anyone else experiencing the same issue. 希望对其他遇到相同问题的人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.