Skip to content

Commit

Permalink
Merge pull request #2043 from Hyperkid123/singleton-imports
Browse files Browse the repository at this point in the history
Forbid imports and eager loading of core singleton packages.
  • Loading branch information
Hyperkid123 authored Aug 7, 2024
2 parents 3665493 + 08023b4 commit b324793
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/config-utils/src/federated-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const defaultPluginMetaDataJSON = {
extensions: [],
};

const createIncludes = (eager = false): { [module: string]: WebpackSharedConfig } => ({
'@patternfly/quickstarts': { singleton: true, eager },
'@redhat-cloud-services/chrome': { singleton: true },
const createIncludes = (): { [module: string]: WebpackSharedConfig } => ({
'@patternfly/quickstarts': { singleton: true, eager: false, import: false },
'@redhat-cloud-services/chrome': { singleton: true, import: false },
axios: {},
lodash: {},
react: { singleton: true, eager },
'react-dom': { singleton: true, eager },
react: { singleton: true, eager: false, import: false },
'react-dom': { singleton: true, eager: false, import: false },
});

export type FederatedModulesConfig = {
Expand Down Expand Up @@ -53,11 +53,10 @@ const federatedModules = ({
useFileHash = true,
separateRuntime = false,
exclude = [],
eager = false,
pluginMetadata,
extensions = [],
}: FederatedModulesConfig) => {
const include = createIncludes(eager);
const include = createIncludes();

const { dependencies, insights } = require(resolve(root, './package.json')) || {};
const appName = moduleName || (insights && jsVarName(insights.appname));
Expand Down Expand Up @@ -92,14 +91,19 @@ const federatedModules = ({
* No application should be installing/interacting with scalprum directly.
*/
if (dependencies['@redhat-cloud-services/frontend-components']) {
sharedDeps['@scalprum/react-core'] = { requiredVersion: '*', singleton: true, eager };
sharedDeps['@scalprum/react-core'] = { requiredVersion: '*', singleton: true, eager: false, import: false };
}

/**
* Make sure the unleash proxy client is a singleton
*/
if (dependencies['@unleash/proxy-client-react']) {
sharedDeps['@unleash/proxy-client-react'] = { singleton: true, requiredVersion: dependencies['@unleash/proxy-client-react'] };
sharedDeps['@unleash/proxy-client-react'] = {
singleton: true,
eager: false,
import: false,
requiredVersion: dependencies['@unleash/proxy-client-react'],
};
}

if (debug) {
Expand Down

0 comments on commit b324793

Please sign in to comment.