department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
283 stars 204 forks source link

Identity Dashboard (FE) - Micro-frontend aka Module Federation #59147

Closed asg5704 closed 1 year ago

asg5704 commented 1 year ago

Description

Research and implement Module Federation with Next.js (identity-dashboard-fe) and Vue (fwa-dashboard)

Tasks

acald-creator commented 1 year ago

Created private repo at https://github.com/department-of-veterans-affairs/identity-microfrontend for testing implementation unrelated to the current Next.js and Vue app.

Will list findings of potential issues and how this can be implemented.

acald-creator commented 1 year ago

Created separate repo to track different implementations on how to setup module federation with different frameworks: https://github.com/department-of-veterans-affairs/vsp-idp-microfrontend-test

acald-creator commented 1 year ago

Implementation Module Federation with Next.js 13 app router and Vue.js 3

Pros:

Cons:

Resources:

However, pertaining to the current project, implementing Micro-frontend with Vue.js and Next.js will not work as expected.

Next.js 13 currently has an app directory layout which might not have full support with using @module-federation/nextjs-mf, and if there is, this implementation is tightly coupled and supported within Next.js apps, not any other apps outside of Next.js.

There is support to use React with Next.js in a module federation format, but extra configuration are needed to make sure that the implementation works properly.

Also, Next.js 13 also supports React Server Components, which means you have to declare which is Client Component and which is Server Components.

Next.js 13 also has a pages directory layout where @module-federation/nextjs-mf is working properly, but there are potential issues with importing and displaying the component. There are suggestions to use async boundary, which means waiting to check the module is available before loading the module.

In the case of using Next.js 13 with Vue.js, there doesn't seem to be an easier way to implement this.

Tool that could serve as a wrapper to use React in Vue, and Vue in React

Cons for the above is adding overhead and maintaining another package if we were to create our own library.

Potential alternative project layout (future reference)

asg5704 commented 1 year ago

@acald-creator Can you provide your recommendation on moving forward. Would it be easier to migrate the FWA dashboard to React, or would it be worth it to use one the packages you mentioned. Thanks

acald-creator commented 1 year ago

@asg5704

My recommendation is to migrate the FWA app to React.

If we do try and use one of the libraries that is a wrapper for a React component and vice versa, the question would be whether the package itself is maintained or not. There is one that is not maintained at this link: https://github.com/akxcv/vuera.

The other two are for their company use cases, and may not necessarily suit us.

The other issue would be permission on whether we can use it, so this means forking our own to maintain it.

In conclusion, I would suggest migrating the FWA dashboard to React. I can assist with this if there are issues with migrating.

asg5704 commented 1 year ago

Sounds good. Put this ticket in PM review and I'll create a new one for the eventual migration in the backlog.

aparsley commented 1 year ago

Looks great, keep up the good work.

asg5704 commented 1 year ago

Added to sprint report 11