generator-angular2-library
generator-angular2-library copied to clipboard
Consuming one NPM library in another NPM library results in an error in Angular 5 with Material 5
I am attempting to upgrade my projects to Angular 5 and Material 5rc1.
With Angular 4 and Material Beta versions, everything worked fine.
My setup is like this (all NPM packages created with your generator and the Angular 5 changes applied):
-Base Class NPM package -Controls NPM package (uses Base Class) -Module NPM package (uses Controls and Base Class) -Main Application, uses all 3
When compiling and uploading the Base Class NPM package, everything works fine.
When compiling Controls, I get this error during the ngc step:
Error: Illegal state: Could not load the summary for directive CdkObserveContent in C:/projects/ThisProject/node_modules/@angular/cdk/observers/typings/index.d.ts.
I have worked around this somewhat by including the code from the Base Class package in the Controls package. This allowed me to continue working on the Main Application to get all of that working. Unfortunately, I can't do that with the Module package, since it uses the Controls and I don't want to include that code in that package because that would be duplicating code.
I have found this issue in the Material Github issue list:
https://github.com/angular/material2/issues/8070
In it, the original poster removed this line from the tsconfig file to get it to work again:
"rootDir": "."
And when I do that, the error goes away, but the rollup:fesm step ends up erroring for another reason:
events.js:160 throw er; // Unhandled 'error' event ^ Error: Could not resolve entry (C:\projects\ThisProject\build/index.js)
I have tried modifying the gulpfile.js file so that this would work, but no matter what I do, the compilation files are not correct. Once I removed the Base Classes package from Controls and included the code, everything worked.
Again, this whole setup works if I revert back to Angular 4 and Material Beta. I know the original error is related to Material, but I feel like there is something I can do related to how this generator created the packages to fix this, I just don't know what that is.
Any help would be appreciated, been working on this for days now.
Thanks!
I just upgraded from angular 4.x to 5.x also, and I have the same issues
I'm revisiting Angular 5, with the hope that the newer releases of Angular 5.1.2 and Material 5.0.2 would have somehow fixed this, but it did not. I still can't remove the rootdir entry, which seems to be a common fix for a similar problem (but not this setup).
If someone with more knowledge than me could post a fix that works, I would greatly appreciate it.
Thanks
I was able to work around this, temporarily, by only uploading the source files to NPM. Compiling them prior to uploading still does not work.
So at least I can make progress, but it's not ideal. A solution is still necessary.