Angular 2 - How to manage multiple application with common components in a server side rendered environment

Viewed 244

I'm working on a project that leverage angular modularity inside a server side application. It is designed in this way:

  • Common Library (Included in all the pages)
  • Application 1 (Included in the home page, import the common library)
  • Application 2 (Included in the contact page, import the common library)
  • ...

Today it is developed with Angular 1.4 and share the common library is not a problem as it is loaded in all pages.

I would like to start moving toward Angular 2 and Webpack (because of the Hot Module Replacement) but it is not clear to me how to handle the build.

My problem is, if I require the common library into each application I'll find duplicate and minified in each bundle and this make no sense to me, so, what will be a better approach?

I guess a possible one will be using System.js to enable require in the browser but I don't feel enthusiast with it.

Is there a correct way to split an application in multiple files? There are some "rules" to be aware in doing this?

0 Answers
Related