Open w3k5 opened 3 years ago
My repos host app: https://github.com/w3k5/host-app-test remote app: https://github.com/w3k5/remote-app-test
I would suggest using libraries for sharing components between applications.
You can create publishable libraries that can be shared across applications.
nx g @nrwl/angular:lib shared-components --buildable --publishable
I would suggest using libraries for sharing components between applications. You can create publishable libraries that can be shared across applications.
nx g @nrwl/angular:lib shared-components --buildable --publishable
Is it possible to share such a library, having two repos? For instanse, we have a repo with libraries and a repo with components. Components somehow must consume services from libraries. Is Module Federation a silver bullet for this case? Or we have to compile libraries and components in one monorepo?
Here's how I modified the example to work with a component not in the monorepo.
ng build auth-lib
npm link
the dist/auth-lib dirnpm link auth-lib
in the shell app and the remote component appauth-lib": { singleton: true, strictVersion: true, requiredVersion: 'auto' }
auth-lib": "0.0.1
AuthService
code belowAuthService
in your app.module in the shell and remote - providers: [AuthService]
import { BehaviorSubject } from "rxjs";
export class AuthService {
private _user$ = new BehaviorSubject<string | null>(null);
public get user$(): BehaviorSubject<string | null> {
return this._user$;
}
public login(userName: string, password: string | null): void {
this._user$.next(userName);
}
}
Hey everybody! Don't judge for my english, please. I need a help, because cannot find solution on my question. I have two separate application, host and remote. It isn't monorepo, and I want use Services and Components from remote app in host app not as page in router. For example in host app was created TestModule, and in template of this module I want use component from remote. Is it possible? Or I should create monorepo and create some shared libs and declare it in tsconfig?