我正在尝试将这个库 https://github.com/flauc/angular2-notifications 从Angular 2+迁移到Angular 9。
最初的错误是关于ModuleWithProviders
已经成为一个泛型类型,所以我进行了修复。我还遇到了一个错误,描述在这里 https://github.com/angular/angular/issues/32352,我使用了require('@angular/compiler-cli');
来解决它,现在我面临另一个错误:
../node_modules/@angular/common/common.d.ts:115:22 - error NG6002: Appears in the NgModule.imports of SimpleNotificationsModule, but could not be resolved to an NgModule class
对我来说很难理解发生了什么,因为我从未构建过库,而且使用gulp构建似乎有点hacky,因为这行代码ngc = require('@angular/compiler-cli/src/main').main
引用了一个不属于公共API的函数。
编辑:
按照评论中的想法(和我的感觉),我尝试不使用gulp构建:
- 创建了一个
angular.json
文件 - 将
index.ts
分成public_api.ts
和simple-notifications.module.ts
- 对文件和文件夹结构进行了一些更改
但我仍然遇到了完全相同的错误...
我的尝试:https://github.com/youkouleley/angular2-notifications
我尝试使用ng build
来构建它,但package.json
中的脚本未被更新。
ng-cli
...这将减少你的头痛。gulp文件只是编译库,而ng-cli也可以完成同样的工作。 - The Fabio