Skip to content

Commit

Permalink
adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Oct 29, 2024
1 parent 5b47ed3 commit 3a2bf7b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
6 changes: 0 additions & 6 deletions generators/react/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
Expand Down
16 changes: 16 additions & 0 deletions generators/react/templates/src/main/webapp/app/app.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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(/\/$/, '');
Expand Down
16 changes: 0 additions & 16 deletions generators/react/templates/src/main/webapp/app/index.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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) { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>('<%= remote.lowercaseBaseName %>/entities-menu').catch(() => import('app/shared/error/error-loading')),
const <%= remote.capitalizedBaseName %>EntitiesMenuItems = React.lazy((async () =>
loadRemote<any>('<%= remote.lowercaseBaseName %>/entities-menu'))().catch(() => import('app/shared/error/error-loading')),
);
<%_ } _%>
<%_ } _%>
Expand All @@ -49,7 +49,7 @@ export const EntitiesMenu = () => (
<Suspense fallback={<div>loading...</div>}>
<EntitiesMenuItems />
</Suspense>
<%_ if (applicationTypeGateway) { _%>
<%_ if (applicationTypeGateway && false) { _%>
<%_ for (const remote of microfrontends) { _%>
<Suspense fallback={<div>loading...</div>}>
<<%= remote.capitalizedBaseName %>EntitiesMenuItems />
Expand Down

0 comments on commit 3a2bf7b

Please sign in to comment.