@module-federation/storybook-addon
Version:
Storybook addon to consume remote module federated apps/components
33 lines (31 loc) • 1.11 kB
JavaScript
import { container } from "webpack";
import { getModuleFederationConfig } from "@nx/module-federation/src/with-module-federation/webpack/utils";
//#region src/utils/with-module-federation.ts
const { ModuleFederationPlugin } = container;
const updateMappedRemotes = (remotes) => {
const newRemotes = {};
Object.keys(remotes).forEach((key) => {
newRemotes[key] = `${key}@${remotes[key]}`;
});
return newRemotes;
};
const withModuleFederation = async (options) => {
const { mappedRemotes, sharedDependencies } = await getModuleFederationConfig(options);
return (config) => {
config.experiments = { outputModule: false };
config.optimization = { runtimeChunk: false };
config.output = { publicPath: "auto" };
config.plugins = config.plugins || [];
config.plugins.push(new ModuleFederationPlugin({
name: options.name,
filename: "remoteEntry.js",
shared: sharedDependencies,
exposes: options.exposes,
remotes: updateMappedRemotes(mappedRemotes)
}));
return config;
};
};
//#endregion
export { withModuleFederation as default };
//# sourceMappingURL=with-module-federation.js.map