Skip to content

Commit

Permalink
switch to @module-federation/enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Oct 17, 2024
1 parent 19e1c76 commit 22ccc24
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
});
_&>

const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
const { ModuleFederationPlugin } = require('@module-federation/enhanced/webpack');
<&- fragments.importsSection() &>
<%_ if (!clientFrameworkVue) { _%>
const packageJson = require('../package.json');
Expand Down Expand Up @@ -63,6 +63,8 @@ module.exports = () => {
filename: 'remoteEntry.js',
<%_ } _%>
shareScope: 'default',
dts: false,
manifest: false,
<&- fragments.moduleFederationSection() &>
}
<%_ } -%>
Expand All @@ -71,6 +73,7 @@ module.exports = () => {
],
output: {
publicPath: 'auto',
scriptType: 'text/javascript',
},
};
};
12 changes: 12 additions & 0 deletions generators/react/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ export default class ReactGenerator extends BaseApplicationGenerator {

get postWriting() {
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 },
});
},
addWebsocketDependencies({ application }) {
const { communicationSpringWebsocket, nodeDependencies } = application;
if (communicationSpringWebsocket) {
Expand Down
1 change: 1 addition & 0 deletions generators/react/resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"devDependencies": {
"@eslint/js": "9.12.0",
"@module-federation/enhanced": "0.6.11",
"@module-federation/utilities": "3.1.17",
"@testing-library/react": "16.0.1",
"@types/jest": "29.5.13",
Expand Down
3 changes: 0 additions & 3 deletions generators/react/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
"uuid": "<%= nodeDependencies['uuid'] %>"
},
"devDependencies": {
<%_ if (applicationTypeGateway && microfrontend) { _%>
"@module-federation/utilities": "<%= nodeDependencies['@module-federation/utilities'] %>",
<%_ } _%>
"@testing-library/react": "<%= nodeDependencies['@testing-library/react'] %>",
"@types/jest": "<%= nodeDependencies['@types/jest'] %>",
"@types/lodash": "<%= nodeDependencies['@types/lodash'] %>",
Expand Down
1 change: 1 addition & 0 deletions generators/vue/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export default class VueGenerator extends BaseApplicationGenerator {
}
this.packageJson.merge({
devDependencies: {
'@module-federation/enhanced': null,
'browser-sync-webpack-plugin': null,
'copy-webpack-plugin': null,
'css-loader': null,
Expand Down
1 change: 1 addition & 0 deletions generators/vue/resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"devDependencies": {
"@eslint/js": "9.12.0",
"@module-federation/enhanced": "0.6.11",
"@module-federation/utilities": "3.1.17",
"@pinia/testing": "0.1.6",
"@tsconfig/node18": "18.2.4",
Expand Down
2 changes: 2 additions & 0 deletions generators/vue/templates/module-federation.config.cjs.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ module.exports = {
'@/locale/translation.service',
),
},
dts: false,
manifest: false,
};

0 comments on commit 22ccc24

Please sign in to comment.