gpt4 book ai didi

angular - 使用 enableIvy : false gives an error 编译 Angular 9 库

转载 作者:行者123 更新时间:2023-12-02 16:36:15 25 4
gpt4 key购买 nike

我正在使用 Angular 9/ng-packagr 编译一个库,它可以工作。但是,如果我更改 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'. Please add a @NgModule annotation.

OtherLibModule 是我创建的另一个库,使用 Angular 9 和 "enableIvy": false 构建。

最佳答案

问题是 otherlib 中的 public-api.ts 正在导出文件夹,而不是桶文件(索引)。所以我改变了

export * from "./lib";

export * from "./lib/index";

public-api.ts 中,它起作用了。问题是生成的 otherlib-metadata.json 没有包含所有必需的元数据。

关于此事还有一个已报告的问题 https://github.com/ng-packagr/ng-packagr/issues/355 .我无法相信它在两年多后仍未得到解决。

关于angular - 使用 enableIvy : false gives an error 编译 Angular 9 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62665731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com