Skip to content

Instantly share code, notes, and snippets.

@amir2mi
Last active May 23, 2024 05:43
Show Gist options
  • Save amir2mi/c9fd7b657d148ff5355039c1207a3015 to your computer and use it in GitHub Desktop.
Save amir2mi/c9fd7b657d148ff5355039c1207a3015 to your computer and use it in GitHub Desktop.
Setup module federation for Next.js using @module-federation/nextjs-mf
const nextJsConfig = {
webpack(config, options) {
if (!options?.isServer) {
config.plugins.push(
new NextFederationPlugin({
name: "service-name",
filename: "static/chunks/remoteEntry.js",
exposes: {
"./pages/index": "./pages/index.jsx",
},
shared: {
zustand: {
singleton: true,
},
antd: {
singleton: true,
},
redux: {
singleton: true,
},
},
extraOptions: {
enableUrlLoaderFix: true,
enableImageLoaderFix: true,
},
})
);
}
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment