Skip to content

Micro-Frontend: Allow to have separate build/ releasable elements for lazy loaded modules  #20056

@mohyeid

Description

@mohyeid

🚀 feature request

Relevant Package

@angular/cli

Description

With Micro-frontend being a hot topic those days, I have seen people taking the wrong approach with their angular projects. Thankfully, we have angular elements that allow us to create pure web-components, but unfortunately this have been misused to allow the micro frontend concept in an angular application. To allow smaller releasable packages, engineers started to create angular elements release them to a CDN site, and re-use them. This created a lot of fraction and challenges to integrate the different pieces. Not only that, but it's also awkward, as you are creating vanilla javascript code from angular code to re-use it back again from an angular code. Other solutions was iframing, which also does not scale. Or releasing smaller libs to npm and re-using them in the code, which is not desired in the case of end to end integration and mon-repo large applications.

Describe the solution you'd like

If you have a solution in mind, please describe it.

Today, we are blessed by having the lazy loading approach which help us to generate separate chunks of the code and lazy load them as the user is visiting the relevant code. While this is great, there is no way to build those chunks separately and/or publish them to a standalone CDN/Server to be used later. I think to help teams avoid mistakes like listed above, it would be awesome if we can have angular CLI able to build these chunks separately, generate an artifact for it, which can be released individually. When this is accomplished, we can then have something like this:

const routes: Routes = [
  {
    path: 'items',
    loadChildren: () => import(env.prod? 'https://CDN-XYA/chunk1.js' : './items/items.module' ).then(m => m.ItemsModule)
  }
]; 

Describe alternatives you've considered

Yes, above but it's not ideal. I think angular team need to get into the micro frontend business.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions