Home > Software engineering >  How to share services and interfaces between 2 separate projects
How to share services and interfaces between 2 separate projects

Time:09-26

I have an angular application that uses some services and interfaces. I want to create a new project that is going to use the same services and interfaces, I do not want to duplicate them as if I do any change to these files I need them to apply to both projects. I also cannot add the new app under the same project as the existing one is a bit complicated and suddenly changing the structure can cause a lot of unpredicted issues.

So is there a way where I can use the services and interfaces for 2 different projects?

CodePudding user response:

The application is build using web pack and the files are compressed. You cannot access other app files, which may cause CORS. So you should be able to build using some common terms and run a wrapper app. Micro fronts are a solution.

I think you can create shared module - maybe a wrapper module that wraps the other components. I think you may use Module Federation.

Here is a POC - https://dev.to/bitovi/how-to-build-a-micro-frontend-with-webpacks-module-federation-plugin-n41

Hope this helps.

CodePudding user response:

there's something called monorepo - it lets you create separate apps under the same project so you can share classes and interfaces between them. try - NX. this is a monorepo system specific to js framework such as - angular react express nestjs

  • Related