Skip to content

Instantly share code, notes, and snippets.

@muhdkhokhar
Created April 30, 2022 15:19
Show Gist options
  • Save muhdkhokhar/0095f35fc3811226c8219e8eb26505e8 to your computer and use it in GitHub Desktop.
Save muhdkhokhar/0095f35fc3811226c8219e8eb26505e8 to your computer and use it in GitHub Desktop.
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const mf = require("@angular-architects/module-federation/webpack");
const path = require("path");
const share = mf.share;
const sharedMappings = new mf.SharedMappings();
sharedMappings.register(path.join(__dirname, "tsconfig.json"), [
/* mapped paths to share */
]);
module.exports = {
output: {
uniqueName: "remote1",
publicPath: "auto",
},
optimization: {
runtimeChunk: false,
},
resolve: {
alias: {
...sharedMappings.getAliases(),
},
},
plugins: [
new ModuleFederationPlugin({
// For remotes (please adjust)
name: "mfe2",
filename: "remoteEntry.js",
exposes: {
"./Module1": "./src/app/microfrontend1/microfrontend1.module.ts",
},
// For hosts (please adjust)
// remotes: {
// "mfe1": "mfe1@http://localhost:3000/remoteEntry.js",
// },
shared: share({
"@angular/core": {
singleton: true,
strictVersion: true,
requiredVersion: "auto",
},
"@angular/common": {
singleton: true,
strictVersion: true,
requiredVersion: "auto",
},
"@angular/common/http": {
singleton: true,
strictVersion: true,
requiredVersion: "auto",
},
"@angular/router": {
singleton: true,
strictVersion: true,
requiredVersion: "auto",
},
...sharedMappings.getDescriptors(),
}),
}),
sharedMappings.getPlugin(),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment