我正在尝试使用ng generate library ts-utils命令作为npm包创建一个库。
这个库使用一个名为回忆录的依赖项,其中我们在库的peerDependencies部分中包含了库及其各自的@类型。
注意:我的包中没有其他地方引用这些依赖项,仅在package.json中引用这些依赖项
{
"name": "@heanfig/ts-utils",
"version": "1.0.1",
"description": "Plugin for TypeScript to support custom decorators and functions",
"peerDependencies": {
"@angular/common": "^13.2.0",
"@angular/core": "^13.2.0",
"@types/memoizee": "^0.4.7",
"memoizee": "^0.4.15"
},
"dependencies": {
"tslib": "^2.3.0"
},
...
}当我试图生成库并将其发布到npmjs时,它不会产生任何问题,
当我试图通过在需要它的项目中安装它来使用它时,它会生成一个类似于以下所示的警告:
Warning: /Users/hermanfigueroaidarraga/Desktop/@hf/ts-utils-demo/dist/ts-utils/fesm2015/heanfig-ts-utils.mjs depends on 'memoizee'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies此外,它还告诉我memoizee是undefined,当我在安装依赖项的项目中检查时,node_modules文件夹中有memoizee及其类型。


显然存在一个模块、commonJS或umd类型错误,但是无法确定此错误的确切原因,因为我的包没有找到依赖项,因为它知道正确地安装在node_modules目录中及其各自的类型。
谢谢你的关注
发布于 2022-03-09 19:13:11
memoizee及其类型应该进入库的dependencies部分。
对等依赖关系旨在通过插件进行扩展(例如,@angular/...依赖关系,因为它们是扩展的目标)--参见这里的文档https://nodejs.org/es/blog/npm/peer-dependencies/
https://stackoverflow.com/questions/71296203
复制相似问题