components: Importing material module in cli lib with Ivy enabled doesn't work

Not sure if this is a material bug or a cli one but it wasn’t happening with other libraries afaik.

What is the expected behavior?

You should be able to import a module like MatProgressSpinnerModule from within an NgModule in an angular cli library with the ivy renderer enabled using angular v8 beta.

What is the current behavior?

It works with ivy disabled but when you enable ivy it breaks with the following error.

Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class LoadingModule is my module name within the cli library.

Building Angular Package
Building entry point '@greatcloak/utils'
Compiling TypeScript sources through ngc

BUILD ERROR
node_modules/@angular/common/common.d.ts(115,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/material/progress-spinner/typings/progress-spinner-module.d.ts(1,15): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/flex-layout/typings/module.d.ts(16,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class

Error: node_modules/@angular/common/common.d.ts(115,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/material/progress-spinner/typings/progress-spinner-module.d.ts(1,15): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/flex-layout/typings/module.d.ts(16,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class

    at Object.<anonymous> (/myprojectdir/_web/node_modules/ng-packagr/lib/ngc/compile-source-files.js:65:19)
    at Generator.next (<anonymous>)
    at fulfilled (/myprojectdir/_web/node_modules/ng-packagr/lib/ngc/compile-source-files.js:4:58)

node_modules/@angular/common/common.d.ts(115,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/material/progress-spinner/typings/progress-spinner-module.d.ts(1,15): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/flex-layout/typings/module.d.ts(16,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class

Error: node_modules/@angular/common/common.d.ts(115,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/material/progress-spinner/typings/progress-spinner-module.d.ts(1,15): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class
node_modules/@angular/flex-layout/typings/module.d.ts(16,22): error TS-996002: Appears in the NgModule.imports of LoadingModule, but could not be resolved to an NgModule class

    at Object.<anonymous> (/myprojectdir/_web/node_modules/ng-packagr/lib/ngc/compile-source-files.js:65:19)
    at Generator.next (<anonymous>)
    at fulfilled (/myprojectdir/_web/node_modules/ng-packagr/lib/ngc/compile-source-files.js:4:58)

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV

Create a cli library with an ng module that imports a material module, enable ivy, then try and build it.

Enabled ivy renderer in your tsconfig.json

  "angularCompilerOptions": {
    "enableIvy": "ngtsc"
  }

Also doesn’t work with true which uses different mixed pipeline iirc.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

"@angular/cdk": "7.3.4",
"@angular/material": "7.3.4",

"@angular/animations": "8.0.0-beta.8",
"@angular/common": "8.0.0-beta.8",
"@angular/compiler": "8.0.0-beta.8",
"@angular/core": "8.0.0-beta.8",
"@angular/flex-layout": "7.0.0-beta.23",
"@angular/forms": "8.0.0-beta.8",
"@angular/http": "8.0.0-beta.8",
"@angular/platform-browser": "8.0.0-beta.8",
"@angular/platform-browser-dynamic": "8.0.0-beta.8",
"@angular/pwa": "^0.13.5",
"@angular/router": "8.0.0-beta.8",
"@angular/service-worker": "8.0.0-beta.8",
"@angular/cli": "^8.0.0-beta.5",
"@angular/compiler-cli": "8.0.0-beta.8",
"@angular/language-service": "8.0.0-beta.8",

Is there anything else we should know?

Works fine using angular v8 beta with ivy disabled(also worked on 7.x).

It works if you import material libraries in a regular app project for some reason with ivy enabled.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Same error with "@angular/core": "^8.2.0-next.0". This issue should be reopened @crisbeto

@tcozzens Known issue. You can see it this angular doc Issue: 30565 Primeng team should change the way they build the library