I built an Angular 10 library and used it via a direct import (file:dist/my-lib
).
Now I wanted to publish my lib to a private npm repository.
To get that working, I changed my tsconfig.lib.json
and disabled ivy:
"angularCompilerOptions": {
...,
"enableIvy": false
}
All that worked, and I was able to build and publish my library. Most of the library code is working as expected, but in one component (internally used inside the library) there is a function:
export class MyComponent {
public hasChanges(): boolean {
return ...;
}
}
I do invoke this function on an injected @ViewChild('myCustomComponent') myComponent: MyComponent;
, which throws an error that hasChanges is not a function.
I do not really know what one would need to figure out the problem. Any thoughts what could be the problem with disabling ivy?
Everything works fine when I build the library without disabling ivy.
The solution was using Angular >= 11 and the partial compilation mode.
In tsconfig.lib.json
:
"angularCompilerOptions": {
"compilationMode": "partial"
}