From 3a2bf7bb9a1cd22f4199a3126b50ed308ea4137b Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 24 Oct 2024 17:59:20 -0300 Subject: [PATCH] adjusts --- generators/react/generator.ts | 6 ------ .../templates/src/main/webapp/app/app.tsx.ejs | 16 ++++++++++++++++ .../templates/src/main/webapp/app/index.tsx.ejs | 16 ---------------- .../app/shared/layout/menus/entities.tsx.ejs | 8 ++++---- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/generators/react/generator.ts b/generators/react/generator.ts index c971bf3de8ed..08e0ca384a3f 100644 --- a/generators/react/generator.ts +++ b/generators/react/generator.ts @@ -198,12 +198,6 @@ export default class ReactGenerator extends BaseApplicationGenerator { return this.asPostWritingTaskGroup({ addMicrofrontendDependencies({ application }) { if (!application.microfrontend) return; - const { applicationTypeGateway } = application; - if (applicationTypeGateway) { - this.packageJson.merge({ - devDependencies: { '@module-federation/utilities': null }, - }); - } this.packageJson.merge({ devDependencies: { '@module-federation/enhanced': null }, }); diff --git a/generators/react/templates/src/main/webapp/app/app.tsx.ejs b/generators/react/templates/src/main/webapp/app/app.tsx.ejs index d9d1f1e524b3..16fee9ffc3ae 100644 --- a/generators/react/templates/src/main/webapp/app/app.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/app.tsx.ejs @@ -36,6 +36,22 @@ import { AUTHORITIES } from 'app/config/constants'; import AppRoutes from 'app/routes'; <%_ if (enableTranslation && enableI18nRTL) { _%> import { setTextDirection } from './config/translation'; +<%_ } _%> +<%_ if (applicationTypeGateway && microfrontend) { _%> +import { init } from '@module-federation/enhanced/runtime'; + +init({ + name: '<%= lowercaseBaseName %>', + remotes: [ + <%_ for (const remote of microfrontends) { _%> + { + name: '<%= remote.lowercaseBaseName %>', + entry: '/<%= remote.endpointPrefix %>/remoteEntry.js', + }, + <%_ } _%> + ], +}); + <%_ } _%> const baseHref = document.querySelector('base').getAttribute('href').replace(/\/$/, ''); diff --git a/generators/react/templates/src/main/webapp/app/index.tsx.ejs b/generators/react/templates/src/main/webapp/app/index.tsx.ejs index aaf0882e900e..c8c834e88b35 100644 --- a/generators/react/templates/src/main/webapp/app/index.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/index.tsx.ejs @@ -30,22 +30,6 @@ import { clearAuthentication } from 'app/shared/reducers/authentication'; import ErrorBoundary from 'app/shared/error/error-boundary'; import AppComponent from 'app/app'; import { loadIcons } from 'app/config/icon-loader'; -<%_ if (applicationTypeGateway && microfrontend) { _%> -import { init } from '@module-federation/enhanced/runtime'; - -init({ - name: '<%= lowercaseBaseName %>', - remotes: [ - <%_ for (const remote of microfrontends) { _%> - { - name: '<%= remote.lowercaseBaseName %>', - entry: '/<%= remote.endpointPrefix %>/remoteEntry.js', - }, - <%_ } _%> - ], -}); - -<%_ } _%> const store = getStore(); <%_ if (enableTranslation) { _%> diff --git a/generators/react/templates/src/main/webapp/app/shared/layout/menus/entities.tsx.ejs b/generators/react/templates/src/main/webapp/app/shared/layout/menus/entities.tsx.ejs index 680a7e64475c..f34566e892c0 100644 --- a/generators/react/templates/src/main/webapp/app/shared/layout/menus/entities.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/shared/layout/menus/entities.tsx.ejs @@ -26,10 +26,10 @@ import { loadRemote } from '@module-federation/enhanced/runtime'; const EntitiesMenuItems = React.lazy(() => import('app/entities/menu').catch(() => import('app/shared/error/error-loading'))); - <%_ if (applicationTypeGateway) { _%> + <%_ if (applicationTypeGateway && false) { _%> <%_ for (const remote of microfrontends) { _%> -const <%= remote.capitalizedBaseName %>EntitiesMenuItems = React.lazy(async () => - loadRemote('<%= remote.lowercaseBaseName %>/entities-menu').catch(() => import('app/shared/error/error-loading')), +const <%= remote.capitalizedBaseName %>EntitiesMenuItems = React.lazy((async () => + loadRemote('<%= remote.lowercaseBaseName %>/entities-menu'))().catch(() => import('app/shared/error/error-loading')), ); <%_ } _%> <%_ } _%> @@ -49,7 +49,7 @@ export const EntitiesMenu = () => ( loading...}> - <%_ if (applicationTypeGateway) { _%> + <%_ if (applicationTypeGateway && false) { _%> <%_ for (const remote of microfrontends) { _%> loading...}> <<%= remote.capitalizedBaseName %>EntitiesMenuItems />