Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ table in [Console dynamic plugins README](./README.md).
- **Deprecated**: `loadPluginEntry` callback is deprecated in favor of `__load_plugin_entry__`. Migrate by
building your plugin with a 4.22 or later of `ConsoleRemotePlugin`. Runtime support for older plugins
built for 4.21 or older will be removed in a future version of OCP Console. ([CONSOLE-3769], [#15904])
- Add warnings for usage of deprecated Console provided shared modules ([CONSOLE-5135], [#16178])

## 4.22.0-prerelease.1 - 2025-01-21

Expand Down Expand Up @@ -109,6 +110,7 @@ table in [Console dynamic plugins README](./README.md).
[CONSOLE-4400]: https://issues.redhat.com/browse/CONSOLE-4400
[CONSOLE-4623]: https://issues.redhat.com/browse/CONSOLE-4623
[CONSOLE-5050]: https://issues.redhat.com/browse/CONSOLE-5050
[CONSOLE-5135]: https://issues.redhat.com/browse/CONSOLE-5135
[OCPBUGS-30762]: https://issues.redhat.com/browse/OCPBUGS-30762
[OCPBUGS-30824]: https://issues.redhat.com/browse/OCPBUGS-30824
[OCPBUGS-31901]: https://issues.redhat.com/browse/OCPBUGS-31901
Expand Down Expand Up @@ -140,5 +142,6 @@ table in [Console dynamic plugins README](./README.md).
[#15479]: https://github.com/openshift/console/pull/15479
[#15802]: https://github.com/openshift/console/pull/15802
[#15904]: https://github.com/openshift/console/pull/15904
[#15945]: https://github.com/openshift/console/pull/15945
[#15934]: https://github.com/openshift/console/pull/15934
[#15945]: https://github.com/openshift/console/pull/15945
[#16178]: https://github.com/openshift/console/pull/16178
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type SharedModuleMetadata = Partial<{
* @default false
*/
allowFallback: boolean;

/** A message describing the deprecation, if the module is deprecated. */
deprecated: string | false;
}>;

/**
Expand Down Expand Up @@ -50,8 +53,8 @@ const sharedPluginModulesMetadata: Record<SharedModuleNames, SharedModuleMetadat
'react-i18next': {},
'react-redux': {},
'react-router': {},
'react-router-dom': {}, // Deprecated; aliased to react-router
'react-router-dom-v5-compat': {}, // Deprecated; aliased to react-router
'react-router-dom': { deprecated: 'Use react-router instead.' },
'react-router-dom-v5-compat': { deprecated: 'Use react-router instead.' },
redux: {},
'redux-thunk': {},
};
Expand All @@ -62,6 +65,10 @@ const sharedPluginModulesMetadata: Record<SharedModuleNames, SharedModuleMetadat
export const getSharedModuleMetadata = (
moduleName: SharedModuleNames,
): Required<SharedModuleMetadata> => {
const { singleton = true, allowFallback = false } = sharedPluginModulesMetadata[moduleName];
return { singleton, allowFallback };
const {
singleton = true,
allowFallback = false,
deprecated = false,
} = sharedPluginModulesMetadata[moduleName];
return { singleton, allowFallback, deprecated };
};
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ export const validateConsoleExtensionsFileSchema = (
return new SchemaValidator(description).validate(schema, extensions);
};

const getDeprecatedSharedModuleWarnings = (pkg: ConsolePluginPackageJSON): string[] => {
const pluginDeps = getPackageDependencies(pkg);
const warnings: string[] = [];

sharedPluginModules.forEach((moduleName) => {
const { deprecated } = getSharedModuleMetadata(moduleName);

if (deprecated && pluginDeps[moduleName]) {
warnings.push(
`shared modules: [DEPRECATION ALERT] '${moduleName}' is deprecated. ${deprecated}`,
);
}
});

return warnings;
};

const validateConsoleProvidedSharedModules = (pkg: ConsolePluginPackageJSON) => {
const pluginDeps = getPackageDependencies(pkg);
const sdkPkgDeps = getPluginSDKPackagePeerDependencies();
Expand Down Expand Up @@ -372,6 +389,7 @@ export class ConsoleRemotePlugin implements WebpackPluginInstance {
} = pluginMetadata;

const logger = compiler.getInfrastructureLogger(ConsoleRemotePlugin.name);

const publicPath = `/api/plugins/${name}/`;

if (compiler.options.output.publicPath !== undefined) {
Expand Down Expand Up @@ -455,6 +473,10 @@ export class ConsoleRemotePlugin implements WebpackPluginInstance {
});

compiler.hooks.thisCompilation.tap(ConsoleRemotePlugin.name, (compilation) => {
getDeprecatedSharedModuleWarnings(this.pkg).forEach((message) => {
compilation.warnings.push(new compiler.webpack.WebpackError(message));
});

const modifiedModules: string[] = [];

compiler.webpack.NormalModule.getCompilationHooks(compilation).beforeLoaders.tap(
Expand Down