Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImprove bundling experience for supporting multiple Angular Elements on a page #19164
Comments
+1 |
is there any news? thanks :) |
In the linked issue and in many other related issues, the advised solution was to use ngx-build-plus and many threads were flagged as "won't fix". I think this cannot be the solution, for four reasons:
|
Take a look at this issue: angular/angular#35429 I also posted a solution with pure angular toolchain which is working. cheers |
thanks @flash-me. I'll read through all your replies and see how it goes. My intention was to ask if there was an official way to have multiple angular elements living togheter and not using some special/custom hacks. In my case I have implemented a simple script which renames the webpackJsonp variable during the building process. |
Hi @dsozzi the only "hack" is that you need to compile your angular element as a library (ng-packagr with that builder that comes with the angular-cli) instead of an application. Instruction and implementation can be found in the repo I posted cheers |
It's already longer possible to bootstrap multiple applications. The tricky part was, to run them all with one dependency injection container and one change detection umbrella. But wasn't that fixed with the new |
@sod I don't know how "platform" Provision is related to change detection and even the mentioned issue of this topic. How should I profit from providing I don't see any relation between Change Detection, "platform" Provisioning & Components. Can you describe your intent? cheers |
Should I make a comment to bring more attention to this matter? |
What kind of optimization do you expect? What do you think is missing? cheers |
Thanks for answering, flash In our company, we have been developing multiple angular project in the recent years. 10s of them, each with some components that follow company UX UI guideline, resulting in duplicated work I would like to know if Whoever use both Element A and B would suffer the bundle size of duplicated P2 P3 P4 right // Did my question spiraled out of context considering the current issue? |
@qkhanhpro The key point is to place all of such components into one placeholder application that allows you to generate only the same runtime bundle for them. So the ideal strategy is to use probably some monorepo, as Nx, for example, and if it has a sense (depends on the type of those components), use lazy loading. Their code will be loaded lazily and individually then, in a moment of their real use. |
You may have a Look at this: https://github.com/flash-me/angular-micro-frontends But in that repo I'm aiming for minimal usage of dependencies. So I even removed the cli and ng-packagr and directly use ngc + rollup. Depending on the skillset of the developers, this might be an issue regarding developer experience. If you prefer the angular cli toolchain, you can have a look on this previous commit: https://github.com/flash-me/angular-micro-frontends/tree/d2cdf8975ff29b7b9e7d9ff127a88104d09c006e back to the questions:
But to be honest. Such solution is not handy for the average angular developer, since a lot more knowledge is required. Hope I could help you a little bit cheers |
This way, your projects are hard coupled to one application and everything needs to be bundled on every change. If this fits the requirements, I'd strongly recommend this way, since it's officially intended and supported. cheers |
Moving this to the CLI repo since it relates to bundling. I believe this would fall under the feature request umbrella for CLI. |
Hi,
I’d like to bring some attention back to this original post
angular/angular#23732
Where it’s stating that in previous Angular version it was not possible to run multiple Angular Elements on a single page and we had to wait for Ivy release.
Now that we are at version 9 and Ivy is enabled by default, I was wondering if there are any progress regarding this issue.
Thanks
UPDATE by @gkalpak (for visibility):
List of related issues (with useful context, info, explanations):