简体   繁体   中英

A way to break Angular app into several Visual Studio projects

I'm looking for a way to write plugin-based Angular application using Visual Studio and ASP .NET Core SPA project template.

I'm newbie to Angular, and I still reading the docs .
It looks like router + lazy loaded modules is what I need. Main application doesn't need to refer these modules directly, and only appropriate routes configuration is required.

Also, some web search shows, that router can be reconfigured dynamically. Eg main app calls my API, which returns available routes, built from plugins list somehow.

The question is how lazy loaded angular modules will fit VS project system. All Angular + VS samples I found are using single VS project.

But I need something similar to C#/.NET. For example, typical plugin-based C# app consists of:

  • common project with plugin contract IPlugin ;
  • host project with some PluginHost , which knows about IPlugin and can load its implementations;
  • a number of projects with IPlugin implementations.

That is, someone can develop his own implementation, copy resulting assembly into app directory, re-run app, and get new functional.

Is there any way to achieve this using Angular and Visual Studio (not VS Code)?

You might want to design your common stuff and your implementations as angular libraries ( ng generate library ).

There are a few ways to pack this together - from Monorepo (which you apparently do not want to use) to building them all as separate libraries, but the main thing is still that you'd just import these libraries from npm as any other package (or as Angular itself) and use their exported APIs.

There are a few resources on this, eg this , this or this .

Now, how to proceed further than this, maybe read up a bit more and then post more specific questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM