简体   繁体   English

使用 enableIvy: false 编译 Angular 9 库时会出现错误

[英]Compiling an Angular 9 library with enableIvy: false gives an error

I'm compiling a library with Angular 9/ng-packagr and it works.我正在用 Angular 9/ng-packagr 编译一个库,它可以工作。 But if I change in angularCompilerOptions and disable Ivy "enableIvy": false then I get the following error:但是,如果我更改angularCompilerOptions并禁用 Ivy "enableIvy": false那么我会收到以下错误:

ERROR: Unexpected value 'OtherLibModule in.../node_modules/other-lib-module/other-lib-module.d.ts' imported by the module 'MyModule in my-project/projects/my-lib/src/app/my.module.ts'.错误:由模块'MyModule in my-project/projects/my-lib/src/app/ 导入的意外值'OtherLibModule in.../node_modules/other-lib-module/other-lib-module.d.ts'我的.module.ts'。 Please add a @NgModule annotation.请添加 @NgModule 注释。

OtherLibModule is another library that I created, built with Angular 9 and "enableIvy": false . OtherLibModule是我创建的另一个库,使用 Angular 9 和"enableIvy": false

The problem was that public-api.ts in otherlib was exporting the folder, not the barrel file (index).问题是 otherlib 中的public-api.ts otherlib导出文件夹,而不是桶文件(索引)。 So I changed所以我改变了

export * from "./lib";

to

export * from "./lib/index";

in public-api.ts and it worked.public-api.ts中,它起作用了。 The problem was that the generated otherlib-metadata.json was not including all the required metadata.问题是生成的otherlib-metadata.json不包括所有必需的元数据。

There's also a reported issue on this matter https://github.com/ng-packagr/ng-packagr/issues/355 .还有一个关于这个问题的报告问题https://github.com/ng-packagr/ng-packagr/issues/355 I cannot believe it's not solved even more than two years later.我不敢相信两年多后它还没有解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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