With Angular 10 being released, I am updating the version of Angular used to build a library + demo application to version 10.
Generally this goes smoothly, and the library remains compatible with previous versions of Angular, but this doesn't seem to be the case with this release (prior version build against Angular 9 works fine with Angular 8).
The output typescript definition files include:
import * as ɵngcc0 from '@angular/core';
...
static ɵfac: ɵngcc0.ɵɵFactoryDef<QrCodeComponent, never>;
static ɵcmp: ɵngcc0.ɵɵComponentDefWithMeta<QrCodeComponent, "qr-code", never, { "value": "value"; "size": "size"; "errorCorrectionLevel": "errorCorrectionLevel"; }, {}, never, never>;
Which causes errors like this when consuming in an Angular 8 project:
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 'ɵɵFactoryDef'.
node_modules/ng-qrcode/lib/qr-code.component.d.ts(8,18): error TS2314: Generic type 'ɵɵComponentDefWithMeta' requires 6 type argument(s).
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 'ɵɵFactoryDef'.
I created the test angular 8 project freshly using:
npx @angular/cli@^8 new ngqrcode-ng8-test
You can see my WIP pull request for this change here: https://github.com/mnahkies/ng-qrcode/pull/8
Note: I already have enableIvy false in my compiler options:
"angularCompilerOptions": {
"enableIvy": false
}
Is there a way to build a library using Angular v10 that maintains compatibility with Angular v8?
There are 2 big breaking changes in angular 10:
I don't think you can package a lib for 8, 9, and 10 in one single package :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With