manfredsteyer / angular3-app

6 stars 3 forks source link

@angular-architects/module-federation version vs angular version #1

Open stockmind opened 1 year ago

stockmind commented 1 year ago

Hello, it seems that the specified version for @angular-architects/module-federation package in this example is ^14.2.0 but the angular version in use in this mfe is 12.0.3.

The package @angular-architects/module-federation suggests in its README (https://github.com/angular-architects/module-federation-plugin/blob/main/libs/mf/README.md#which-version-to-use) that with Angular 12 we should use @angular-architects/module-federation: ^12.0.0.

In this example the dependency was updated to ^14.2.0 only to be able to use the new appType property on bootstrap and the router workarounds? There are other reasons (bugs, fixes, etc..)? We should always use the same @angular-architects/module-federation version in use in the Shell regardless of the angular version of the MFE?

I ask this because it seems that if i try for example to install dependencies of this example using Yarn instead of NPM i get this error on yarn start:

./node_modules/@angular-architects/module-federation-tools/fesm2020/angular-architects-module-federation-tools.mjs - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):
TypeError: Cannot create property 'message' on string '/Users/simonerobertonunzi/Projects/sandbox/angular3-app/node_modules/@angular-architects/module-federation-tools/fesm2020/angular-architects-module-federation-tools.mjs: **This application depends upon a library published using Angular version 14.1.1, which requires Angular version 14.0.0 or newer to work correctly.**

Removing the package-lock also makes npm install fail right away with issues resolving dependencies:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: mfe2@0.0.0
npm ERR! Found: zone.js@0.10.2
npm ERR! node_modules/zone.js
npm ERR!   zone.js@"0.10.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer zone.js@"~0.11.4" from @angular/core@12.0.3
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"12.0.3" from the root project
npm ERR!   peer @angular/core@"12.0.3" from @angular/common@12.0.3
npm ERR!   node_modules/@angular/common
npm ERR!     @angular/common@"12.0.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Output of ng version:

Angular CLI: 14.1.1
Node: 16.15.0
Package Manager: npm 8.5.5
OS: darwin x64

This example seems to work fine only if used with npm install without touching deps or lock, but shouldn't create unexpected issues to use packages intended for a different angular major version?

marco24690 commented 11 months ago

same here