-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Library is skipped by Ivy / ngcc compiler #40357
Description
🐞 Bug report
Command (mark with an x)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- extract-i18n
- run
- config
- help
- version
- doc
Is this a regression?
I'm not sure. Upgraded to angular 11 almost together with getting the issue - might be.
Description
I maintain a set of libraries to work with gRPC from Angular, here is the link: https://github.com/ngx-grpc/ngx-grpc
The lib includes 6 libs (located in packages):
- one non-angular (however located between angular apps, just is not present in angular.json) - protoc plugin -
protoc-gen-ng - 4 normal angular libs
- 1 angular lib; built using Angular toolset but is used inside a web worker -
worker.
There is also examples directory served as example and, well, as a test reference that all goes fine. This example uses all the libs, and this is the place where the error is happening.
Now I added a module with forRoot / forChild in some of the angular libraries: core (2 modules), grpc-web-client (1 module) and worker-client (1 module). All modules and libs are working fine, all, but the latter one. It is just not processed by ngcc. When I start the application I see the following:
Compiling @ngx-grpc/common : es2015 as esm2015
Compiling @ngx-grpc/core : es2015 as esm2015
Compiling @ngx-grpc/- removing all references to the `Worker` type () : es2015 as esm2015
Compiling @ngx-grpc/well-known-types : es2015 as esm2015
Compiling @ngx-grpc/worker : es2015 as esm2015
Compiling @ngx-grpc/worker-client : es2015 as esm2015
So, the ngcc reaches the library, but the directory __ivy_ngcc__ is not created in dist/worker-client, however for all other modules it is created. The outcome is that the latter library does not work.
What I tried:
- removing all references to the
Workertype fromworker-client- did not help - checking angular config, including angular.json, tsconfigs and ng-packagr - did not help, it is totally equal to the working lib
grpc-web-client - regenerated the lib from scratch - did not help
- removed references to
workerlibrary fromworker-client- did not help - moved code from
worker-clienttogrpc-web-clientlib. This made the code work, meaning that thegrpc-web-clienthad no problems with ngcc; and I can use the code in the example and it works just fine. However, I cannot get more out of it; I still need the code in a separate package. This also means that code is valid and it can be compiled by ngcc, but for some reason when it's in its own package it does not.
What is also very weird - I would not be surprised if I had problems with worker library; it's built by Angular and used in Worker. And I have a feeling it can be connected to the issue.
I don't know what / where else to dig. The issue is driving me crazy. It seems unlogical to me and I cannot find the reason.
Please help me out.
🔬 Minimal Reproduction
- Clone https://github.com/ngx-grpc/ngx-grpc
- Switch to develop branch
npm cinpm run build- builds the libsnpm run examples- produces the error after ngcc compiler
🔥 Exception or Error
Error: dist/worker-client/lib/grpc-worker-client.module.d.ts:11:22 - error NG6002: Appears in the NgModule.imports of GrpcWorkerClientExampleModule, but could not be resolved to an NgModule class.
This likely means that the dependency (@ngx-grpc/worker-client) which declares GrpcWorkerClientModule has not been processed correctly by ngcc.
11 export declare class GrpcWorkerClientModule {
🌍 Your Environment
Angular CLI: 11.0.2
Node: 14.5.0
OS: darwin x64
Angular: 11.0.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.2
@angular-devkit/build-angular 0.1100.2
@angular-devkit/core 11.0.2
@angular-devkit/schematics 11.0.2
@angular/cdk 11.0.0
@angular/material 11.0.0
@schematics/angular 11.0.2
@schematics/update 0.1100.2
ng-packagr 11.0.3
rxjs 6.6.3
typescript 4.0.5
Anything else relevant?
I'm not sure wheher the issue belongs to @angular/cli, please feel free to locate it properly in case it's necessary