Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing material module in cli lib with Ivy enabled doesn't work #15465

Open
epelc opened this Issue Mar 13, 2019 · 8 comments

Comments

Projects
None yet
3 participants
@epelc
Copy link
Contributor

epelc commented Mar 13, 2019

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.

@vladimirdjurdjevic

This comment has been minimized.

Copy link

vladimirdjurdjevic commented Mar 14, 2019

I managed to build and run application, but i get runtime error when trying to open dialog with MatDialog.

image

@mohammedzamakhan

This comment has been minimized.

Copy link

mohammedzamakhan commented Mar 14, 2019

@vladimirdjurdjevic how did you manage to build and run the application?

@vladimirdjurdjevic

This comment has been minimized.

Copy link

vladimirdjurdjevic commented Mar 14, 2019

Just updated cli version to 8.0.0-beta.5, ng new myapp --enableIvy, and added "aot": true to angular.json options. Check if you have postinstall setup in package.json, "postinstall": "ivy-ngcc".

@epelc

This comment has been minimized.

Copy link
Contributor Author

epelc commented Mar 14, 2019

@vladimirdjurdjevic

This comment has been minimized.

Copy link

vladimirdjurdjevic commented Mar 14, 2019

Anyone has idea why material won't work with ivy?

@vladimirdjurdjevic

This comment has been minimized.

Copy link

vladimirdjurdjevic commented Mar 14, 2019

Just to add, when i turn ivy off, dialog opens as expected.

@epelc

This comment has been minimized.

Copy link
Contributor Author

epelc commented Mar 14, 2019

@vladimirdjurdjevic After messing with it more today my assumption is that ivy just isn't finished yet hence the beta and aot isn't fully supported or it possible needs some lib updates?

Specifically the docs on "ngModule-less bootstrapping" are not really there and using erenderComponent is still a private api. v8 is supposed to release march/april so maybe just use without AOT if you need ivy specific fixes or stick with v7 until v8 is fully released.

@vladimirdjurdjevic

This comment has been minimized.

Copy link

vladimirdjurdjevic commented Mar 14, 2019

I think i will have to stick to v7 for now. It is broken with "aot": false also. I need ivy for dynamic component loading, since i have dialogs in lazy modules, and i don't like moving them to app module. But i will have to wait :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.