@module-federation/storybook-addon
Version:
Storybook addon to consume remote module federated apps/components
33 lines • 1.2 kB
JavaScript
import { getModuleFederationConfig } from '@nx/module-federation/src/with-module-federation/webpack/utils';
import { container } from 'webpack';
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;
};
};
export default withModuleFederation;
//# sourceMappingURL=with-module-federation.js.map