nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.51k stars 2.34k forks source link

MFE Angular application doesn't work after update to nx 14.x.x #10733

Closed JeremieLapert closed 2 years ago

JeremieLapert commented 2 years ago

Current Behavior

The command nx run-many --target=build --all failed since NX update to 14.x.x (MFE application)

Expected Behavior

build and run MFE application

Steps to Reproduce

nx run-many --target=build --all

Failure Logs

` ✖ nx run refclearing:build:production ✔ Browser application bundle generation complete.

   Error: apps/refclearing/src/app/app.module.ts:57:13 - error TS2322: Type 'Promise<Type<any> | NgModuleFactory<any> | Routes | RemoteEntryModule>' is not assignable to type 'Type<any> | NgModuleFactory<any> | Routes | Observable<Type<any> | Routes> | Promise<Type<any> | NgModuleFactory<any> | Routes>'.
     Type 'Promise<Type<any> | NgModuleFactory<any> | Routes | RemoteEntryModule>' is not assignable to type 'Promise<Type<any> | NgModuleFactory<any> | Routes>'.
       Type 'Type<any> | NgModuleFactory<any> | Routes | RemoteEntryModule' is not assignable to type 'Type<any> | NgModuleFactory<any> | Routes'.
         Type 'RemoteEntryModule' is not assignable to type 'Type<any> | NgModuleFactory<any> | Routes'.

   57             import('./remote-entry/entry.module').then(
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   58               (m: { RemoteEntryModule: RemoteEntryModule }) => m.RemoteEntryModule
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   59             )
      ~~~~~~~~~~~~~

     node_modules/@angular/router/index.d.ts:1173:44
       1173 export declare type LoadChildrenCallback = () => Type<any> | NgModuleFactory<any> | Routes | Observable<Type<any> | Routes> | Promise<NgModuleFactory<any> | Type<any> | Routes>;
                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       The expected type comes from the return type of this signature.

`

Environment

` ❯ nx report

NX Report complete - copy this into the issue template

Node : 16.13.2 OS : linux x64 yarn : 1.22.17

nx : 14.3.1 @nrwl/angular : 14.3.1 @nrwl/cypress : 14.3.1 @nrwl/detox : Not Found @nrwl/devkit : 14.3.1 @nrwl/eslint-plugin-nx : 14.3.1 @nrwl/express : Not Found @nrwl/jest : 14.3.1 @nrwl/js : Not Found @nrwl/linter : 14.3.1 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/nx-cloud : Not Found @nrwl/nx-plugin : Not Found @nrwl/react : Not Found @nrwl/react-native : Not Found @nrwl/schematics : Not Found @nrwl/storybook : 14.3.1 @nrwl/web : Not Found @nrwl/workspace : 14.3.1 typescript : 4.7.3

Community plugins: @fortawesome/angular-fontawesome: 0.10.2 @ngneat/transloco: 4.0.0 ng2-charts: 3.0.11 @compodoc/compodoc: 1.1.19 @cypress/schematic: 1.7.0 @ngneat/spectator: 10.0.1

`

leosvelperez commented 2 years ago

Thanks for reporting this!

This is a Typescript issue. Adding the type to the module (m: { RemoteEntryModule: RemoteEntryModule }) makes the TS compiler error due to type incompatibility:

Type 'RemoteEntryModule' is not assignable to type 'Type<any> | Routes | NgModuleFactory<any>'

By removing the typing the error goes away and you still have type inference to get the module name. This started to happen now because TS was updated to v4.7.0 which is a bit more strict.

leosvelperez commented 2 years ago

Please note that our generators don't generate MF apps with the routes having that type in place, so this was something manually added in your project after the apps were generated.

I'm closing this since there's no issue on the Nx side of things. If you still think there's an issue in what gets generated by Nx or what the executors do, please feel free to leave a comment.

JeremieLapert commented 2 years ago

@leosvelperez : it's good ! Thanks for your help

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.