Mic*_*ael 5 typescript angular angular-library ng-packagr
随着 Angular 10 的发布,我将用于构建库 + 演示应用程序的 Angular 版本更新到版本 10。
\n一般来说,这一切进展顺利,并且该库仍然与 Angular 的早期版本兼容,但此版本似乎并非如此(针对 Angular 9 的先前版本构建与 Angular 8 运行良好)。
\n输出打字稿定义文件包括:
\nimport * as \xc9\xb5ngcc0 from \'@angular/core\';\n\n...\n\nstatic \xc9\xb5fac: \xc9\xb5ngcc0.\xc9\xb5\xc9\xb5FactoryDef<QrCodeComponent, never>;\nstatic \xc9\xb5cmp: \xc9\xb5ngcc0.\xc9\xb5\xc9\xb5ComponentDefWithMeta<QrCodeComponent, "qr-code", never, { "value": "value"; "size": "size"; "errorCorrectionLevel": "errorCorrectionLevel"; }, {}, never, never>;\nRun Code Online (Sandbox Code Playgroud)\n在 Angular 8 项目中使用时会导致这样的错误:
\n ERROR in node_modules/ng-qrcode/lib/qr-code.component.d.ts(7,25): error TS2694: Namespace \'"/ngqrcode-ng8-test/node_modules/@angular/core/core"\' has no exported member \'\xc9\xb5\xc9\xb5FactoryDef\'.\n node_modules/ng-qrcode/lib/qr-code.component.d.ts(8,18): error TS2314: Generic type \'\xc9\xb5\xc9\xb5ComponentDefWithMeta\' requires 6 type argument(s).\n node_modules/ng-qrcode/lib/qr-code.directive.d.ts(13,25): error TS2694: Namespace \'"/ngqrcode-ng8-test/node_modules/@angular/core/core"\' has no exported member \'\xc9\xb5\xc9\xb5FactoryDef\'.\nRun Code Online (Sandbox Code Playgroud)\n我使用以下命令新创建了测试 Angular 8 项目:
\nnpx @angular/cli@^8 new ngqrcode-ng8-test\nRun Code Online (Sandbox Code Playgroud)\n您可以在此处查看我对此更改的 WIP 拉取请求:https://github.com/mnahkies/ng-qrcode/pull/8
\n注意:我的编译器选项中已经设置了enableIvy false:
\n"angularCompilerOptions": {\n "enableIvy": false\n }\nRun Code Online (Sandbox Code Playgroud)\n有没有办法使用 Angular v10 构建一个保持与 Angular v8 兼容性的库?
\nAngular 10 有 2 个重大变化:
我不认为你可以将 8、9 和 10 的库打包在一个包中:-)
| 归档时间: |
|
| 查看次数: |
4439 次 |
| 最近记录: |