angular-architects / module-federation-plugin

MIT License
725 stars 195 forks source link

NF and NX, failing to resolve import of libraries(latest Angular & NF packages) #639

Closed BednarovskyiIhor closed 1 month ago

BednarovskyiIhor commented 1 month ago

I have NX project to utilize native federation and I'm struggling to get the library imports to work. Here is the error I'm getting when serving one of the microfrontends

WARN Sharing mapped paths with wildcards (*) not supported INFO Building federation artefacts X [ERROR] TS2307: Cannot find module '@ttt/utils/src' or its corresponding type declarations. [plugin angular-compiler] libs/utils/src/lib/action-service.ts:2:28: 2 │ import { DataService } from '@ttt/utils/src'; ╵ ~~~~~ X [ERROR] TS2339: Property 'post' does not exist on type 'ActionService'. [plugin angular-compiler] libs/utils/src/lib/action-service.ts:19:16: 19 │ return this.post(methodName, { ActionId: actionId }); ╵ ~~~~ X [ERROR] TS2307: Cannot find module '@ttt/utils/src/lib/beautifier.service' or its corresponding type declarations. [plugin angular-compiler] libs/utils/src/lib/beautifier-factory.ts:2:34: 2 │ ... BeautifierService } from '@ttt/utils/src/lib/beautifier.service'; ╵ ~~~~~~~~ X [ERROR] TS2307: Cannot find module '@ttt/session-management/src/lib/session/services/intialize-session.service' or its corresponding type declarations. [plugin angular-compiler] libs/utils/src/lib/data.service.ts:7:41: 7 │ ...ice } from '@ttt/session-management/src/lib/session/services/in... ╵ ~~~~~~~~~~~~~ X [ERROR] TS2307: Cannot find module '@ttt/session-management/src/lib/session/services/session-data.service' or its corresponding type declarations. [plugin angular-compiler] libs/utils/src/lib/data.service.ts:8:35: 8 │ ...ice } from '@ttt/session-management/src/lib/session/services/se... ╵ ~~~~~~~~~~~~~ X [ERROR] TS2307: Cannot find module '@ttt/session-management' or its corresponding type declarations. [plugin angular-compiler] libs/utils/src/lib/data.service.ts:9:37: 9 │ import { ConfigurationService } from '@ttt/session-management';

My tsconfig.base.json

{ "compileOnSave": false, "compilerOptions": { "rootDir": ".", "sourceMap": true, "allowJs": true, "declaration": false, "moduleResolution": "node", "useDefineForClassFields": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "resolveJsonModule": true, "esModuleInterop": true, "importHelpers": true, "target": "ES2022", "module": "ES2022", "typeRoots": ["node_modules/@types"], "lib": ["ES2022", "dom"], "skipLibCheck": true, "skipDefaultLibCheck": true, "baseUrl": ".", "paths": { "@ttt/": ["libs/"], "@ttt/utils": ["libs/utils/src/index.ts"], "@ttt/i18n": ["libs/i18n/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] }

I'm using version 18.1.3 of the native federation library.

BednarovskyiIhor commented 1 month ago

The problem was in the configuration of the tsconfig.json file