Skip to content

Commit

Permalink
fix(config): add the option to exclude shared package
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Feb 17, 2021
1 parent a7084b2 commit 26691a4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/config/federated-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ module.exports = ({
shared = [],
debug,
moduleName,
useFileHash = true
useFileHash = true,
exclude = []
}) => {
const { dependencies, insights } = require(resolve(root, './package.json')) || {};
const appName = moduleName || (insights && insights.appname);

const sharedDeps = [
let sharedDeps = [
{ lodash: { singleton: true, ...dependencies.lodash && { requiredVersion: dependencies.lodash } } },
{ axios: { singleton: true, ...dependencies.axios && { requiredVersion: dependencies.axios } } },
...dependencies.redux ? [{ redux: { singleton: true, requiredVersion: dependencies.redux } }] : [],
Expand Down Expand Up @@ -53,12 +54,17 @@ module.exports = ({
}] : []
];

sharedDeps = sharedDeps.filter(entry => !exclude.includes(Object.keys(entry)[0]));

if (debug) {
console.log('Using package at path: ', resolve(root, './package.json'));
console.log('Using appName: ', appName);
console.log(`Using ${exposes ? 'custom' : 'default'} exposes`);
console.log('Number of custom shared modules is: ', shared.length);
console.log('Number of default shared modules is: ', sharedDeps.length);
if (exclude.length > 0) {
console.log('Excluding default packages', exclude);
}
}

return new ModuleFederationPlugin({
Expand Down

0 comments on commit 26691a4

Please sign in to comment.