8

I have a huge Angular application where a couple of components are exported as @angular/elements.

These components (although they still use shared services and components) are used in a different section of the website which is not part of the Single Page Application, but it is a stand-alone page delivered by the server.

The exported angular elements work fine in the new page, but I don't consider acceptable load the whole SPA bundle (which si 5MB+) just to render two components. How can I generate a different javascript file for each angular elements?

I'd like to render my components like this:

<my-first-component />
<script src="./my-first-component.js"></script>

<my-second-component>
<script src="./my-second-component.js"></script>

But if the page generates a single bundle, the components (or, better, the custom elements) won't be independent by each other! And it's obvious that, in this context, concatanation doesn't work.

How can I solve this problem?

Thank you

0 Answers0